Linux Administrator

How To Setup Remote Backup With Rsync

remote-backup-with-rsync
mm
Written by Santosh Prasad

Backup is most important task for any server administrator these days, all Linux users know about rsync as a file transfer utility, but using rsync we can also automate remote backups of our Linux, Windows, and Mac OS X system.

In this article I will explain how to setup rsync to perform automatic backup.

Install Rsync

To perform secure remote backup, make sure you have rsync and SSH installed on both your local system and your remote system. Rsync uses SSH as a secure transport agent.

Verify the rsync utility is installed on not on your system using below command:

# rsync --version 

Sample output

rsync  version 3.0.6  protocol version 30
Copyright (C) 1996-2009 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

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.

If you get message like “command not found” or a similar message, you will need to download and install rsync, you can also use GNU/Linux distribution’s package management system to to this.

Follow the below command to install rsync:

# yum -y install rsync

For SSH installation follow my previous article:

Once all the necessary package and programs and permission are in place choose a directory with some small files to use as a test backup. After that create a directory on the remote machine to hold your backups.

One Local Machine:

# mkdir /root/test
# cd /root/test
# touch test.txt test1.txt test2.txt
# ls -l
total 0
-rw-r--r-- 1 root root 0 Sep  6 10:24 test1.txt
-rw-r--r-- 1 root root 0 Sep  6 10:24 test2.txt
-rw-r--r-- 1 root root 0 Sep  6 10:24 test.txt

On Remote Machine:

# mkdir -p /backup/destination/directory/

Do the rsync:

# rsync -avz -e ssh /root/test/ [email protected]:/backup/destination/directory/

Trailing slash is used in source directory to copy only the contents of the source directory. Omitting the trailing slash causes rsync to copy both the directory name and its contents to the destination.

Congratulations on your first remote backup! Now let’s automate the process.

Automatic Backups

Follow the below link to automate the above process.

Thanks:)

Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment