diff --git a/Lib.fs b/Lib.fs index 0aeff4c074d87ef4d718f9ec771f9bcf1175e22a..704f633770b87ba8c152fe1de8455f1322a81b84 100644 --- a/Lib.fs +++ b/Lib.fs @@ -65,5 +65,14 @@ let toMingwPath (windowsPath: string) = windowsPath result +// Convert Mingw64 path to windows path. +let toWinPath (mingwPath: string) = + if mingwPath.StartsWith("/cygdrive/") then + let driveLetter = mingwPath.Substring("/cygdrive/".Length, 1).ToUpper() + let rest = mingwPath.Substring("/cygdrive/".Length + 1) + driveLetter + ":" + rest.Replace('/', '\\') + else + null + let ensureDir (path: string) = if path.EndsWith "/" then path else path + "/" let ensureWinDir (path: string) = if path.EndsWith "\\" then path else path + "\\" diff --git a/Program.fs b/Program.fs index da0ef7193d8a2f91ad6011fdf5d6979ca03825ce..3acfbb5962e74b91e8baa6bc562a0f6d61f433b8 100644 --- a/Program.fs +++ b/Program.fs @@ -180,7 +180,12 @@ let main argv = 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 sshConfigFileOption = + if File.Exists(toWinPath sshConfigFile) then + " -F " + sshConfigFile + else + "" + let rsyncCmd = List.append rsyncCmd [sprintf "-e \"'%s'%s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFileOption sshPrivateKeyFile] // precedence: command line argument > environment variable > config file let normalizeTarget target = diff --git a/mbackup-tests/MbackupTest.fs b/mbackup-tests/MbackupTest.fs index 60db4676af511067305d40fd053f1f3166260e21..3b979e35c44cdaa949a3b8a47f5f57c353706c0a 100644 --- a/mbackup-tests/MbackupTest.fs +++ b/mbackup-tests/MbackupTest.fs @@ -27,6 +27,14 @@ let TesttoMingwPath () = Assert.That("/cygdrive/D/foo", Is.EqualTo(toMingwPath "/D/foo")) Assert.That("/var/log", Is.EqualTo(toMingwPath "/var/log")) +[] +let TesttoWinPath () = + Assert.That("C:\\abc\\def", Is.EqualTo(toWinPath "/cygdrive/c/abc/def")) + Assert.That("C:\\abc\\def\\", Is.EqualTo(toWinPath "/cygdrive/c/abc/def/")) + Assert.That("C:\\", Is.EqualTo(toWinPath "/cygdrive/c/")) + Assert.That("D:\\", Is.EqualTo(toWinPath "/cygdrive/d/")) + Assert.That(null, Is.EqualTo(toWinPath "/etc/foo/")) + let mysprintf fmt = sprintf fmt [] diff --git a/operational b/operational index 87647fc9c23429bd2d087c6094fad905a3b81e31..1a59009c1f939cbaafe2248750714d3a98ef1265 100644 --- a/operational +++ b/operational @@ -194,6 +194,21 @@ Both local.list and local.exclude. - mbackup.msi works on B75I3 host. - try mbackup.msi on win 10 VM. how to require dotnet core 3.0 in .wxs file? + search: wix NetFxExtension symbol for .net core 3 + asp.net mvc - Wix package ID for .NET core runtime 1.0.3 - Stack Overflow + https://stackoverflow.com/questions/42908913/wix-package-id-for-net-core-runtime-1-0-3 + requires dotnet core 3 runtime on target node. + backup to local dir works. + backup to remote ssh node... + - problems + - 2019-11-14T10:50:13 ERROR Read/write file failed: System.Private.CoreLib Could not find a part of the path 'C:\Users\IEUser\AppData\Local\mbackup\mbackup.list'. + Does the dir exist? no. Create it at runtime. + fixed. + - backup to remote ssh node. + Warning: Identity file /cygdrive/c/Users/IEUser/.ssh/id_rsa not accessible: No such file or directory. + Can't open user config file /cygdrive/c/Users/IEUser/.ssh/config: No such file or directory + DONE do not specify config file if it doesn't exist. + TODO fail fast if ssh key doesn't exist. mbackup will only support key based auth. - problems - each file require it's own tag.