= rdiff-backup: {page-name}
:page-name: Windows Usage
:pp: {plus}{plus}
:sectnums:
:toc: macro

link:.[Home,role="button round"] // *{page-name}*

'''''

toc::[]


== Installation

Thank you for trying _rdiff-backup_ on Windows.
Native support for the Windows environment is quite new in _rdiff-backup_.
Please read the manual page, FAQ and the Wiki thorougly.

To install the provided binary, simply copy _rdiff-backup.exe_ to someplace in your *PATH*.
Everything is included in the binary (including Python) for local operation.
For remote operation, you will need to install a Windows SSH program.
You will also need to install _rdiff-backup_ on the remote system(s).

You will need the Microsoft Visual C{pp} 2008 redistributables.
If these are not installed on your system, _rdiff-backup_ will be unable to run and Windows will display a message such as _"The system cannot execute the specified program"_.
To install the redistributables for all users, install the package available from Microsoft.com (search for _"visual c 2008 redistributable"_).

Alternatively, you can install the redistributable in a "side-by-side" configuration, which does not require administrator privileges.
Simply download the DLL package from: https://download.savannah.gnu.org/releases/rdiff-backup/Microsoft.VC90.zip and copy the four enclosed files to the same directory as _rdiff-backup.exe_.

You will need to follow either method only once.

____
*NOTE:* you might want to https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later[enable long paths support in Windows 10 v1607 or later].
A simple alternative from the command line is to query the long path support with `reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled` (the result will be `0x0` for disabled or `0x1` for enabled), and enable it with `reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f`.
____

== Additional Issues

=== include and exclude paths

Currently, _rdiff-backup_'s `--include` and `--exclude` options do not support Windows paths with `\` as the directory separator.
Instead, it is necessary to use `/` which is the Unix directory separator.

Additionally, you may need to run _rdiff-backup_ from the same directory as the source of your backup, eg:

 > cd c:\
 > rdiff-backup.exe --include "c:/My Stuff" --exclude "c:/**" c:/ c:/Backup

will work to backup `"c:\My Stuff"` to `"c:\Backup"`, but:

 > cd "c:\My Stuff"
 > rdiff-backup.exe --include "c:/My Stuff" --exclude "c:/**" c:/ c:/Backup

will not work.

*UPDATE:* With appropriate escaping, it looks like it is possible for this to work.
Follow this example:

 > mkdir c:\foo
 > cd "c:\Documents and Settings"
 > rdiff-backup.exe --include c:\\/foo --exclude c:\\/** c:\/ c:\bar

The `\\` is necessary in the `--include` and `--exclude` options because those options permit regular-expressions, and `\` is the escape character in regular-expressions, and thus needs to be escaped itself.

=== Too old version of Windows

If trying to start rdiff-backup, you get a dialog:

____
The program can't start because api-ms-win-core-path-l1-1-0.dll is missing from your computer.
Try reinstalling the program to fix this problem.
____

And then on the command line something like:

____
Error loading Python DLL 'C:\Users\myuser\AppData\Local\Temp\_MEI395202\python39.dll
LoadLibrary: The specified module could not be found.
____

Then you're most probably running a version of Windows not supported by the version of Python embedded in `rdiff-backup.exe`.
The release notes and/or the installation instructions should give you the necessary information, else check the https://www.python.org/downloads/windows/[Python for Windows download page].

== Troubleshooting

If you have everything installed properly, and it still doesn't work, see the enclosed manual, FAQ, the web page at https://rdiff-backup.net, and/or the mailing list.
You can subscribe to the mailing list at: https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users

You can also try searching the mailing list archives: https://lists.nongnu.org/archive/html/rdiff-backup-users/

== Tips and Tricks

=== Using Putty as SSH client

If you have Putty installed (and configured) and don't want to fiddle with OpenSSH, add the following parameter to your rdiff-backup call:

----
--remote-schema "plink.exe -i D:\backup-key.ppk -batch %s rdiff-backup --server"
----

* `-batch` avoids having to press enter to open the session
* `-i` lets you specify a puttygen-generated private key

=== Using Microsoft's OpenSSH client on Windows 10

If rdiff-backup can't seem to find the native SSH client offered by Windows, even if it is definitely in your PATH (as proven by `where ssh`), and even if you use the full path `C:\Windows\System32\OpenSSH\ssh.exe`, it's most probably because you're using the 32 bits version of rdiff-backup on a 64 bits Windows, they just don't see this path.

You have two solutions:

. install the 64 bits version of rdiff-backup (at time of writing, it will _soon_ be available).
. add the remote schema option to your call of rdiff-backup with something like `--remote-schema "C:\Windows\SysNative\OpenSSH\ssh.exe %s rdiff-backup --server"` (adding the path to the front of your PATH environment variable might also be an option).

=== Create a bat script to call rdiff-backup

Create a file `rdiff-backup.bat` somewhere in your `PATH`.
The content can be as simple as the following:

----
C:\FULLPATH\rdiff-backup.exe -v5 -b --exclude-globbing-file "%~dpn0.txt" source target
----

so that you can put your exclusion patterns in a file called `rdiff-backup.txt` placed in the same directory as your bat-script.

____
*TIP:* if you set the remote-schema in your bat-script, don't forget to   duplicate the percentage sign to `%%s`, so that the bat-interpreter doesn't   "interpret" it as variable.
____
