How to backup your data using Rsync

Rsync is a great open source file synchronization application for Linux based systems. It is very fast and versatile. We all need to backup data from time to time. In this article I will tell you how to backup your data using rsync both locally and remotely.

Rsync is installed by default in most of the linux distros. If it is not installed then you may download the source package from here and follow the installation instructions to install it.

Local Backup

The basic syntax for local transfers is:

[shredder12]$ rsync -azv <path of source directory> <path of destination directory>

e.g.

[shredder12]$ rsync -azf /home/user1/source/ /media/disk/dest

P.S. - While using Rsync take care of the extra slash '/' at the end of the destination file. If there is a '/' at the end of the directory then it means that only the contents of source directory will be copied to the destination directory not the whole directory. If no slash '/' is used then the whole directory source will be copied to the destination directory.

Backup over network (Remote backup)

For remote backup using ssh is useful than creating a rsync daemon. The basic syntax while using ssh for backup is

[shredder12]$ rsync --delete -azv  -e ssh  <path of src dir> remoteuser@remotehost.remotedomain:<path of dest dir>

Arguments used

--delete - This is optional. It means delete files that don't exist on the system being backed up.

-a --archive -  archive mode. Using this single option is similar to using -rlptgoD. This mode copies recursively, saves file permissions, ownerships, symlinks, modification times and a lot more.

-v --verbose -  to be more verbose

-z --compress - the data

-e - to specify the remote shell to use (here ssh)

So, next time you have to back up your data, its just a single command away using rsync.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.