Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

5 Answers 5

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.
  • fdisk -lu /dev/sda >sda-partition-table.txt for later human reference.
  • 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.

The upsides:

  • dump gets a complete copy of the filesystem, including ACLs, extended attributes, ownership, sparse files, special filesystem attributes — everything is dumped as-is.
  • It'll only copy the blocks you need, ignoring unused ones.
  • It's standard unix tool and readable by a lot of other unix tools.

The downsides:

  • 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.
share|improve this answer

Use dd for the boot-sector and rsync -aHS for the files. You have to exclude "virtual" filesystems like /proc /sys and any RAM-disks (tmpfs).

If you want to keep the partitioning as well, you can dump that with sfdisk or recreate it with parted.

share|improve this answer
    
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.wpf Jun 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. –  Nils Jun 23 '12 at 21:16

For Debian, you really only need to back up your data and configuration files.

To back up existing state:

  • Back up package selections with dpkg --get-selections > dpkg_selections.
  • Back up the debconf database with sudo debconf-get-selections > debconf_selections.

To apply this to a new system:

  • First apply debconf selections with sudo debconf-set-selections < debconf_selections.
  • Apply package selections with dpkg --set-selections < dpkg_selections.
  • Install packages with apt-get dselect-upgrade.

Your data should primarily be in /home and /var (e.g., /var/lib/mysql for MySQL, /var/www for Apache, etc.). You should be able to figure out which applications are important to you.

Configuration will be primarily in /etc. Again, it shouldn't be difficult to pick out what's important for you.

share|improve this answer

Check out Clonezilla. I see it listed in the standard Debian repos. http://clonezilla.org/

Edit: Probably not, Clonezilla list requirements on their front page: "X86 or x86-64 processor"

share|improve this answer
    
Interesting project though, thank you anyway :-) –  stefan.at.wpf Jun 22 '12 at 23:11

I don't know, if this is good to do, when the system is running, but this is what I do.

sudo dd if=/dev/mmcblk0 of=/path/to/backup/directory/backup.img bs=1M

as I said, maybe there is a better solution, in that case I would like to know it as well!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.