Ubuntu – How to make a full backup of an ubuntu root server with tar

backupdumprestoreUbuntu

I am running ubuntu 10.04 LTS on a remote root server and almost the same setup on a development server over virtualbox. My goal is to backup the remote root server to an ftp-account. In case the hard drive failes I would then boot from a rescue system and install the backup. I looked into partimage, but that unfortunatelly does not support exclude folders and the drive in question contains about 200GB of Data I do not want to backup.

So I tried it with tar:

mkdir /mnt/system
mount /dev/sda1 /mnt/system
cd /mnt/rescue
tar cvzpf image.tar.gz ./ --exclude=image.tar.gz --exclude=unwanted_folder

This worked, but obviously the boot sector is not included. So I am left with a copy that does not help to make a full server restore.

The server looks like this:

/home$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md2             1016G  4.9G  960G   1% /
none                   16G  220K   16G   1% /dev
none                   16G     0   16G   0% /dev/shm
none                   16G   72K   16G   1% /var/run
none                   16G     0   16G   0% /var/lock
none                   16G     0   16G   0% /lib/init/rw
/dev/md3              1.7T  267G  1.4T  17% /home
/dev/md1              496M   69M  402M  15% /boot

What would be the best way to do a full backup to an image or tar with the option of excluding special folders inside /home ?

Thank you for any help.

Best Answer

You can use dd to backup MBR

dd if=/dev/sdX of=/tmp/sda-mbr.bin bs=512 count=1

to restore use

dd if= sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446 seek=446

Replace X with actual device name such as /dev/sda.

Related Topic