rdiff-backup - synchronize or backup files between Linux and Windows
Example scenario.
There is one of the most simplest way to have a full one-way backup of files from Linux server to Windows folder. One-way means that this solution covers backup solution only, i.e. without ability to restore the file system into exact state. This solution will help if, for example, Linux server hard drive fails, the most configuration files and data will not be lost and reconfiguration will take much less time.
The solution is as simple as having one exe file and one Windows batch file. No installation of software or admin related permissions/functions required on Windows machine.
rdiff-backup
tool has been chosen as core engine for this backup task.
- Home page: http://www.nongnu.org/rdiff-backup/
- Windows: http://savannah.nongnu.org/download/rdiff-backup/rdiff-backup-1.2.8-win32.zip
- Unix: http://savannah.nongnu.org/download/rdiff-backup/rdiff-backup-1.2.8.tar.gz
Linux server configuration
-
rdiff-backup should be on path on remote server
In my case the tool was installed on OpenSUSE system using the following command:
zypper in rdiff-backup
-
SSH public key, which will be used for authentication, should be in authorized keys store
By default it is located at
~/.ssh/authorized_keys
Windows configuration for backup with history
Create backup-rdiff.cmd
Example:
set BACKUP_HOME=D:/backup
set RDIFF_EXE=D:/utils/rdiff-backup-1.2.8/rdiff-backup.exe
set PLINK_EXE=D:/utils/Putty/plink.exe
set SSH_KEY=D:/docs/id_dsa.ppk
%RDIFF_EXE% ^
--remove-older-than 10B ^
%BACKUP_HOME%/files-rdiff
%RDIFF_EXE% ^
--exclude-filelist %BACKUP_HOME%/exclude-list.txt ^
--remote-schema "%PLINK_EXE% -i %SSH_KEY% %%s rdiff-backup --server" ^
--override-chars-to-quote "*/:<>?\\;" ^
--no-hard-links ^
--exclude-symbolic-links ^
root@serverhost::/ ^
%BACKUP_HOME%/files-rdiff
Just update BACKUP_HOME, RDIFF_EXE, PLINK_EXE, SSH_KEY paths and replace root@serverhost::/
with your own user, server host (or IP address) and start folder.
Create exclude-list.txt
Contains the list of directories that should be skipped.
Example:
/bin/
/dev/
/home/bob/Downloads/
/home/bob/Music/
/home/bob/Videos/
/lost+found/
/proc/
/run/
/sbin/
/sys/
/tmp/
/usr/
/var/
Of cause it is possible to change parameters for your personal needs. There is a comprehensive manual inside rdiff-backup archive.
Run
Now the two files are created and we are ready for backup operations.
Run the backup-rdiff.cmd
file everytime you want to make a backup!
Windows configuration for simple synchronization
Create and use the following backup-photo-gallery.cmd
script (example to rsync some photo library):
set RDIFF_EXE=D:/inst/UTILS/rdiff-backup-1.2.8/rdiff-backup.exe
set PLINK_EXE=D:/inst/UTILS/Putty/plink.exe
set TARGET_DIR=D:/docs/PHOTO_GALLERY_BACKUP
set RDIFF_BACKUP_DIR=%TARGET_DIR%/rdiff-backup-data
set SSH_REMOTE_LOCATION=user@remote.com::/home/user/photo/gallery/
set SSH_REMOTE_PORT=22
set SSH_KEY=D:/docs/id_dsa_user.ppk
rd /s /q "%RDIFF_BACKUP_DIR%"
%RDIFF_EXE% ^
--remote-schema "%PLINK_EXE% -i %SSH_KEY% -P %SSH_REMOTE_PORT% %%s rdiff-backup --server" ^
--force ^
--override-chars-to-quote "*/:<>?\\;" ^
--no-hard-links ^
--exclude-symbolic-links ^
%SSH_REMOTE_LOCATION% ^
%TARGET_DIR%
rd /s /q "%RDIFF_BACKUP_DIR%"