Is it possible to backup a running Debian system to some kind of image file, that could simply be written back to another hard disk using dd in case of failures of the original (backed up) Debian system?

I am especially looking for a tool directly available in the repositories, as I have Debian Wheezy running on a raspberry pi and therefore, I need support for the ARM architecture, which is given quite reliable for packages of the Debian repositories.

I wouldn't recommend trying to get a block-for-block copy from rw-mounted filesystem. Smallest write can corrupt it and you think you have a workable backup. So mount -o remount,ro the drive you are copying if you opt for dd,dump or similar. Copying withing filesystem with rsync or any other method including cp is safe for live system.
–
WhimsicalWombatMay 21 at 2:38

7 Answers
7

dd is good if you don't mind generating an image file that's exactly the size of your raw disk. rsync is good if you want easy file-level access. But the standard means of backing up a filesystem is dump and restore (aptitude install dump).

For a device like the Raspberry Pi, I'd back up as follows, assuming an MS-DOS partition table and that the disk is /dev/sda:

dd if=/dev/sda of=sda-boot-sectors.img count=2048 to get an image of the boot section of the disk.

dump -0af sda1-root-level0.dump /dev/sda1 and repeat for each partition you want to back up.

You can then compress the lot and leave it somewhere safe. To restore, you'd use dd to restore the partition table and boot sectors, reload the partition table, make the new filesystem(s), and use cd /mnt/new-filesystem; restore -rf /some-location/sda1-root-level0.dump.

it will produce corrupted snapshots if the file system is written to during the dump

it's more difficult to mount the backed up image (which you can do with disk images) or get to individual files (which you can get with rsync backups).

It's filesystem type-specific. You can dump an ext3 filesystem and restore it in an ext4 one, but you can'd dump any type of filesystem. Most mature filesystems have their ownd dump versions. The standard Debian dump does ext2, ext3 and ext4. If you use a Flash-specific filesystem, your options may be different.

Thanks, sounds very interesting, did you already tset this in the past? How do I create a complete image out of these parts, just use a loopkack device? (Yes, want to keep partitioning and so on. Want an image ready to be written to a new SD card / disk without further fiddling)
–
stefan.at.wpfJun 22 '12 at 23:10

@stefan.at.wpf I just mixed up some of my solutions for cloning VMs, creating physical servers (autoyast/kistart) making a raid1-mirror out of a non-mirrored system and the usual way to replicate (static) parts of the filesystem for cluster nodes. I do not use this myselv. My method would be to autoinstall new server (including a backup-client) and then restore via backup the contents of the old server to the new server.
–
NilsJun 23 '12 at 21:16

I have tried so much backup and restore software and was never happy.
This is what I do now: I have a second Debian installed on a spare computer (same MB, NIC card, etc).
Every evening I rsync from machine A to machine B. There are some files that I hold back (/etc/network/interfaces, /etc/hosts, /etc/hostname) since I don't want conflicts of the two running systems. Actually, I do have copies of them in another folder.
I also disable some services that I don't need to run on machine B (postfix, mysql, etc).
I have a script written on machine B that will basically turn it into machine A (replace those files that I held back), restart the NIC and enable the services that were disabled. Of course machine A needs to be off when I run the script or there will be havoc.
I test machine B monthly by turning off machine A, running the script, and doing some tests to make sure it is up to date and running properly. It works like a charm!