...
 
Commits (5)
......@@ -5,4 +5,5 @@ bin/
*.wixpdb
*.msi
*-files.wxs
t1*
\ No newline at end of file
t1*
.vscode/
\ No newline at end of file
This diff is collapsed.
// Copyright (C) 2019 Yuanle Song <[email protected]>
//
// This file is part of mbackup-for-windows.
//
// mbackup-for-windows is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// mbackup-for-windows is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>.
module Mbackup.ConfigParser
open System
......
# Copyright (C) 2019 Yuanle Song <[email protected]>
#
# This file is part of mbackup-for-windows.
#
# mbackup-for-windows is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# mbackup-for-windows is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# mbackup-for-windows. If not, see <http:#www.gnu.org/licenses/>.
[xml]$FSPROJ = Get-Content mbackup.fsproj
Write-Output $FSPROJ.Project.PropertyGroup.Version
// Copyright (C) 2019 Yuanle Song <[email protected]>
//
// This file is part of mbackup-for-windows.
//
// mbackup-for-windows is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// mbackup-for-windows is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>.
module Mbackup.Lib
open System
......
......@@ -5,6 +5,7 @@ LIGHT := "$(WIX_DIR)\light.exe" -nologo
RSYNC_MINGW_DIR := D:\downloads\apps\rsync-w64
MBACKUP_PUBLISH_DIR := bin\Release\netcoreapp3.0\publish
MBACKUPW_PUBLISH_DIR := mbackupw\bin\Release\netcoreapp3.0\publish
MSI_DIR := D:\downloads\upload
VERSION := $(shell powershell -NoProfile -File GetVersion.ps1)
......@@ -17,11 +18,14 @@ all: test release dist
dist: msi
release: test
dotnet publish --nologo -c Release --self-contained false
dotnet publish --nologo -c Release --self-contained false mbackupw
cmd /C 'COPY /Y $(MBACKUPW_PUBLISH_DIR)\*.* $(MBACKUP_PUBLISH_DIR)\'
test:
dotnet test --nologo mbackup-tests
check: test
build:
dotnet build --nologo
dotnet build --nologo mbackupw
clean:
dotnet clean --nologo
cmd /C 'del *.wixobj *.wixpdb *.msi rsync-mingw64-files.wxs'
......
// Learn more about F# at http://fsharp.org
// Copyright (C) 2019 Yuanle Song <[email protected]>
//
// This file is part of mbackup-for-windows.
//
// mbackup-for-windows is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// mbackup-for-windows is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>.
//
// - mbackup config file
// %programdata%/mbackup/mbackup-config.txt
......@@ -254,7 +270,7 @@ let main argv =
let rsyncCmd =
let localExcludeFile = userConfigDir + MbackupFileName.LocalExclude
if File.Exists localExcludeFile then
let convertAbsPathToMingwStyle (line: string) =
let convertAbsPathToMingwStyle (line: string) =
if Regex.IsMatch(line, "[a-z]:", RegexOptions.IgnoreCase) then
toMingwPath line
else
......
mbackup for windows
====================
Intro
------
mbackup is a file backup tool based on [rsync](https://rsync.samba.org/).
It supports backup a list of files and dirs to local dir or remote ssh node.
Difference with rsync: rsync doesn't have an official windows build. rsync
doesn't support windows style path in source, target, and file lists. You can
run rsync in cygwin or msys2 shell. But usually it's painful to run it in
windows cmd or powershell directly. Mbackup is a thin wrapper around rsync,
with support for windows style path and bundled openssh client.
Installation
-------------
mbackup is written in F# and C# in dotnet core 3.
To install mbackup, get .NET Core Installer and .NET Core Desktop Installer
from [dotnet core 3](https://dotnet.microsoft.com/download/dotnet-core/3.0)
and install both.
Get mbackup msi installer from
https://emacsos.com/software/mbackup-for-windows and run it. I don't have a
key to sign the exe, you should verify sha256sum if you worry about file
integrity.
Backup List and Exclude lists
------------------------------
By default, the following files are backed up by mbackup:
- C:\ProgramData\mbackup
- C:\Docs
- D:\Docs
- <User>\Documents
- <User>\Desktop
- <User>\Downloads
- <User>\Pictures\Saved Pictures\
- <User>\<dot files>
By default, some files are ignored, such as iso, rar, zip, exe etc. mbackup is
designed to backup user created contents, not downloaded contents. That's why
archives and executables are excluded by default.
You can add more dirs to backup in %programdata%\mbackup\local-list.txt
Here are the backup list files and exclude pattern files:
- backup file list
%programdata%\mbackup\default-list.txt
%programdata%\mbackup\user-default-list.txt
%programdata%\mbackup\local-list.txt (managed by user)
- exclude pattern
%programdata%\mbackup\default-exclude.txt
%programdata%\mbackup\local-exclude.txt (managed by user)
local-list.txt and local-exclude.txt are managed by user and mbackup will not
modify those files when it is uninstalled or upgraded. The other lists are
shipped with mbackup and will be removed/overwritten when
uninstalling/upgrading mbackup.
To learn more about file list and exclude patterns, read rsync man page
https://download.samba.org/pub/rsync/rsync.html --files-from option,
--exclude-from option, and INCLUDE/EXCLUDE PATTERN RULES section.
How to Invoke mbackup
----------------------
mbackup for windows is designed to run automatically in the background via
Windows Task Scheduler (Win+R taskschd.msc). You can also run in from windows
cmd or powershell to trigger a backup immediately.
For the automatic backup to work, you need to specify a target in mbackup
config file.
Open mbackup config file %programdata%\mbackup\mbackup-config.txt,
To backup to local disk, add config
target=D:\backup
Replace D:\backup with the dir you want to save backup files to.
To backup to remote ssh node, add config
[email protected]:/path/to/dir
ssh-key=D:\path\to\id_rsa
Replace ssh-key path with your ssh private key. Since mbackup is designed to
run in the background, only ssh key based authentication (with no passphrase)
is supported. If you use password to login your server, you may learn
[how to set up ssh keys](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2).
Save mbackup-config.txt file, now auto backup will work. The default scheduler
runs mbackup a few minutes after user logon and every 2 hours during
daytime. You can open Task Scheduler to check the scheduler.
Here is how to run it in cmd or powershell:
%programfiles%\mbackup\publish\mbackup.exe --help
%programfiles%\mbackup\publish\mbackup.exe
You can also drag the mbackup shortcut to cmd window:
C:\Users\Public\Desktop\mbackup.lnk --help
C:\Users\Public\Desktop\mbackup.lnk
You can also click mbackup.exe shortcut on desktop or start menu. The downside
is the window will auto close after mbackup finishes.
You can check mbackup run log in %localappdata%\mbackup\mbackup.log
License
--------
Copyright (C) 2019 Yuanle Song <[email protected]>
This file is part of mbackup-for-windows.
mbackup-for-windows is free software: you can redistribute
it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any
later version.
mbackup-for-windows is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public
License along with this program. If not, see
<https://www.gnu.org/licenses/>.
# dirs to backup
C:\ProgramData\mbackup
C:\path\to\dir
D:\path\to\dir
C:\Docs
D:\Docs
<Project Sdk="Microsoft.NET.Sdk">
<!-- Copyright (C) 2019 Yuanle Song <[email protected]> -->
<!-- This file is part of mbackup-for-windows. -->
<!-- mbackup-for-windows is free software: you can redistribute it and/or modify -->
<!-- it under the terms of the GNU General Public License as published by the -->
<!-- Free Software Foundation, either version 3 of the License, or (at your -->
<!-- option) any later version. -->
<!-- mbackup-for-windows is distributed in the hope that it will be useful, but -->
<!-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -->
<!-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -->
<!-- more details. -->
<!-- You should have received a copy of the GNU General Public License along with -->
<!-- mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>. -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
......@@ -6,7 +23,7 @@
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<RootNamespace>Mbackup</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>0.4.5.0</Version>
<Version>0.5.1.0</Version>
</PropertyGroup>
<ItemGroup>
......
<?xml version="1.0"?>
<!-- Copyright (C) 2019 Yuanle Song <[email protected]> -->
<!-- This file is part of mbackup-for-windows. -->
<!-- mbackup-for-windows is free software: you can redistribute it and/or modify -->
<!-- it under the terms of the GNU General Public License as published by the -->
<!-- Free Software Foundation, either version 3 of the License, or (at your -->
<!-- option) any later version. -->
<!-- mbackup-for-windows is distributed in the hope that it will be useful, but -->
<!-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -->
<!-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -->
<!-- more details. -->
<!-- You should have received a copy of the GNU General Public License along with -->
<!-- mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>. -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="3030B91E-5E3E-4151-9A69-B53B72690430" Version="$(var.Version)" Language="1033" Name="mbackup" Manufacturer="Yuanle Song">
<Package InstallScope="perMachine" InstallerVersion="300" Compressed="yes"/>
......@@ -15,7 +31,7 @@
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
<Directory Id="ProgramMenuFolder">
<Directory Id="mbackup_start_menu_dir" Name="mbackup" />
<Directory Id="MbackupStartMenuDir" Name="mbackup" />
</Directory>
</Directory>
......@@ -44,19 +60,19 @@
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="mbackup_desktop_shortcuts" Guid="*">
<Component Id="MbackupDesktopShortcut" Guid="*">
<Shortcut Id="DesktopMbackupExe"
Name="mbackup"
Description="Backup your computer using rsync"
Target="[!filE3FFB5E42FD6DDB7AD945F29409779F0]"
WorkingDirectory="MBACKUP_PROGRAM_FILES"/>
<RemoveFolder Id="MbackupDesktopShortcut" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\mbackup\desktopshortcuts" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<RegistryValue Root="HKCU" Key="Software\mbackup" Name="DesktopShortcutInstalled" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="mbackup_start_menu_dir">
<Component Id="mbackup_start_menu" Guid="F7C168BA-BDC9-4C4D-8AE7-722AC399AFD5">
<DirectoryRef Id="MbackupStartMenuDir">
<Component Id="MbackupStartMenuShortcuts" Guid="*">
<Shortcut Id="StartMenuMbackupExe"
Name="mbackup"
Description="Backup your computer using rsync"
......@@ -77,8 +93,8 @@
Description="mbackup local-exclude.txt file"
Target="[!local_exclude.txt]"
WorkingDirectory="MBACKUP_PROGRAM_FILES"/>
<RemoveFolder Id="mbackup_start_menu_dir" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\mbackup\startmenushortcuts" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<RemoveFolder Id="MbackupStartMenuDirRemove" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\mbackup" Name="StartMenuShortcutsInstalled" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
......@@ -94,7 +110,7 @@
Impersonate="no"
Execute="deferred"
Directory="TARGETDIR"
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /RU SYSTEM /RP /NP /SC ONLOGON /TN &quot;mbackup-logon&quot; /TR &quot;[MBACKUP_PROGRAM_FILES]publish\mbackup.exe&quot; /DELAY 0015:00" />
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /RU BUILTIN\USERS /RP /NP /SC ONLOGON /TN &quot;mbackup-logon&quot; /TR &quot;[MBACKUP_PROGRAM_FILES]publish\mbackupw.exe&quot; /DELAY 0015:00" />
<CustomAction Id="RemoveScheduledTaskLogon"
Return="check"
Impersonate="no"
......@@ -106,7 +122,7 @@
Impersonate="no"
Execute="deferred"
Directory="TARGETDIR"
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /RU SYSTEM /RP /NP /SC DAILY /TN &quot;mbackup-interval&quot; /TR &quot;[MBACKUP_PROGRAM_FILES]publish\mbackup.exe&quot; /ST 09:00 /DU 17:00 /RI 120 /K" />
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /RU BUILTIN\USERS /RP /NP /SC DAILY /TN &quot;mbackup-interval&quot; /TR &quot;[MBACKUP_PROGRAM_FILES]publish\mbackupw.exe&quot; /ST 09:00 /DU 17:00 /RI 120 /K" />
<CustomAction Id="RemoveScheduledTaskInterval"
Return="check"
Impersonate="no"
......@@ -123,8 +139,8 @@
<ComponentRef Id="local_exclude.txt" />
<ComponentRef Id="mbackup_config.txt" />
<ComponentRef Id="user_default_list.txt" />
<ComponentRef Id="mbackup_start_menu" />
<ComponentRef Id="mbackup_desktop_shortcuts" />
<ComponentRef Id="MbackupDesktopShortcut" />
<ComponentRef Id="MbackupStartMenuShortcuts" />
</Feature>
</Product>
</Wix>
// Copyright (C) 2019 Yuanle Song <[email protected]>
//
// This file is part of mbackup-for-windows.
//
// mbackup-for-windows is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// mbackup-for-windows is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>.
namespace mbackupw
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "mbackupw";
}
#endregion
}
}
// Copyright (C) 2019 Yuanle Song <[email protected]>
//
// This file is part of mbackup-for-windows.
//
// mbackup-for-windows is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// mbackup-for-windows is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace mbackupw
{
/**
* This is a winforms application used to invoke mbackup.exe without showing cmd.exe window.
* This application is invoked by schtasks to run mbackup regularly.
*/
public partial class Form1 : Form
{
private Timer exitTimer;
// https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
private const int WS_EX_NOACTIVATE = 0x08000000;
private const int EXIT_TIMEOUT = 2;
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= WS_EX_NOACTIVATE;
return createParams;
}
}
protected override bool ShowWithoutActivation
{
get { return true; }
}
private static void ExitTimerHandler(Object timer, EventArgs eventArgs)
{
Application.Exit();
}
private void ExitInNSeconds(int n)
{
exitTimer = new Timer();
exitTimer.Tick += new EventHandler(ExitTimerHandler);
exitTimer.Interval = n * 1000;
exitTimer.Start();
}
private void RunMbackup()
{
string programFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
string mbackupExe = programFilesDir + "\\mbackup\\publish\\mbackup.exe";
int timeoutSeconds = 4 * 3600;
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = mbackupExe,
Arguments = "",
CreateNoWindow = true
};
Process proc = Process.Start(startInfo);
if (proc.WaitForExit(timeoutSeconds * 1000)) {
Environment.ExitCode = proc.ExitCode;
} else {
Environment.ExitCode = EXIT_TIMEOUT;
proc.Kill();
}
Application.Exit();
Environment.Exit(Environment.ExitCode);
}
public Form1()
{
InitializeComponent();
// Hide form
Opacity = 0;
ShowInTaskbar = false;
RunMbackup();
// auto exit. just used for easier testing.
// ExitInNSeconds(2);
}
}
}
// Copyright (C) 2019 Yuanle Song <[email protected]>
//
// This file is part of mbackup-for-windows.
//
// mbackup-for-windows is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// mbackup-for-windows is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace mbackupw
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
<!-- Copyright (C) 2019 Yuanle Song <[email protected]> -->
<!-- This file is part of mbackup-for-windows. -->
<!-- mbackup-for-windows is free software: you can redistribute it and/or modify -->
<!-- it under the terms of the GNU General Public License as published by the -->
<!-- Free Software Foundation, either version 3 of the License, or (at your -->
<!-- option) any later version. -->
<!-- mbackup-for-windows is distributed in the hope that it will be useful, but -->
<!-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -->
<!-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -->
<!-- more details. -->
<!-- You should have received a copy of the GNU General Public License along with -->
<!-- mbackup-for-windows. If not, see <http://www.gnu.org/licenses/>. -->
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
\ No newline at end of file
This diff is collapsed.