BackupToFromWindowsToLinux

From RdiffBackupWiki

(Redirected from BackupFromWindowsToLinux)
Jump to: navigation, search

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

Path Workarounds

A number of bugs exist in rdiff-backup (as of the latest 1.3.3) that prevent the use of standard Windows paths. To make matters more confusing, these bugs are inconsistent between different parameters.

The most common bug reported is the unescaping of strings. For example, the follow command will produce the output below:

rdiff-backup c:\source\directory "c:\destination directory\"
Fatal error: Unable to create directory c:\destination directory"

Notice how the end quote was included in the directory name. There are two solutions, first, include an extra "\" to complete the escaping or remove the trailing slash since it's not needed anyway.

rdiff-backup c:\source\directory "c:\destination directory"

If we choose the other solution by adding a "\", it fixes the escaping problem but lands us right in the middle of another bug.

rdiff-backup c:\source\directory "c:\destination directory\\"
Exception 'Unexpected end to file description c:\destination directory\

This bug appears to be the result of rdiff-backup expecting / as the last character or the name of a directory or file. An easy work around is to include a "/" at the end, or a period.

rdiff-backup c:\source\directory "c:\destination directory\\."

Keep in mind, if you do use a "." instead of a "/" it gets added to the path, and will affect your include and exclude statements.

On the topic of include and exclude, for some reason, the code that checks the include/exclude parameters against the base directory fails unless you escape the root drive "c:\" as "c:\\". An example of how to "trick" rdiff-backup into using include and exclude statements:

rdiff-backup --include "c:\\/source/directory/somesubdir" --exclude "c:\\/source/directory/" c:\source\directory "c:\destionation directory"

Also note, in the include and exclude statements, you must use only forward slashes ("/") except for right after the drive letter ("c:\\").


Configuring SSH with public key authentication

  • 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. (Make sure that there is no line break in the newly created line, as the key must be in one single line.)

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)
Personal tools