The challenge: Backup your server without rebooting it and with nearly no downtime of the services.
The solution:
1. Mount your backup device. In my case, it is a USB drive on /dev/sdb1. My server’s root is located on /dev/sda.
2. Turn off database, mail services and other disk intensive daemons for the backup: sudo /etc/init.d/mysql stop (or via Webmin). Also shut down virtual machines for the backup that have their virtual drives on this partition.
3. Run a test drive of rsync:
sudo rsync –dry-run –checksum –progress –verbose –exclude-from=/root/exclude.rsync –archive –acls –one-file-system –delete / /media/sdb1/
4. Run rsync for real:
sudo rsync –dry-run –checksum –progress –verbose –exclude-from=/root/exclude.rsync –archive –acls –one-file-system –delete / /media/sdb1/
5. Restart your services and daemons: sudo /etc/init.d/mysql start etc.
6. If you want to be able to boot your system from the backup after a hard disk swap, install grub on its MBR:
sudo grub
grub> root (hd1,0)
grub> setup (hd1)
Also, run “sudo blkid” and adjust the Unit-IDs in /etc/fstab OF YOUR COPY according to the output for your backup HD (/dev/sdb).
7. Test your backup: Swap the disks and boot from your backup hard drive.



