On this tutorial I am going to show you how to use Rsync to backup files or directories from Linux to a remote Windows shared. Rsync is a powerful tool to backup data to a local directory or remote shared folder via ssh or using samba. We can also automate the process so we do not have to execute the backup command everytime.
First, make sure you have rsync installed. On this tutorial, I am using Elementary OS Luna which rsync is already installed. To check, type this command on Terminal
If rsync is installed, you will see the following version information printed on screen
dhani@dhani-elementary:~$ rsync –version
rsync version 3.0.9 protocol version 30
Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
Now, since we want to save the backup on a remote directory (Windows shared folder), we need to mount the remote folder first.
mount -t cifs //192.168.2.101/share -o username=fitri,password=12345 /mnt/remote-folder
Change the IP address with the remote Windows IP address, and also username and password to login to Windows. The command above will mount the folder share on Windows to /mnt/remote-folder. Change this with your own.
Next, we can execute this command to backup a folder to the remote folder.
rsync -avv /home/fitri/ /mnt/remote-folder
The command above will backup /home/fitri to the mounted folder. In this case, the file will be saved on the remote folder which is mounted on /mnt/remote-folder.