Skip to content
Commits on Source (3)
  • Yuanle Song's avatar
    WIP build msi using wix. · d2bd4ec4
    Yuanle Song authored
    - introduced wix, make
    - rsync-mingw64.msi works
    - I decide to include rsync inside mbackup.msi, and install it in
      the same app dir. So this working rsync-mingw64.msi config will
      be removed in next commit.
    d2bd4ec4
  • Yuanle Song's avatar
    mbackup.msi works on dev node. · a00a1c3c
    Yuanle Song authored
    - renmaed mbackup-for-windows.fsproj to mbackup.fsproj
      this file name is the project name. now exe is named mbackup.exe
    - use framework dependent release.
    - include rsync-mingw in one msi
    - use installed rsync and ssh path in Program.fs
    a00a1c3c
  • Yuanle Song's avatar
    bugfix: create runtime dir before generating · 0ada5c66
    Yuanle Song authored
    mbackup.list file; create dir should use windows format dir string.
    0ada5c66
obj/
bin/
.ionide/
*.wixobj
*.wixpdb
*.msi
*-files.wxs
WIX_DIR := C:\Program Files (x86)\WiX Toolset v3.11\bin
HEAT := "$(WIX_DIR)\heat.exe"
CANDLE := "$(WIX_DIR)\candle.exe" -arch x64 -nologo
LIGHT := "$(WIX_DIR)\light.exe" -nologo
RSYNC_MINGW_DIR := D:\downloads\apps\rsync-w64
MBACKUP_PUBLISH_DIR := bin\Release\netcoreapp3.0\publish
default: build
help:
@cmd /C echo 'Usage: make [build|test|release|clean|dist|all]'
all: test release dist
dist: mbackup.msi
release:
dotnet publish --nologo -c Release --self-contained false
test:
dotnet test --nologo mbackup-tests
check: test
build:
dotnet build --nologo
clean:
dotnet clean --nologo
cmd /C 'del *.wixobj *.wixpdb *.msi rsync-mingw64-files.wxs'
%.wixobj: %.wxs
$(CANDLE) $<
rsync-mingw64-files.wxs:
$(HEAT) dir $(RSYNC_MINGW_DIR) -cg RsyncHeatGenerated -dr MBACKUP_PROGRAM_FILES -var var.RsyncSourceDir -gg -nologo -out $@ -sw5150
rsync-mingw64-files.wixobj: rsync-mingw64-files.wxs
$(CANDLE) -dRsyncSourceDir=$(RSYNC_MINGW_DIR) $<
mbackup-files.wxs: release
$(HEAT) dir $(MBACKUP_PUBLISH_DIR) -cg MbackupHeatGenerated -dr MBACKUP_PROGRAM_FILES -var var.MbackupPublishDir -gg -nologo -out $@ -sw5150
mbackup-files.wixobj: mbackup-files.wxs
$(CANDLE) -dMbackupPublishDir=$(MBACKUP_PUBLISH_DIR) $<
mbackup.msi: mbackup.wixobj rsync-mingw64-files.wixobj mbackup-files.wixobj
$(LIGHT) $^ -o $@
.PHONY: default help all dist release test check build clean rsync-mingw64-files.wxs mbackup-files.wxs
......@@ -44,6 +44,11 @@ with
| Node_Name _ -> "local node's name, used in remote logging"
| Ssh_Key _ -> "ssh private key, used when backup to remote ssh node"
let programFilesDirWin = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) |> ensureWinDir
let programFilesDir = toMingwPath programFilesDirWin
let mbackupProgramDirWin = programFilesDirWin + "mbackup\\"
let mbackupProgramDir = toMingwPath mbackupProgramDirWin
let appDataRoamingDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) |> toMingwPath |> ensureDir
let programDataDirWin = getEnv "PROGRAMDATA" |> ensureWinDir
let programDataDir = toMingwPath programDataDirWin
......@@ -115,7 +120,7 @@ let generateMbackupList (logger: Logger) =
let lines = readMbackupListFile mbackupLocalList |> Seq.map toMingwPath
(true, lines)
with
| :? System.IO.FileNotFoundException ->
| :? FileNotFoundException ->
(true, Seq.empty)
| ex ->
logger.Error "Read mbackupLocalList failed: %s" ex.Message
......@@ -128,6 +133,7 @@ let generateMbackupList (logger: Logger) =
// For mbackup-default.list and local.list, exclude empty lines and comment lines.
// skip and give a warning on non-absolute path.
// For user-default.list, auto prefix user's home dir, auto expand Documents, Downloads etc special folder.
Directory.CreateDirectory(runtimeDirWin) |> ignore
File.WriteAllLines(mbackupList, allLines)
logger.Info "mbackup.list file written: %s" mbackupList
true
......@@ -151,6 +157,7 @@ let main argv =
logger.Info "user config dir: %s" userConfigDirWin
logger.Info "runtime dir: %s" runtimeDirWin
logger.Debug "program dir: %s" mbackupProgramDirWin
let rsyncCmd: string list = []
let rsyncCmd = appendWhen dryRun rsyncCmd "--dry-run"
......@@ -170,13 +177,10 @@ let main argv =
let localLogFile = runtimeDir + "mbackup.log"
let rsyncCmd = List.append rsyncCmd [sprintf "--log-file=%s" localLogFile]
// TODO remove usage of test dir.
let mbackupInstallDirWinTest = "D:\\downloads\\apps\\mbackupTest\\"
let mbackupInstallDirTest = mbackupInstallDirWinTest |> toMingwPath |> ensureDir
let sshExeFile = mbackupInstallDirTest + "rsync-w64/usr/bin/ssh.exe"
let sshExeFile = mbackupProgramDir + "rsync-w64/usr/bin/ssh.exe"
let sshConfigFile = userHome + ".ssh/config"
let sshPrivateKeyFile = results.GetResult(Ssh_Key, defaultValue = userHome + ".ssh/id_rsa") |> toMingwPath
let rsyncCmd = List.append rsyncCmd [sprintf "-e \"%s -F %s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFile sshPrivateKeyFile]
let rsyncCmd = List.append rsyncCmd [sprintf "-e \"'%s' -F %s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFile sshPrivateKeyFile]
// precedence: command line argument > environment variable > config file
let normalizeTarget target =
......@@ -211,13 +215,12 @@ let main argv =
let rsyncCmd = List.append rsyncCmd ["/"]
let rsyncCmd = List.append rsyncCmd [backupTarget]
let rsyncArgs = rsyncCmd |> String.concat " "
let rsyncExe = mbackupInstallDirWinTest + "rsync-w64\\usr\\bin\\rsync.exe"
let echoExe = "C:\\Program Files\\Git\\usr\\bin\\echo.exe"
let rsyncExe = mbackupProgramDirWin + "rsync-w64\\usr\\bin\\rsync.exe"
try
IO.Directory.CreateDirectory(runtimeDir) |> ignore
IO.Directory.CreateDirectory(userConfigDir) |> ignore
let proc = Process.Start(rsyncExe, rsyncArgs)
Directory.CreateDirectory(runtimeDirWin) |> ignore
Directory.CreateDirectory(userConfigDirWin) |> ignore
logger.Info "Note: if you run the following rsync command yourself, make sure the generated file list (%s) is up-to-date.\n%s" mbackupFile (rsyncExe + " " + rsyncArgs)
let proc = Process.Start(rsyncExe, rsyncArgs)
if proc.WaitForExit Int32.MaxValue then
logger.Info "mbackup exit"
proc.ExitCode
......@@ -225,7 +228,7 @@ let main argv =
logger.Error "mbackup timed out while waiting for rsync to complete"
ExitTimeout
with
| :? System.IO.IOException as ex ->
| :? IOException as ex ->
logger.Error "IO Error: %s %s" ex.Source ex.Message
ExitIOError
| ex ->
......
......@@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\mbackup-for-windows.fsproj" />
<ProjectReference Include="..\mbackup.fsproj" />
</ItemGroup>
</Project>
......@@ -3,7 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<RootNamespace>Mbackup</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
......
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="3030B91E-5E3E-4151-9A69-B53B72690430" Version="0.1.0.0" Language="1033" Name="mbackup" Manufacturer="Yuanle Song">
<Package InstallerVersion="300" Compressed="yes"/>
<Media Id="1" Cabinet="mbackup.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="MBACKUP_PROGRAM_FILES" Name="mbackup" />
</Directory>
<Directory Id="CommonAppDataFolder">
<Directory Id="MBACKUP_DATA" Name="mbackup"/>
</Directory>
</Directory>
<DirectoryRef Id="MBACKUP_DATA">
<Component Id="mbackup_default.exclude" Guid="*">
<File Id="mbackup_default.exclude" Source="mbackup-config\mbackup-default.exclude" KeyPath="yes"/>
</Component>
<Component Id="mbackup_default.list" Guid="*">
<File Id="mbackup_default.list" Source="mbackup-config\mbackup-default.list" KeyPath="yes"/>
</Component>
<Component Id="user_default.list" Guid="*">
<File Id="user_default.list" Source="mbackup-config\user-default.list" KeyPath="yes"/>
</Component>
<Component Id="mbackup.txt" NeverOverwrite="yes" Permanent="yes" Guid="*">
<!-- do not overwrite this component/file if it already exists on target system -->
<File Id="mbackup.txt" Source="mbackup-config\mbackup.txt" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentGroupRef Id="MbackupHeatGenerated" />
<ComponentGroupRef Id="RsyncHeatGenerated" />
<ComponentRef Id="mbackup_default.exclude" />
<ComponentRef Id="mbackup_default.list" />
<ComponentRef Id="user_default.list" />
<ComponentRef Id="mbackup.txt" />
</Feature>
</Product>
</Wix>
......@@ -64,6 +64,10 @@ dotnet run -- -i
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netframework-4.8
Standard Date and Time Format Strings | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings?view=netframework-4.8
The Option type | F# for fun and profit
https://fsharpforfunandprofit.com/posts/the-option-type/
Pattern Matching - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/pattern-matching
- FSharpLint
http://fsprojects.github.io/FSharpLint/
http://fsprojects.github.io/FSharpLint/index.html
......@@ -81,10 +85,21 @@ dotnet run -- -i
** 2019-11-13 install dir layout.
C:\Program Files\mbackup\rsync-w64\usr\bin\rsync.exe
C:\Program Files\mbackup\rsync-w64\usr\bin\ssh.exe
C:\Program Files\mbackup\publish\mbackup.exe
C:\Program Files\mbackup\publish\mbackup.dll
C:\ProgramData\mbackup\mbackup-default.exclude
C:\ProgramData\mbackup\mbackup-default.list
C:\ProgramData\mbackup\user-default.list
C:\ProgramData\mbackup\mbackup.ini
C:\ProgramData\mbackup\mbackup.txt
- optional user configs
like /etc/mbackup/ in linux
C:\ProgramData\mbackup\local.list
C:\ProgramData\mbackup\local.exclude
like ~/.mbackup/ in linux
<My Documents>/mbackup/local.list
<My Documents>/mbackup/local.exclude
** 2019-11-14 notes :development:
- Argu optional param support.
......@@ -94,6 +109,18 @@ C:\ProgramData\mbackup\mbackup.ini
results.TryGetResult Target
or
results.GetResult(Target, defaultValue = xxx)
- WiX wxs file
<Package InstallerVersion="300" Compressed="yes" Platform="x64"/>
Platform="x64" has the same meaning as candle -arch x64.
- Wix for creating installer for 64bit app, you need to add in <Component> attribute
Win64="yes"
use candle -arch x64 can add Win64="yes" automatically if there is no Win64 attribute specified in Component.
wix3.6 - WiX Heat tool, create Component with Win64 attribute - Stack Overflow
https://stackoverflow.com/questions/11981498/wix-heat-tool-create-component-with-win64-attribute
- Wix to install file in another name, add Name attribute in <File>.
<File Id="mbackup.exe" Name="mbackup.exe" Source="bin\Release\netcoreapp3.0\win10-x64\mbackup-for-windows.exe" KeyPath="yes" Checksum="yes"/>
-
* later :entry:
......@@ -103,105 +130,207 @@ it can only support open a namespace.
using the vscode Ionide-fsharp extension.
* current :entry:
**
** 2019-11-13 next todos
- DONE fix TODOs in F# code
- DONE add rsync command and arguments for running in windows.
i.e. -e etc.
** TODO 2019-11-15 additionally support <My Documents>/mbackup/local.list file.
This file is easier to open and backup.
no. programdata should be good enough.
but this is per user extra config file.
each user could have their own local file to backup.
one user don't want to manage all other user's local backup list.
yes. I should support this.
Both local.list and local.exclude.
** 2019-11-14 learn how to create an msi installer.
- WiX Toolset
https://wixtoolset.org/
c# - How to create MSI installer for ASP.NET Core application using Wix Toolset - Stack Overflow
https://stackoverflow.com/questions/46878752/how-to-create-msi-installer-for-asp-net-core-application-using-wix-toolset
Windows Installer XML (WiX)
https://wixtoolset.org/documentation/manual/v3/main/
- Introducing dotGet: an installer for .NET Core CLI apps
https://medium.com/@tonerdo/introducing-dotget-an-installer-for-net-core-cli-apps-9ba79ac7cd89
requires nuget. then it can install your dotnet core console project.
this is not what I need here.
- Packaging a self-contained .NET Core app for Windows Installer
https://nblumhardt.com/2017/04/netcore-msi/
This is the first time I’ve tried packaging a .NET Core app for the Windows
Installer, so I thought I’d write these brief notes to help anyone else
interested in taking the same path.
- should I include rsync-mingw64 in the same msi file?
distributing it alone is not very useful, since people can just use msys2 or cygwin.
If I include it in the same msi, I don't need to use wix bundle, and I can install rsync to the same dir as mbackup.
it seems cleaner this way. Just like a VPN client bundle openvpn or a python program bundle python.
yes. include it in the same msi and install in a sub dir.
- try Wix.
- install wix.
requires .net 3.5 windows feature.
- Building Installation Package Bundles
https://wixtoolset.org/documentation/manual/v3/bundle/
- How To Guides
https://wixtoolset.org/documentation/manual/v3/howtos/
- How To: Add a File to Your Installer
https://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/add_a_file.html
- create mbackup.wxs
build mbackup binaries
dotnet publish -c Release
- TODO how to show a message when installer is finished succesfully?
currently it installs very fast and just exit without any user notification.
maybe show a installer window and let user click Next and Finish.
- TODO how to add some dir to PATH?
I only have one exe. Maybe just create a start menu or desktop shortcut?
create desktop shortcut to mbackup.exe
- TODO how to support upgrade when I click a new msi?
currently every msi is a standalone msi and will always install fresh.
is the UpgradeCode used for this?
- mbackup.msi works on B75I3 host.
- try mbackup.msi on win 10 VM.
how to require dotnet core 3.0 in .wxs file?
<Arguments>--stats -togr --chown=sylecn:sylecn --exclude-from=/cygdrive/d/sylecn_docs/texts/configs/rsync-exclude
--files-from=/cygdrive/d/sylecn_docs/texts/configs/rsync-file-list
--log-file=/cygdrive/d/sylecn_docs/rsync-b75i3.log
-e ".\ssh.exe -F c:/users/sylecn/.ssh/config -i c:/Users/sylecn/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
/ sheni:/data/backup/server-backup/b75i3/</Arguments>
- problems
- each file require it's own <Component> tag.
rsync mingw have many files. I seems I need to generate an installer for
rsync for windows.
- search: wix only install file if it does not exist
windows installer - Copy if not exist in WiX - Stack Overflow
https://stackoverflow.com/questions/1912037/copy-if-not-exist-in-wix
installer - What is the wix 'KeyPath' attribute? - Stack Overflow
https://stackoverflow.com/questions/2003043/what-is-the-wix-keypath-attribute/2003366#2003366
Component Table - Win32 apps | Microsoft Docs
https://docs.microsoft.com/en-us/windows/win32/msi/component-table?redirectedfrom=MSDN
How To: Check for .NET Framework Versions
https://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/check_for_dotnet.html
- WONTFIX how to unpack zip file to target dir?
I don't want to create a Component for every file there.
windows installer - Wix custom action to unzip a file - Stack Overflow
https://stackoverflow.com/questions/47691477/wix-custom-action-to-unzip-a-file
the suggestion is to include the files in msi.
or unzip the files at app runtime.
I will try create a msi file for mingw64 rsync.
then use wix bundle to install it as dependency.
- search: wix install all files in a folder
- Include all Files in Bin folder in Wix installer - Stack Overflow
https://stackoverflow.com/questions/36756311/include-all-files-in-bin-folder-in-wix-installer
create rsync-mingw64-files.wxs
&"C:\Program Files (x86)\WiX Toolset v3.11\bin\heat.exe" dir "D:\downloads\apps\rsync-w64" -cg RsyncHeatGenerated -dr ProgramFiles64Folder -var var.RsyncSourceDir -gg -nologo -out rsync-mingw64-files.wxs -sw5150
compile and build rsync-mingw64.msi
&"C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe" -dRsyncSourceDir=D:\downloads\apps\rsync-w64\ .\rsync-mingw64.wxs .\rsync-mingw64-files.wxs
&"C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe" .\rsync-mingw64.wixobj .\rsync-mingw64-files.wixobj -o rsync-mingw64.msi
build is getting complex. I need make and Makefile.
- problems
- how to pass in preprocessor variable?
WiX undefined preprocessor variable - Stack Overflow
https://stackoverflow.com/questions/2063630/wix-undefined-preprocessor-variable
To pass values for preprocessor variables like $(var.MyProject.TargetDir), use options like -dMyProject.TargetDir=c:\foo.
- why rsync-mingw64 is installed to C:\Program Files (x86)\rsync-w64? I expect C:\Program Files\rsync-w64\
wix-users - 64 Bit program files folder
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/64-Bit-program-files-folder-td5948080.html
- INVALID make pattern rule doesn't work in windows
it works. it is because my source file is missing.
- why mbackup.exe is 32 bit component?
try this:
dotnet publish -c Release -r win10-x64
still same error.
D:\sylecn_docs\projects\mbackup-for-windows\mbackup.wxs(16) : error LGHT0204 : ICE80: This 32BitComponent mbackup.exe uses 64BitDirectory APPLICATIONROOTDIRECTORY
search: dotnet core how to build x64 exe file
dotnet is building x64 exe file. it's WIX issue.
need to add Win64="yes" in <Component> attribute.
- DONE how to run wix to create msi file?
two command line tool
light
candle
it's not added in PATH.
C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe
C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe
There is offline doc.
C:\Program Files (x86)\WiX Toolset v3.11\doc\WiX.chm
C:\Program Files (x86)\WiX Toolset v3.11\doc\msi.chm
do read the WiX Tutorial.
https://www.firegiant.com/wix/tutorial/
https://www.firegiant.com/wix/tutorial/getting-started/
&"C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe" .\mbackup.wxs
&"C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe" .\mbackup.wixobj
it works.
mbackup.msi file is created.
- the mbackup.exe can't run without all those dlls.
dotnet publish -c Release -r win10-x64 --nologo
maybe I should build a exe that requires dotnet core 3 to run.
I don't want to create a big msi.
try this:
dotnet publish -c Release --nologo
and update wix xml files.
need to add all files in bin\Release\netcoreapp3.0\publish\ dir.
use heat to create another wxs file.
- heat can't add some dll.
"C:\Program Files (x86)\WiX Toolset v3.11\bin\heat.exe" dir bin\Release\netcoreapp3.0\publish -cg MbackupHeatGenerated -dr MBACKUP_PROGRAM_FILES -var var.MbackupPublishDir -gg -nologo -out mbackup-files.wxs -sw5150
heat.exe : warning HEAT5151 : Could not harvest data from a file that was expected to be an assembly: D:\sylecn_docs\projects\mbackup-for-windows\bin\Release\netcoreapp3.0\publish\Argu.dll. If this file is not an assembly you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: 未能加载文件或程序集“FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。系统找不到
指定的文件。
heat.exe : warning HEAT5151 : Could not harvest data from a file that was expected to be an assembly: D:\sylecn_docs\projects\mbackup-for-windows\bin\Release\netcoreapp3.0\publish\mbackup.dll. If this file is not an assembly
you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: 未能加载文件或程序集“System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。系统
找不到指定的文件。
.net - Wix Toolkit: Heat balking about DLL's - Stack Overflow
https://stackoverflow.com/questions/43992433/wix-toolkit-heat-balking-about-dlls
com - Cannot register DLL using WiX - Stack Overflow
https://stackoverflow.com/questions/12463256/cannot-register-dll-using-wix
- TODO dup file?
<Component Id="cmp981FC09307D7CB82695815FAAFCC646D" Directory="dir02A4AE56AE905AEEE7E2D4F4410A9748" Guid="{DB94490C-32CA-4B14-A96D-A95D4B557D01}">
<File Id="fil432C46247A06CCDB891611045DD37081" KeyPath="yes" Source="$(var.MbackupPublishDir)\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" />
<Component Id="cmp5190411B4FE56A0E0CE782BE6C1B537E" Directory="dir1B0C588BD61288F160D459591DA01603" Guid="{F0613E24-B22B-4A58-A054-380BDF2B857C}">
<File Id="filE0C94795A0B5F482BD659FBB774641C7" KeyPath="yes" Source="$(var.MbackupPublishDir)\System.Security.Cryptography.ProtectedData.dll" />
why there are duplicated dll in publish dir? check publish doc.
this is the only duplicated file. I will ignore it for now.
- DONE ssh.exe path escape issue.
&"C:\Program Files\mbackup\rsync-w64\usr\bin\rsync.exe" -h --stats -togr --delete --delete-excluded --ignore-missing-args --files-from=/cygdrive/c/Users/sylecn/AppData/Local/mbackup/mbackup.list --exclude-from=/cygdrive/c/ProgramData/mbackup/mbackup-default.exclude --log-file=/cygdrive/c/Users/sylecn/AppData/Local/mbackup/mbackup.log -e "/cygdrive/c/Program Files/mbackup/rsync-w64/usr/bin/ssh.exe -F /cygdrive/c/Users/sylecn/.ssh/config -i /cygdrive/c/Users/sylecn/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --remote-option=--log-file=/var/log/mbackup/B75I3.log --chown=sylecn:sylecn / root@sylecn01.emacsos.com:/data/backup/PC-backup/B75I3/
rsync: Failed to exec /cygdrive/c/Program: No such file or directory (2)
&"C:\Program Files\mbackup\rsync-w64\usr\bin\rsync.exe" -h --stats -togr --delete --delete-excluded --ignore-missing-args --files-from=/cygdrive/c/Users/sylecn/AppData/Local/mbackup/mbackup.list --exclude-from=/cygdrive/c/ProgramData/mbackup/mbackup-default.exclude --log-file=/cygdrive/c/Users/sylecn/AppData/Local/mbackup/mbackup.log -e "'/cygdrive/c/Program Files/mbackup/rsync-w64/usr/bin/ssh.exe' -F /cygdrive/c/Users/sylecn/.ssh/config -i /cygdrive/c/Users/sylecn/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --remote-option=--log-file=/var/log/mbackup/B75I3.log --chown=sylecn:sylecn / root@sylecn01.emacsos.com:/data/backup/PC-backup/B75I3/
- DONE test param parsing is working.
command line param > env var > mbackup default value.
support --node-name param.
- test run in console and scheduled task.
run in console works.
try run in scheduled task.
** 2019-11-12 make code work in a specific dir. then create an installer.
- bundle dotnet core 3 with installer.
- install binary files to %programfiles%
- install mbackup config files to %programdata%
- install scheduled tasks as admin
SCHTASKS /Create /?
# run mbackup 15m after user logon.
SCHTASKS /Create /U <username> /SC ONLOGON /TN mbackup-logon /TR "\"<path\to\mbackup.exe>\" \"args\"" /DELAY 15:00
SCHTASKS /Create /NP /SC ONLOGON /TN mbackup-logon /TR "\"<path\to\mbackup.exe>\" \"args\"" /DELAY 15:00
# run mbackup at 10am and 4pm.
SCHTASKS /Create /U <username> /SC DAILY /TN mbackup-morning /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 10:00 /ET 13:00 /K
SCHTASKS /Create /U <username> /SC DAILY /TN mbackup-afternoon /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 16:00 /ET 19:00 /K
SCHTASKS /Create /NP /SC DAILY /TN mbackup-morning /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 10:00 /ET 13:00 /K
SCHTASKS /Create /NP /SC DAILY /TN mbackup-afternoon /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 16:00 /ET 19:00 /K
# debug purpose, one time only
SCHTASKS /Create /U <username> /SC ONCE /TN mbackup-afternoon /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 12:03
- problems
- how many scheduled task to run on a multi-user PC?
each user have its own user-default.list expansion.
should I iter over all users on PC?
I think only current user can get it's profile dir and special dirs.
- maybe config mbackup to run after user logon. with 15minute delay.
always run as current user.
- how to not require any param when running mbackup.exe?
put TARGET and other option in a config file?
define system level TARGET env variable.
SCHTASKS /Create /NP /SC ONCE /TN mbackup-test /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 19:18
use config file is easier for user to edit and making the change effective.
userConfigDir / mbackup.conf
In admin powershell,
SCHTASKS /Create /NP /SC ONCE /TN mbackup-test /TR $mbackupexe /ST 19:32
/NP option requires admin privilledge.
it works.
search: F# read config file
FSharp.Configuration
http://fsprojects.github.io/FSharp.Configuration/
- FSharp.Configuration missing reference to System.Runtime.Caching
search: how to reference System.Runtime.Caching for dotnet core project
https://www.nuget.org/packages/System.Runtime.Caching/
dotnet add package System.Runtime.Caching --version 4.6.0
should I add 4.0.0? Can I use a higher version?
to delete it,
schtasks /delete /tn mbackup-test
still not compatible.
search: use FSharp.Configuration with dotnet core 3
- give up on FSharp.Configuration.
- try this:
FsConfig
https://www.demystifyfp.com/FsConfig/
AppSettings is only supported in V0.0.6 or below.
try F# AppSettings directly.
If nothing is easy to use, write my own parser.
Support similar config format as python wells lib.
- ConfigurationManager.AppSettings Property (System.Configuration) | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager.appsettings?view=netframework-4.8
where should I save the App.config xml file?
search: what is app.config
App.Config: Basics and Best Practices - SubMain Blog
https://blog.submain.com/app-config-basics-best-practices/
What is App.config in C#.NET? How to use it? - Stack Overflow
https://stackoverflow.com/questions/13043530/what-is-app-config-in-c-net-how-to-use-it
Okay. This is not what I want.
This is for application configuration (rarely change), not for user configuration (can change any time).
dotnet will create <yourapp>.exe.config from your App.config file.
- how to use multiple files in F# dotnet core project?
search: f# module and namespace
search: f# module
Modules - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/modules
- create an installer. The installer should add scheduled task on install and
delete scheduled task on removal.
- problems
- how to write unit test in F#?
Unit testing F# in .NET Core with dotnet test and NUnit - .NET Core | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-nunit
mkdir mbackup-tests
cd mbackup-tests
dotnet new nunit -lang F#
//wait.
dotnet test
dotnet add reference ../mbackup-for-windows.fsproj
dotnet build # this will build both ref project and test project.
dotnet test
- how to support short option names?
--dry-run -n
-
** 2019-11-12 make code work in a specific dir. then create an installer.
- install to %programfiles%
- config is installed/saved to %appdata% roaming dir.
- problems
- config should be system wide. %appdata% is per-user dir.
......@@ -307,6 +436,126 @@ using the vscode Ionide-fsharp extension.
it contains hostname.
-
* done :entry:
** 2019-11-13 next todos; scheduled task command line.
- DONE fix TODOs in F# code
- DONE add rsync command and arguments for running in windows.
i.e. -e etc.
<Arguments>--stats -togr --chown=sylecn:sylecn --exclude-from=/cygdrive/d/sylecn_docs/texts/configs/rsync-exclude
--files-from=/cygdrive/d/sylecn_docs/texts/configs/rsync-file-list
--log-file=/cygdrive/d/sylecn_docs/rsync-b75i3.log
-e ".\ssh.exe -F c:/users/sylecn/.ssh/config -i c:/Users/sylecn/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
/ sheni:/data/backup/server-backup/b75i3/</Arguments>
- DONE test param parsing is working.
command line param > env var > mbackup default value.
support --node-name param.
- DONE test run in console and scheduled task.
run in console works.
try run in scheduled task.
SCHTASKS /Create /?
# run mbackup 15m after user logon.
SCHTASKS /Create /U <username> /SC ONLOGON /TN mbackup-logon /TR "\"<path\to\mbackup.exe>\" \"args\"" /DELAY 15:00
# run mbackup at 10am and 4pm.
SCHTASKS /Create /U <username> /SC DAILY /TN mbackup-morning /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 10:00 /ET 13:00 /K
SCHTASKS /Create /U <username> /SC DAILY /TN mbackup-afternoon /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 16:00 /ET 19:00 /K
# debug purpose, one time only
SCHTASKS /Create /SC ONCE /TN mbackup-test /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 19:18
in powershell,
$mbackupexe = "D:\sylecn_docs\projects\mbackup-for-windows\bin\Debug\netcoreapp3.0\mbackup-for-windows.exe"
SCHTASKS /Create /SC ONCE /TN mbackup-test /TR $mbackupexe /ST 19:21
default run as user is current user.
in admin powershell,
SCHTASKS /Create /SC ONCE /TN mbackup-test /TR $mbackupexe /ST 19:32 /NP
/NP option requires admin privilledge.
it works.
to delete it,
schtasks /delete /tn mbackup-test
- problems
- how many scheduled task to run on a multi-user PC?
each user have its own user-default.list expansion.
should I iter over all users on PC?
I think only current user can get it's profile dir and special dirs.
- maybe config mbackup to run after user logon. with 15minute delay.
always run as current user.
- how to not require any param when running mbackup.exe?
put TARGET and other option in a config file?
define system level TARGET env variable.
use config file is easier for user to edit and making the change effective.
userConfigDir / mbackup.conf
search: F# read config file
FSharp.Configuration
http://fsprojects.github.io/FSharp.Configuration/
- FSharp.Configuration missing reference to System.Runtime.Caching
search: how to reference System.Runtime.Caching for dotnet core project
https://www.nuget.org/packages/System.Runtime.Caching/
dotnet add package System.Runtime.Caching --version 4.6.0
should I add 4.0.0? Can I use a higher version?
still not compatible.
search: use FSharp.Configuration with dotnet core 3
- give up on FSharp.Configuration.
- try this:
FsConfig
https://www.demystifyfp.com/FsConfig/
AppSettings is only supported in V0.0.6 or below.
try F# AppSettings directly.
If nothing is easy to use, write my own parser.
Support similar config format as python wells lib.
- ConfigurationManager.AppSettings Property (System.Configuration) | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager.appsettings?view=netframework-4.8
where should I save the App.config xml file?
search: what is app.config
App.Config: Basics and Best Practices - SubMain Blog
https://blog.submain.com/app-config-basics-best-practices/
What is App.config in C#.NET? How to use it? - Stack Overflow
https://stackoverflow.com/questions/13043530/what-is-app-config-in-c-net-how-to-use-it
Okay. This is not what I want.
This is for application configuration (rarely change), not for user configuration (can change any time).
dotnet will create <yourapp>.exe.config from your App.config file.
- how to use multiple files in F# dotnet core project?
search: f# module and namespace
search: f# module
Modules - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/modules
- SCHTASKS /Create /SC ONCE /TN mbackup-test /TR $mbackupexe /ST 19:21
this runs, it will show a console window. how to not show console window?
search: schedule tasks do not show console window
In the “General” tab, under the “Security options” section, select the Run
whether user is logged on or not option. (This is the option that will make
the command window not to appear when the task runs automatically.)
try /NP option.
- create an installer. The installer should add scheduled task on install and
delete scheduled task on removal.
- problems
- how to write unit test in F#?
Unit testing F# in .NET Core with dotnet test and NUnit - .NET Core | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-nunit
mkdir mbackup-tests
cd mbackup-tests
dotnet new nunit -lang F#
//wait.
dotnet test
dotnet add reference ../mbackup-for-windows.fsproj
dotnet build # this will build both ref project and test project.
dotnet test
- how to support short option names?
--dry-run -n
-
** 2019-11-14 support mbackup.txt config.
config file will have wells config file format.
empty lines and comment lines are ignored.
......