BackupToFromWindowsToLinux
From RdiffBackupWiki
Contents |
Scenarios
Push/Pull from Linux TO Windows
As Microsoft Windows does not have a native SSH server built-in, this is currently not possible without the purchase of a commercial Windows SSH server package. It is simpler to use push and pull from a Windows machine, as you can conduct most rdiff-backup operations with Windows native rdiff-backup.
So the following will NOT work from a Linux host to a Windows host:
rdiff-backup /source/directory user1@windowshost.domainname::/destination/directory rdiff-backup user1@windowshost.domainname::/source/directory /destination/directory
Push/Pull FROM Windows to Linux
Since rdiff-backup has native Win32 binaries, this works when initiated by the Windows host! With one caveat: rdiff-backup.exe has to be instructed how to connect to a remote host using an external SSH client program. There are many SSH clients for windows. I prefer the popular ssh client putty but this documentation is probabably easy to adapt to other SSH clients, too.
So the following WORKS from a Windows host to a Linux host:
rdiff-backup C:\source\directory jay@linuxhost.domainname::/destination/directory rdiff-backup user1@linuxhost.domainname::/source/directory C:\destination\directory rdiff-backup user1@linuxhost.domainname::/source/directory user2@another.linuxhost.domainname::/destination/directory
Configuring SSH with public key authentication
- Download to your Windows computer putty.exe, plink.exe and puttygen.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Generate a keypair with puttygen.exe. (This is a windows program with a GUI, just start it, no installation required, hit generate, then move the mouse to create random seed.)
- Save the private key, without a Key passphrase, to a file named privatekey.ppk, in C:\Documents and Settings\user\. Leave puttygen open for the moment...
- Still from your Windows computer, log in to the Linux system with putty.exe, supplying your Linux username and password. Within putty, decide whether you are going to use /home/user/.ssh/authorized_keys or /root/.ssh/authorized_keys on the linux server (depends on which user account you are going to use.) If using the first, and the directory (~/.ssh) doesn't exist, create it with mkdir ~/.ssh. Do nano -w ~/.ssh/authorized_keys or su nano -w /root/.ssh/authorized_keys to edit/create authorized_keys. Copy the public key from the puttygen window, and paste (right-click) it directly into a new line in this file, then exit nano with CTRL+X and save the change.
Verify that passwordless login works with the private key file
From a command prompt execute the following:
plink.exe -i privatekey.ppk username@servername.domainname
Important! You have to answer 'yes' to accept the fingerprint of the server. If this not is done rdiff-backup can't use plink.exe and won't work nor give you the possibility to answer 'yes'.
If everything works you should now be logged in to the remote server without having to enter a password.
Special Considerations for the Windows Filesystem
Syntax to launch rdiff-backup.exe
rdiff-backup.exe -v5 --no-hard-links --print-statistics --remote-schema "plink.exe -i privatekey.ppk %s rdiff-backup --server" c:\sourcedirectory username@servername.domainname::/destinationdirectory
In this example -v5 (verbose level 5) and --print-statistics aren't necessary but I often prefer to use them. All three lines above should be on one line when launching rdiff-backup.
NTFS does not support hard links, so the --no-hard-links option is used. If you do not use it, rdiff-backup will complain that the target filesystem does not support hard links and will exit.
If you want to backup all of the C drive, then use c://\ instead of c:\sourcedirectory.
Hints on using native win32 rdiff-backup in windows
- If using rdiff-backup versions prior to 1.2.1: You will propably want to use the --no-hard-links option. Otherwise rdiff-backup stores a diff for every file even when there are no changes. This is happening because windows does not have inode numbers in the filesystem. From release 1.2.1 this option is automatically disabled when running in Windows.
- If called from a DOS batch file the %s must be written as %%s.
- %s in the command line must exist and should NOT be a "hardcoded" servername which will result in a syntax error.
Known problems
- rdiff-backup fails if you specify C:\ as the source directory (and maybe any other path that ends with a '\'). You may use C:/ to side-step this problem (it's unintuitive to non-unix aware people but works see https://savannah.nongnu.org/bugs/?24100#comment23)
