Saturday, August 14, 2010

Granny Flat Floor Plans

Backup with Tar

To back up a directory or an entire disk, it can be very convenient to use the tar command:

Carry my script I used when I wanted to make a full backup of all my Gentoo (all partitions).
After booting with a bootable CD of Gentoo, Invoke the following script that created a full backup of the whole disk (partition for / home / roby only the configuration directory ... I did not care to back up throughout the home).
backup of each partition was created with a separate file, using a single prefix for the name of file and, as a suffix, date of creation.
It was also created another backup of the / etc directory separately, so you can access the configuration file without having to handle the largest of the backup.
messages output from the executed commands are stored in a log file separately.

NB: note that the directory / mnt / gentoo / backup (previously created) should not be considered when creating the backup!

# / bin / bash
cd / mnt
mount / dev/hda2 / mnt / gentoo / boot
mount / dev/hda6 / mnt / gentoo / var
mount / dev/hda5 / mnt / gentoo / home

if [$? ! = 0];
then echo "ERROR:"
exit -1 fi


cd / mnt / gentoo
PREFISSO_FILE = "/ mnt / gentoo / backup / distroBack"
FILE_LOG = "$ PREFISSO_FILE.log"
EST_TAR = ". Tar.gz"

DATA_START = $ ( date "+% Y% m% d_% H-% M-% S")


pwd echo "Backup etc ..."
echo "Backup etc ..." > $ FILE_LOG
tar-czpf $ PREFISSO_FILE "_etc__" $ (date "+% Y% m% d_% H-% M-% S") $ EST_TAR / mnt / gentoo / etc / * 2> & 1 - {Exclude = / mnt / gentoo / home, / mnt / gentoo / backup / mnt / gentoo / usr / portage / distfiles} / mnt / gentoo / * 2> & 1 $ FILE_LOG
echo "Backup start:" $ DATA_START>> $ FILE_LOG
echo "Backup end:" $ (date "+% Y% m% d_% H-% M-% S")>> $ FILE_LOG


cd / mnt
umount / mnt / gentoo / home
umount / mnt / gentoo / var
umount / mnt / gentoo / boot
umount / mnt / gentoo

echo "KILL ..."

poweroff exit 0




0 comments:

Post a Comment