Home / How to use rsync to backup an entire Linux server?

How to use rsync to backup an entire Linux server?

Yes, It is possible to backup entire server files using rsync over the network to another server or to a locally attached disk. rsync is easy to set up but it is not a complete backup solution. Make sure you should not use rsync to backup server files to tape devices. You could completely clone a server but it is the slowest backup method. You should back up only the data and use third-party cloning tools to backup system files.

You can use rsync to perform differential backups so later backups only copy files that are changed since the last backup is done. It should be noted that rsync cannot backup online databases so use third-party software like cPanel to backup databases. You should use the following options with rsync:

ownerships, permissions, preserve timestamps, extended attributes (to preserve SELinux attributes), and ACLs.

Make sure you use the same rsync version on source and destination servers.

  • To backup server filesystem to an external disk (attached with USB or other hardware) and mounted as /media

rsync -AXav --progress --del --exclude "/sys/*" --exclude "/media/*" --exclude "/proc/*" --exclude "/selinux/*" --exclude "/mnt/*" / /media/

  • To backup server filesystem over a network to another server (which is computing.seimaxim.com in this How-To):

rsync -AXavz --progress --del --bwlimit=1000 --exclude "/sys/*" --exclude "/selinux/*" --exclude "/proc/*" --exclude "/media/*" --exclude "/mnt/*" / root@computing.seimaxim.com:/media/

In the above command -z option is used for compression to increase data transfer speed.

Leave a Reply