Local backup with rsync

rsync is a very powerful and versatile tool for managing your backups.

The algorithm is its main feature: this piece of software can recognize the updates you did on the original files. The backup’s speed is increased because it transfers only the changes that have been made. In this tutorial, we’ll learn how to perform a simple backup of our /home using an external drive.

WARNING: THIS METHOD IS AMAZING BUT ALSO DANGEROUS. AN IMPROPER USE COULD DESTROY YOUR DATA PERMANENTLY, SO PLEASE USE IT CAREFULLY AND AT YOUR OWN RISK.

Anyway, the basic syntax is extremely easy to understand:

rsync [OPTION…] SRC… [DEST]

OPTION = optional parameters

SRC = source of the data

DEST = destination of the backup

If the source has got an EXT-4 filesystem, I would recommend this way:

rsync -avHu –delete –progress –stats /home/juliux /run/media/juliux/ExtDisk

Let’s analyze the syntax:

/home/juliux is, obviously, the directory where my data are normally stored.

/run/media/juliux/ExtDisk is the path of my external hard drive.

a = archive mode: rsync works in a recursive way inside the directories. It also preservs symlinks, permissions, dates, groups, owners, devices and special files. So, this parameter tells rsync to save the Unix’ attributes of our files.

-v = it throws some details about the whole process

-H = tell rsync to preserv Hard links too.

-u = omit the files which are newer in the destination

–delete = delete the destination’s files which are no longer present in the source

–progress = it shows us the “on going” of the whole process

stats = rsync summarizes some stats at the end of the backup

If the source has got a FAT32 filesystem, This way works way better:

rsync –progress –delete –modify-window=1 –update –recursive –times –size-only –stats /home/juliux/ /run/media/juliux/FatDisk

Obviously, this filesystem doesn’t support the Unix’ standard for permissions and ownership.

/home/juliux is, again, the directory where my data are normally stored.

/run/media/juliux/FatDisk is the path of an external drive with a FAT32 filesystem.

–modify-window and —times are required because FAT32 threats dates in a different way than Unix’ one.

update it’s the same as “u“, explained with the other method.

size-only = with this parameter, ryncs omits files which haven’t changed size.

That’s all for now! I still recommend to use this tool carefully. My advice is to try and learn how to use it with small directories first. PAY ATTENTION, as an improper use could destroy your data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s