I make a backup of my Debian webserver on a daily basis. A full backup on Sunday, and differentials each other day of the week.
The backup is made with Tar. I backup the whole system into the Tar file.
If the HDD on my webserver dies, I got all my backups in a safe place.
But what would be the best way to do a Bare Metal Restore on a new HDD with a differential backup make the previous day? Can I boot with a boot cd, and then format a new HDD and untar the backup file into it? How do I do that exactly?
EDIT:
This is my backup script:
#!/bin/sh
# Backup script
BACKUPDIR="/backups"
BACKUPFILE=$BACKUPDIR/backup_$(date +%y-%m-%d).tgz
if [ ! -d $BACKUPDIR ]; then
mkdir $BACKUPDIR
fi
if [ -f $BACKUPFILE ]; then
echo "Backup file already exists and will be replaced."
rm $BACKUPFILE
fi
apt-get clean
tar czpf $BACKUPFILE --same-owner \
--exclude=$BACKUPDIR \
--exclude=/boot/grub/menu.lst* \
--exclude=/home/error.log \
--exclude=/proc \
--exclude=/media \
--exclude=/dev/* \
--exclude=/mnt \
--exclude=/sys/* \
--exclude=/cdrom \
--exclude=/lost+found \
--exclude=/var/cache/* \
--exclude=/tmp / 2>/home/error.log
Simply restoring the HDD will not be enough, you're probably will want your boot record too which I hardly believe exists in your backup (am I wrong?, it's better for you if i do!)...
Lest assume you got the server to the point it can boot (i personally prefer creating the additional partition mounted to
/boot
which will havekernel
andinitrd
withbusybox
or something similar to allow you basic maintenance tasks). You can also use a live CD of your Linux distribution.Mount your future
root partition
somewhere and restore your backup.tar
was created for tapes so it support appending to archive files with same name. If you used this method justuntar -xvpf backup.tar -C /mnt
if not you'll need to restore "last sunday" backup and applying deferential parts up to needed day.You should keep in mind that there is a lot of stuff that you should not backup, things like:
/proc
,/dev
,/sys
,/media
,/mnt
(and probably some more which depend on your needs). You'll need to take care of it before creating backup, or it may became severe pain while in restore process!There is many points that you can easily miss with that backup method for whole server:
Some good points on that exact method can be found on Ubuntu Wiki:BackupYourSystem/TAR. Look for Restoring.
BTW:
puppet
orchief
, so only thing you should care about is real data)P.P.S
I recommend reading couple of Jeff Atwood posts about backups http://www.codinghorror.com/blog/2008/01/whats-your-backup-strategy.html and http://www.codinghorror.com/blog/2009/12/international-backup-awareness-day.html
Have a look at http://www.mondorescue.org/ as it can do online backups without shutting down the machine.
if differential backups are not mandatory, the best option for baremetal backup/restore is ddrescue : http://www.gnu.org/software/ddrescue/ddrescue.html