Options for full Debian laptop OS backup to second HDD
Hi all,
I've finally got round to installing a linux OS on my laptop and have been having fun tinkering and learning but this morning I made, what I'm sure won't be the last, major mistake. As root I Code:
chown -R owner:group / Code:
chown -R owner:group ./ Is there any way to fully backup my OS so that should I get myself into this sort of situation again I would be able to restore my way out of it? I've got a second 1tb HDD in the laptop that I'll use to store the backups. I've seen tools like clonezilla that can take a full backup of a disk but I'm hoping for something I can run incrementally so it's not a fully disk backup every time. Thanks in advance! Jack |
I've heard good things about Back in Time, which is a GUI frontend for rsync. I've not used myself.
I use rsync itself from time to time to back up my laptop's /home directory to external media; I say "from time to time" because significant changes warranting backup don't happen all that often on my laptop. When it comes to system configuration files (those found in /etc, as opposed those in /home), I back up only those which I have changed or expect to change, such as /etc/samba/smb.conf. If I have truly significant data to back up, I usually back it up to at least two external hard drives. On of the nice things about Linux is that a restore or reinstall is a last resort. If you make a mistake, can often fix it short of that. For example, if you muck up a config file, you can boot to a live CD of something or other, mount the hard drive, and often fix the problem by re-editing the file. I learned that you could do that by mucking up a config file.:) |
I use rsnapshot, which uses rsync to do incremental backups, to make daily, weekly, and monthly backups of an entire server configuration to another, off-site, server. It can also be used to make in-place copies -- I'm reluctant to call them backups if they're on the same HDD -- if that might me useful.
I don't think it has a GUI, tho. :: Oh, you said second HDD. Yes that will work well with rsnapshot. |
As others have suggested, rsync is an excellent utility. Personally, I use it on the command line as I don't like gui utilities much. I'd check out the Arch wiki https://wiki.archlinux.org/index.php...backup_utility for more information
|
You can can make an exact, bootable back-up with dd:
Code:
$ dd if=/dev/sda of=/dev/sdb bs=4096 Code:
$ dd if=/dev/sdb of=/dev/sda |
Quote:
Quote:
|
Which illustrates one needs to really understand why a backup is needed. What you ask for may not be what you actually want.
I use several different tools (on the one system) depending on requirement. But I never use dd (for backups) - I prefer to have some confidence that the filesystem(s) is readable. But I have no problem having to re-install grub in a disaster - that's likely to be the least of my concerns in such a situation. So: - fsarchiver (compressed, CRC, point-in-time complete filesystem backup) - rsnapshot - rsync How many of you people test your backups before you actually need them ?. |
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 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/ -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 Code:
UUID=770ce661-6e16-4d8f-9fb5-365dfcb6b33a /mnt/sdb1 ext4 errors=remount Code:
update-grub 7) Update grub and install MBR bootloader on sdb with: Code:
update-grub 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 Code:
/dev/sda1 / ext4 errors=remount Code:
rsync -vaxAX --delete /. /mnt/sdb1/ |
Ugh...sorry, read too fast. Missed out on "laptop".
A much simpler solution in this case would be to just rsync to an backup like this: Code:
rsync -vaxAX --delete /. /mnt/bigdrive/osbackup/ Later on, if you need to restore, boot to a liveCD or a second Debian install if necessary and use rsync to copy back to the main OS drive: Code:
rsync -vaxAX --delete /mnt/bigdrive/osbackup/. /mnt/sda1/ Additionally, you can use "dd" to backup and restore the MBR/partition table (assuming we're talking an MBR drive): backup MBR Code:
dd if=/dev/sda of=/root/boot.img bs=512 count=1 Code:
dd if=/root/boot.img of=/dev/sda bs=512 count=1 |
@TheEzekielProject
Point taken. I guess my speed-reading class didn't really pay off. |
Just a couple of notes:
Quote:
Quote:
|
Quote:
|
Quote:
Quote:
Hibernation is just so incredibly slow and sluggish in both directions compared to normal suspend. Considering normal suspend can conserve a low battery for a long time, well... Okay, I see a use case for hibernation. If you're the sort of person who doesn't save regularly and you also have a tendency to leave your laptop unattended, and you often work off of battery, and you might leave the laptop unattended for more than a few days (however long it will last in normal suspend mode), then having the OS emergency hibernate on low battery can save you from losing your unsaved work. And really, it only takes one "save" to make it all have been worth it. Personally, I'm used to using desktop computers at work; most of them have no UPS. The occasional power outage keeps me in the habit of saving often. As such, I just don't fit the use cases where hibernation is useful. |
Wow, thank you all for the massively detailed responses! It looks like rsync to dedicated partition on my second HDD should do what I want!
So RSYNC is going to basically synchronise my OS to the second HDD and should I get into a position where I've messed everything up I can boot into a live cd and just RSYNC everything back to restore my OS to the original position? I'm happy modifying FSTAB to get everything mounted how it should be. |
Quote:
If you just want to be able to save and restore, and you assume the primary drive itself doesn't go bad, it's much simpler. You don't even need to set up a separate partition for the backup. Just create a folder on any partition with sufficient space. I'll assume the backup folder is /mnt/sdb1/debback/ You simply save/update with: Code:
rsync -vaxAX --delete /. /mnt/sdb1/debback/. Code:
rsync -vaxAX --delete /media/user/sdb1/debback/. /media/usr/sda1/. Additionally, you can save/restore the MBR/partition table with: backup MBR Code:
dd if=/dev/sda of=boot.img bs=512 count=1 Code:
dd if=boot.img of=/dev/sda bs=512 count=1 |
All times are GMT -5. The time now is 08:42 PM. |