This time is about using rsync to copy a Linux/Unix system to another host or perform full system backup. By using rsync, its more effective than using tool like dd since we can efficiently select the directory, attribute that we we want to backup or move.

Sometime ignorance is a blessing

The one who not so wise

rsync also can be use when the system is running. But you may need to do it with caution and make sure you understand the data state. When rsync with the system running, the data that have not commit the changes in files level may not transfered.

This method is work for migrating the the system to another hosts. Please be aware, that the target is the fresh installed operating system with the same version of the source.

Rsync full backup

#rsync -aAXHv --numeric-ids --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup

Rsync Clone

rsync -qaHAXS [SOURCE_DIR] [DESTINATION_DIR]
  • –numeric-ids, will disable mapping of user and group names; instead, numeric group and user IDs will be transfered. This is useful when backing up over SSH or when using a live system to backup different system disk.
  • –info=progress2,  will show the overall progress info and transfer speed instead of the list of files being transferred.
  • avoid crossing a filesystem boundary when recursing, add the option -x/–one-file-system. This will prevent backing up any mount point in the hierarchy.
  • -n or known as the option for the dry-run. To simulate the file transfers

Tips:

When migrating operating system using rsync, we may need to make sure that the migration have a low downtime impact on the server/service. Make sure you perform inital rsyn using above command in “Rsync full backup”. Then at the final migration, stop all service on the source server/vm then perfom the same command again.

To avoid saturated network performance when transfering the you can use option to have a speed limit in the transfer  –bwlimit= [In KBytes]

Previous ArticleNext Article

Leave a Reply

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