Newer
Older
* COMMENT -*- mode: org -*-
#+Date: 2019-11-12
Time-stamp: <2019-11-12>
#+STARTUP: content
* notes :entry:
** 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
try an ssh run:
dotnet run -- -n --target root@sylecn01.emacsos.com:/data/backup/PC-backup/B75I3/
it works.
file list works.
ssh transfer works.
remote logging works.
** 2019-11-12 docs
- rsync
https://www.samba.org/ftp/rsync/rsync.html
- Basic Editing in Visual Studio Code
https://code.visualstudio.com/docs/editor/codebasics
Get Started with F# in Visual Studio Code | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/get-started/get-started-vscode
install Ionide-fsharp extension.
- Argu
http://fsprojects.github.io/Argu/
Tutorial
http://fsprojects.github.io/Argu/tutorial.html
--help doesn't work, need error handler.
Argu/Program.fs at master · fsprojects/Argu · GitHub
https://github.com/fsprojects/Argu/blob/master/samples/Argu.Samples.LS/Program.fs
- F#
F# Language Reference - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/
F# Collection Types - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/fsharp-collection-types
fsharp-cheatsheet
https://dungpa.github.io/fsharp-cheatsheet/
Literals - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/literals
[|' '|] is an array of character, length is 1.
F# list is not the same as array. You can convert array to list via Array.toList
String Class (System) | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/api/system.string?view=netframework-4.8
Environment.SpecialFolder
https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.8
ApplicationData
LocalApplicationData
MyDocuments
MyPictures
DesktopDirectory
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
- FSharpLint
http://fsprojects.github.io/FSharpLint/
http://fsprojects.github.io/FSharpLint/index.html
** 2019-11-14 supports expand Downloads dir in user-default.list
** 2019-11-13 extra user default list.
Documents is replaced by real path.
Downloads
Pictures
User should always use forward slash in backup list and exclude list files.
These path are supported:
C:\Foo\Bar
C:/Foo/Bar
Pictures/Saved Pictures
Documents/
** 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:\ProgramData\mbackup\mbackup-default.exclude
C:\ProgramData\mbackup\mbackup-default.list
C:\ProgramData\mbackup\user-default.list
- DONE fix TODOs in F# code
- 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.
- test run in console and scheduled task.
- 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.
where should I save global config file in windows 10?
Windows uses the %APPDATA% directory for user specific application
configuration files. The %PROGRAMDATA% folder is used for system wide
application configuration files, though it appears that Windows Store
apps may not be able to use %PROGRAMDATA%.
C:\ProgramData\mbackup\mbackup-default.list
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
- on B75I3, rsync is here.
D:\downloads\apps\rsync-w64-3.1.3-2-standalone\usr\bin\rsync.exe
scheduled task command is:
<Actions Context="Author">
<Exec>
<Command>D:\downloads\apps\rsync-w64-3.1.3-2-standalone\usr\bin\rsync.exe</Command>
<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>
<WorkingDirectory>D:\downloads\apps\rsync-w64-3.1.3-2-standalone\usr\bin\</WorkingDirectory>
</Exec>
</Actions>
- I don't want to bundle python with mbackup for windows, so I will use
C# and dotnet core 3 to create mbackup console executable.
mbackup --cron
# run the command as if run in scheduled task.
mbackup
# run backup command interactively.
create new console project.
dotnet new console -lang=F#
Try F# this time. it's said dotnet have very good F# support.
It's a small program, should be easy to handle.
- implementation
- install-package argu
can't find package.
https://www.nuget.org/packages/Argu
try this:
dotnet add package Argu --version 5.5.0
it works.
- how to change output exe file name?
can't find it. won't fix. default name is mbackup-for-windows.dll/exe
- make rsync command work.
- how to backup only documents in "My Documents" and "Downloads"?
I don't want to backup exe/msi/zip/rar/7z/iso/tar.gz files in those dir.
Only backup pdf/docx/xlsx etc.
Maybe just let user add "My Documents" in local.list.
I won't backup anything by default.
This is not good enough. docs should be backed up by default.
can I backup a zip file if I have Documents/**.zip in exclude list?
- TODO F# doesn't have a free logging framework yet?
logary/LICENSE.md at master · logary/logary · GitHub
https://github.com/logary/logary/blob/master/LICENSE.md
this one is not free software.
-
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
** 2019-11-12 how to test it? test it in a win 10 VM?
- search: lite weight win 10 VM
There are pirated specialized versions of Windows 7 and XP out there called
TinyXP and Tiny7. They are very stripped down and light weight.
Tiny7 is created using AIK.
https://en.wikipedia.org/wiki/Windows_Automated_Installation_Kit
- try get tiny7 iso/disk image.
tiny7 is no longer maintained.
try the old version.
Tiny 7 Windows : eXPreience : Free Download, Borrow, and Streaming : Internet Archive
https://archive.org/details/Tiny7
2017.5
- I have a 4.1G MSEdge win10 vmdk disk on sheni. from 2016.
maybe just use this.
- there is no enough RAM on B75I3. I will stop bogon VM and run win 10 VM.
-
** 2019-11-12 mbackup for windows
- 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.
taskschd.msc
- implementation.
- there is rsync running on B75I3.
exported tasksched.msc config as xml.
that XML is not portable.
it contains hostname.
-
* done :entry:
** 2019-11-13 build mbackup.list file from file list and exclude lists.