Skip to content
Commits on Source (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 <root@emacsos.com>
//
// 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 <root@emacsos.com>
#
# 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 <root@emacsos.com>
//
// 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 <root@emacsos.com>
//
// 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
target=user@somehost.example.com:/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 <sylecn@gmail.com>
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 <root@emacsos.com> -->
<!-- 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 <root@emacsos.com> -->
<!-- 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 <root@emacsos.com>
//
// 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 <root@emacsos.com>
//
// 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 <root@emacsos.com>
//
// 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 <root@emacsos.com> -->
<!-- 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
* COMMENT -*- mode: org -*-
#+Date: 2019-11-12
Time-stamp: <2019-11-16>
Time-stamp: <2019-11-18>
#+STARTUP: content
* notes :entry:
** 2019-11-12 mbackup for windows :featurereq:
- features
- DONE windows installer.
bundles mingw rsync and ssh.
they are NOT installed to PATH. so it will not affect other ssh programs.
- DONE backup file list;
user file list;
default exclude file list;
user exclude file list;
etc
They have different value compared to mbackup for linux.
- DONE script designed to run via windows scheduled task.
no service installed. no auto starts.
taskschd.msc
** 2019-11-13 how to run it in dev env?
dotnet run -- --dry-run --itemize-changes --target d:\backup
dotnet run -- -n -i --target d:\backup
......@@ -226,14 +242,43 @@ vscode should at least always indent using space for F#.
* current :entry:
**
** 2019-11-16 how to sign my msi executable?
so it doesn't show publisher unknown.
** 2019-11-18 add dockerfile to create rsync mingw64 distribution,
then update Makefile and wix xml files to use that.
** 2019-11-18 TODO can I target .net fw instead of .net core?
this way windows 10 users should not require install any dependencies.
Does develop for .net fw require installing visual studio IDE?
Are there any code change required?
** 2019-11-18 add log rotate for %localappdata%\mbackup\mbackup.log
* done :entry:
** 2019-11-18 apply gpl.
rsync is gplv3. I will apply gplv3.
** 2019-11-12 make code work in a specific dir. then create an installer.
- bundle dotnet core 3 with installer.
- WONTFIX bundle dotnet core 3 with installer.
https://dotnet.microsoft.com/download/dotnet-core/3.0
Run apps - Runtime
.NET Core Desktop Installer: x64
The .NET Core Desktop Runtime is dependent on the .NET Core Runtime. Make
sure that .NET Core Runtime 3.0.0 is also installed.
That's 50MiB dependency.
- problems
- TODO will windows 10 apply security fixes for dotnet core 3 in windows
updates? this will decide whether bundle it is a good idea.
- in wix config, can I require dotnet core 3 and alert user to install it
first? open the dotnet core 3 download url.
search: wix require dotnet core 3
-
- DONE install binary files to %programfiles%
- DONE install mbackup config files to %programdata%
- install scheduled tasks as admin
- DONE install scheduled tasks as admin. task will run as normal user.
SCHTASKS /Create /?
# run mbackup 15m after user logon.
......@@ -353,7 +398,25 @@ so it doesn't show publisher unknown.
how would home dir expand in SYSTEM user?
I'd like task to run as currently logon user. for ONLOGON.
- TODO why start menu shortcuts doesn't appear in win 10 guest?
search: can schtasks always run task as current user
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks
/it param
Specifies to run the task only when the "run as" user (the user account
under which the task runs) is logged on to the computer. This parameter
has no effect on tasks that run with system permissions.
where is win 10 doc?
https://docs.microsoft.com/en-us/windows/win32/taskschd/schtasks
// currently I use /NP to not show console window when mbackup.exe runs.
// maybe I should find another way to not show console window.
// don't write anything to console when run in schtasks.
// --cron option. disable logging. I think cmd.exe will still appear for
// console app.
- TODO start menu txt file shortcuts doesn't appear in win 10 guest.
start menu folder is created. but only one exe there.
txt file shortcuts are not added.
......@@ -372,6 +435,40 @@ so it doesn't show publisher unknown.
I can make use of /RI, run mbackup every 30min.
TODO what happen if last run have not finished yet?
does /RI interval count from last exit?
- DONE mbackup start menu dir is not deleted when mbackup is uninstalled.
// it is auto deleted now. tested 0.4.6.0 on B75I3.
I want to install as per machine, not per user.
changed reg root key to HKLM.
c# - How can I create a shortcut on the Users Desktop folder - Stack Overflow
https://stackoverflow.com/questions/29255922/how-can-i-create-a-shortcut-on-the-users-desktop-folder/29498210#29498210
installer - How to create desktop shortcut for all users in WIX - Stack Overflow
https://stackoverflow.com/questions/2211218/how-to-create-desktop-shortcut-for-all-users-in-wix
per machine requires set ALLUSERS=1.
how to set it?
add inside <Product>
<Property Id="ALLUSERS">1</Property>
that result in error.
Setting the 'AllUsers' option on Wix installer does not work - Stack Overflow
https://stackoverflow.com/questions/17878460/setting-the-allusers-option-on-wix-installer-does-not-work
set InstallScope="perMachine" should set ALLUSERS key.
search: wix can't use HKLM InstallScope="perMachine"
- info: install for all users is trouble some in wix.
it's not clear how to install shortcuts.
when install as per User. current user can edit mbackup-config.txt file.
when install as per machine, only admin can edit that file.
maybe just install per User.
when install scheduled task, run as current user.
task name should also include current user name.
-
** 2019-11-12 how to test it? test it in a win 10 VM?
......@@ -394,30 +491,171 @@ so it doesn't show publisher unknown.
- there is no enough RAM on B75I3. I will stop bogon VM and run win 10 VM.
-
** 2019-11-12 mbackup for windows :featurereq:
- features
- windows installer.
bundles mingw rsync and ssh.
they are NOT installed to PATH. so it will not affect other ssh programs.
- backup file list;
user file list;
default exclude file list;
user exclude file list;
etc
They have different value compared to mbackup for linux.
- script designed to run via windows scheduled task.
no service installed. no auto starts.
** 2019-11-16 how to sign my msi executable?
so it doesn't show publisher unknown.
taskschd.msc
- Sign Setup.exe and MySetup.msi - Win32 apps | Microsoft Docs
https://docs.microsoft.com/en-us/windows/win32/msi/sign-setup-exe-and-mysetup-msi
SignTool - Win32 apps | Microsoft Docs
https://docs.microsoft.com/en-us/windows/win32/seccrypto/signtool?redirectedfrom=MSDN
SignTool.exe is in Windows SDK.
Signing Page, Project Designer - Visual Studio 2015 | Microsoft Docs
https://docs.microsoft.com/en-us/visualstudio/ide/reference/signing-page-project-designer?view=vs-2015&redirectedfrom=MSDN
- search: can I use let's encrypt to sign my msi
https://community.letsencrypt.org/t/do-you-support-code-signing/370/6
nope.
- Deconstructing Code Signing: how to get the certificate, sign a code and verify signatures? | CQURE Academy
https://cqureacademy.com/blog/windows-internals/code-signing
Code Signing Certificates - Validate Software Code - CodeSigningStore
https://codesigningstore.com/code-signing
code signing cert: 74-300USD/year
I will not sign my msi for now.
a sha256sum is more than enough.
** 2019-11-17 schtasks run-as user problem
- try implement this:
when run as system user, expand user-default-list.txt for all non-system,
non-service users. (all users that can login with password.)
when run as normal user, expand user-default-list.txt for current user.
// not supported on windows.
- try implement this:
schtasks always run as current user.
but don't show cmd.exe window when it runs.
Could use a GUI wrapper that show in systray or have no visiable Windows
Form at all.
installer should not add /RU SYSTEM in this case.
mbackupw.exe
- DONE integrate mbackupw.exe.
- DONE call mbackupw.exe from schtasks.
- DONE include mbackupw.exe in msi file.
- DONE create mbackupw.exe in Makefile when making a release.
- test it.
install okay.
schtasks okay.
check whether mbackupw.exe can exit by itself.
yes. it can.
- implementation.
- there is rsync running on B75I3.
- problems
- I use robocopy to copy mbackupw publish files to mbackup publish dir.
but the exit is 2, why?
Getting ROBOCOPY to return a "proper" exit code? - Super User
https://superuser.com/questions/280425/getting-robocopy-to-return-a-proper-exit-code
I will use cp instead of robocopy in this case.
- problems
- can I iter over all users on a system? yes.
can I get their special folders as SYSTEM user? no.
search: dotnet iter over all users on localhost
.net - Get windows users with C# - Stack Overflow
https://stackoverflow.com/questions/6033391/get-windows-users-with-c-sharp
c# - Get list of local computer usernames in Windows - Stack Overflow
https://stackoverflow.com/questions/5247798/get-list-of-local-computer-usernames-in-windows
search: dotnet expand user's special folders
search: Environment.GetFolderPath for other user
c# - Get special folder for different user without credentials - Stack Overflow
https://stackoverflow.com/questions/37630726/get-special-folder-for-different-user-without-credentials
You could create a folder in ProgramData at install time, and then each
time your application starts up it could write a file for the current user
containing the path(s) to the directories and/or files in question.
exported tasksched.msc config as xml.
that XML is not portable.
it contains hostname.
// In mbackup, I can skip generate mbackup-list.txt file if run as system
user. And write mbackup-list.txt to both %localappdata%/mbackup/ and
%programdata%/mbackup/run/ dir.
This answer confirms it's not supported to get special folder for all
users. There is no /etc/passwd like service in Windows.
- is schtasks a per user thing?
can schtasks always run as current login user?
- run as BUILTIN\Users works. but it will show cmd.exe window.
I can use a GUI app to hide the window.
when run as BUILTIN\Users, with /NP, the cmd.exe window still shows.
search: schtasks console application hide cmd.exe window
- create a GUI app for running mbackup.exe
call it mbackupw.exe
create a subproject.
mkdir mbackupw
cd mbackupw
dotnet new winforms
- problems
- dotnet new winforms -lang=F#
fail.
winforms only support c#
wpf is also c# only.
now I can't access F# modules directly.
I may need to create wrappers for C#.
- if I launch mbackup.exe process in mbackupw.exe, will it show cmd.exe
window? yes. it show a cmd.exe window.
ProcessStartInfo startInfo = new ProcessStartInfo {
FileName = mbackupExe,
Arguments = "",
CreateNoWindow = true
};
now window is not shown when start mbackup.exe.
but mbackupw.exe doesn't exit when mbackup.exe finishes.
Application.Exit();
doesn't work as expected?
c# - Application won't exit before Diagnostics.Process.Start() finishes - Stack Overflow
https://stackoverflow.com/questions/26762745/application-wont-exit-before-diagnostics-process-start-finishes
add this:
Environment.Exit(Environment.ExitCode);
now it works.
- winforms can't hide Form? it can.
c# - How to hide WinForm after it run? - Stack Overflow
https://stackoverflow.com/questions/14455084/how-to-hide-winform-after-it-run
Opacity = 0
ShowInTaskbar = false
when app starts it will get focus.
how to not get focus when winform app starts?
c# - Two issues with WS_EX_NOACTIVATE and WinForms - Stack Overflow
https://stackoverflow.com/questions/28873729/two-issues-with-ws-ex-noactivate-and-winforms
c# - Show a Form without stealing focus? - Stack Overflow
https://stackoverflow.com/questions/156046/show-a-form-without-stealing-focus
Add in Form class
protected override bool ShowWithoutActivation
{
get { return true; }
}
this works.
-
* done :entry:
** 2019-11-16 local-exclude.txt should convert win path to mingw path.
foo/bar
C:\foo\bar
......