There are backup tool we can use on Linux system. Many of them are free but there are also paid backup software for Linux. Today, we are going to show you how to use Rsync to backup your Linux data. Rsync is a popular file transfer tool for Linux that is powerful, reliable and very stable. If you are in Windows, there are some Rsync client available for Windows. Rsync Linux is a command line tool, but it is popular among system administrator who uses Rsync for their backup tool. Continue reading to see How to Use Rsync for Linux Backup.
How to Use Rsync for Linux Backup
Rsync is available for any Linux distribution. It should be available on a standard installation. Linux Distribution such as Ubuntu comes with rsync package by default. You can check if rsync is available on your Linux with this command.
You should get something like this on your Terminal screen
ubuntu-budgie@ubuntu-budgie:~$ rsync --version rsync version 3.1.2 protocol version 31 Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append, ACLs, xattrs, iconv, symtimes, prealloc 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.
You can open rsync help with this command
You will find detailed informations and rysnc command list available.
On this tutorial we have the following:
- Local Linux computer:
IP address: 192.168.1.4
OS: Ubuntu 17.10
- Remote Computer (Linode Cloud):
IP address: 22.214.171.124
OS: Debian 9 Stretch
You may use another configuration based on your needs. On this example I use my cloud server at Linode.com. You may check the Linode.com if you want to build a low cost public cloud server. Below are some example that I use to Backup my Linux data to the remote computer
A. Incremental Backup using Rsync over SSH
By default, rsync will do incremental backup unless you add other options such as –delete flag. To do an incremental backup using rsync use the following syntax
rsync -avz /mydata -e ssh email@example.com:/backup
With this command, rsync will only backup or transfer the modified files. It will not copy the whole file again. This feature can save you a lot of bandwidth, storage space and it can run faster.
B. Backup Local Directory to Remote Server using Rsync over SSH
The following command will backup or syn my local directory called mydata to the remote computer/server inside /backup directory.
sudo rsync -avz –delete /mydata -e ssh firstname.lastname@example.org:/backup
- a : Tell rsync to archive the backup
- v: verbose
- z: This tell rsync to compress the archive
- –delete : This will delete any files in the destination, that does not exist in the source
- -e : Specify the remote shell to use. In this case I use ssh to connect to my remote server
As you can see there is –delete flag on this rsync command. This –delete flag is great if you want to sync your source directory with the destination directory (One way sync).
C. Backup to local disk or external disk using Rsync
Assume your external hard disk is mounted under /mnt/device01. The following syntax will backup /mydata directory to external hard disk.
sudo rsync -avz /mydata /mnt/device01
Rsync is a powerful backup tool for Linux. With this tool you can backup Linux to local disk, external disk, network folder, cloud server and many more. Thanks for reading this How to Use Rsync for Linux Backup and we’ll see you in the next tutorial.