I'm trying to implement the easy to maintain backup solution for our local linux server. The goal is to be able to restore the whole system from image file.

What I am thinking of is just to issue following script with cron

FILENAME=`date +%F`.bak
dd if=/dev/sda | bzip > /media/remote_backups/$FILENAME

The problem is that this script should be run in special environment - when only basic services work and no filesystems are mounted.

So, the question is: Is it possible to reboot the server by cron, for example, weekly, and then not boot normal mode, but some kind of "special" mode, when nothing loads, except:

  1. mount remote partition for backups at /media/remote_backups/
  2. execute dd as previously described

dd really isn't the best solution for this. You should probably look into something like rsync if you want "Quick-and-Dirty Backups." Otherwise, look into a product like Bacula to do a more full-featured backup.

With rsync, you will have file backups. In the case of a total failure, you would need to reinstall linux and then copy the rsync'd files back from the remote location.

With bacula, it does a full bare-metal backup of the system, so you can restore the entire system OS and all of your user files.

See this article for a comprehensive document explaining bare metal recovery with Bacula.

| improve this answer | |
  • Will I have to install linux back, in case of restore? – Illarion Kovalchuk Mar 15 '12 at 14:33
  • I've amended my answer to address your concern, check it and let me know if that helps. – Peter Grace Mar 15 '12 at 14:40
  • Bacula looks like something that's abusing unix way -- at the first look it seems to be too complex. – Illarion Kovalchuk Mar 16 '12 at 9:12
  • @PeterGrace sorry but I cannot understand how Bacula let you restore the full system if the system doesn't boot anymore. Image a disk failure, you replace the disk then you need to restore the system... How? Also, Bacula won't repartition your disk, won't reinstall Grub in the boot sector... Or I'm wrong? – Marco Marsala May 16 '16 at 17:50

The only easy-to-main backup solution is one that's properly done.

Spend the time to implement bacula or amanda properly and you'll avoid utter disaster.

The only thing that you accomplish above is protecting from drive failure. There's much better ways of doing so - such as mirroring the drive.

| improve this answer | |
  • Plus DD would capture the block size, partition information, etc...you risk having a problem if your replacement drive doesn't match your old drive. 1:1 cloned images of disks really works now for VM's, not so much as a robust repair for physical systems, in my experience. – Bart Silverstrim Mar 15 '12 at 14:50

Simple answer - you can do what you want by combining some tools as grub-reboot - set the default boot entry for GRUB, for the next boot only and starting system in some special runlevel (or init= kernel boot param) where custom script execute dd command. Don't do that!

Please consider tools like:

 dump - ext2/3/4 filesystem backup
 xfsdump - XFS filesystem incremental dump utility

as they can work on mounted filesystem or at least use partimage instead of dd.

partimage - back up and restore disk partitions

Only used blocks are copied and stored into an image file. You can copy data over network (with SSL) and it has many more features.

| improve this answer | |
  • Partimage is great but it doesn't support ext4, so it is in no use with me :( – Illarion Kovalchuk Mar 15 '12 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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