Backup Linux Home Directory Using rsync

I need to backup my Linux home directory to one of my portable hard disk. I tried to use git, but failed since git doesn’t support large file (I failed after many tries, I have file larger than 5G). I find rsync, the fast, versatile, remote (and local) file-copying tool and I am happy with it now. rsync is very fast especially the change is incremental. rsync can generate a delta of the change.

The method is simple, just execute this command:

$ rsync -avxP \
/path/to/directory/to/backup \
-a means archive mode
-v means print out the verbose information during backuping
-x means not cross filesystem boundaries
-P is shortcut for
--progress means printing information showing the progress of the transfer
--partial means keeping partially transferred files if the transfer is interrupted

Note that the files on the destination directory storing the backup data will be kept if the files do not exist in the source directory to be backup’ed. If you would like rsync to delete the files/directories in the destination directory if the files/directories does not exist in the source directory, you can add --delete to rsync:

$ rsync -avxP --delete \
/path/to/directory/to/backup \

If you would like
You can check all options of rsync from rsync’s man page.

That’s it. You can use cron to run it every day or every week.

The method can also be used to backup any kinds of directory except linux home directory. rsync also supports copying files to remote host. Please check “man rsync” for more.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.


Leave a Reply

Your email address will not be published. Required fields are marked *