I use Debian and I do full OS backup synchronization all the time. If you want a true bootable backup that includes the exact same MBR and such, you've got a little problem: by default Debian uses UUIDs and having two partitions in the same physical box with the same UUIDs can be a problem.
My experience is that it's okay to temporarily have cloned UUIDs for when I am cloning hard drives or partitions. But when you boot with identical UUIDs around things can get messy. The solution is this:
A) Don't have the same UUIDs!
B) Modify your /etc/fstab to use device names instead of UUIDs. Be aware that this means you have to be careful which SATA cable is attached to which hard drive, so the correct hard drive is /dev/sda. OTOH, this makes swapping in the backup easy. You just power down and swap SATA cables!
So, a way to do all this is:
1) Do a clean Debian install on the first drive. Do manual partitioning. Wipe out all partitions on /dev/sda and /dev/sdb and create exactly ONE partition on /dev/sda for the OS and ONE partition on /dev/sdb for the backup. DO NOT CREATE A SWAP PARTITION (this will make everything more complicated later on if you do; if you really need swap create a swap file later). Make these partitions the same size; something like:
Code:
/dev/sda1 / ext4 5GB
/dev/sdb1 /mnt/sdb1 ext4 5GB
Note that because you created sdb1 using the Debian installer, it will have a different UUID than sda1. If you had used the "dd" method to clone sda, it would create cloned partitions with cloned UUIDs. Not good for this use case!
When the Debian installer asks where to install GRUB, do it in /dev/sda.
2) Boot up to your Debian install
3) Use the following command as root to create and later sync up the backup of sda1 to sdb1:
Code:
rsync -vaxAX --delete /. /mnt/sdb1/
The first time will take a while. From then on, it will typically take a few seconds or less just to incrementally update the changed files. The flags used are:
-v = verbal output (so you can see all it's doing)
-a = archive mode
-x = only one file system (in this case, only /dev/sda1)
-AX = preserve ACLs, file attributes
--delete = delete files that don't exist in the source
4) Modify a temporary /mnt/sdb1/etc/fstab so we can install grub on sdb. You'll want to swap mount points of "/" and "/mnt/sdb1".
Code:
UUID=770ce661-6e16-4d8f-9fb5-365dfcb6b33a / ext4 errors=remount
-ro 0 1
UUID=a8c01db2-a7f3-4771-a0c6-61e10cc6b0ac /mnt/sdb1 ext4 defaults
0 2
Modify to something like this:
Code:
UUID=770ce661-6e16-4d8f-9fb5-365dfcb6b33a /mnt/sdb1 ext4 errors=remount
-ro 0 1
UUID=a8c01db2-a7f3-4771-a0c6-61e10cc6b0ac / ext4 defaults
0 2
5) Create an auto-detected boot menu entry for sdb with:
6) Reboot into sdb. There will be two Debian options. Choose the second. You can confirm which partition you've booted to with the "df" command.
7) Update grub and install MBR bootloader on sdb with:
grub-install /dev/sdb[/code]
This will install the grub2 bootloader on sdb, pointing to the UUID of /dev/sdb1. Note that the configuration in /boot and /etc/fstab will later get overwritten by your backup rsync. This was just done to get the grub2 bootloader properly installed on /dev/sdb.
8) Reboot to sda (the first boot option).
9) Modify /etc/fstab to replace UUIDs with device names. It will start something like this:
Code:
UUID=770ce661-6e16-4d8f-9fb5-365dfcb6b33a / ext4 errors=remount
-ro 0 1
UUID=a8c01db2-a7f3-4771-a0c6-61e10cc6b0ac /mnt/sdb1 ext4 defaults
0 2
Modify to something like this:
Code:
/dev/sda1 / ext4 errors=remount
-ro 0 1
/dev/sdb1 /mnt/sdb1 ext4 defaults
0 2
10) From now on, use the rsync command to backup from sda1 to sdb1. To repeat the above command:
Code:
rsync -vaxAX --delete /. /mnt/sdb1/
If you ever need to use your backup, power down the computer and swap SATA cables.