How to backup your root filesystem gracefully

If I say backup I usualy mean dumping a whole filesystem, a content of a partition.
If other filesystems are already mounted to this filesystem, the "tar" will pack them as well. There are some magic switches for tar to stay on one filesystem, but then folders hidden by the mount will skipped.

My solution follows.
Mount the filesystem with option "bind", and dump the binded folder.

# mkdir /mnt/rootfs
# mount / /mnt/rootfs -o bind
# cd /mnt/rootfs
# tar cjf /mnt/backup/rootfs.tar.bz2 .
# umount /mnt/rootfs

Where /mnt/backup is an other partition.

It is also a good idea to duplicate your root partition to an other partition located on a secondary disk. In case an emergecy you can boot your system from that disk. Note that you should make that secondary disk bootable with a proper boot option. "/etc/fstab" should also be modified.

Do duplicate your root filesystem classicaly do this. Let's say that the mirror partition is /dev/sdb2, which can be completely cleared from data.

# mkfs.ext3 /dev/sdb2
# mount /dev/sdb2 /mnt/mirror
# mount / /mnt/rootfs -o bind
# cd /mnt/rootfs
# tar cf - . | ( cd /mnt/mirror; tar xpf - )
# umount /mnt/rootfs
# mount /mnt/mirror

Hozzászólások

En a mirrorra rsync-et hasznalnek, vagy csinalnek vmi exclude file-t. /tmp, /var/tmp, /var/cache - ezekrol nincs ertelme backupot csinalni.
--


()=() Ki oda vagyik,
('Y') hol szall a galamb
C . C elszalasztja a
()_() kincset itt alant.

A tar miota dump? Latszik hogy linuxon csak ganyolni lehet.

A "cp -R" nem szabványos unix parancs, illetve régebben bugos is volt, így a rendszergazdák képzeletbeli kézikönyvébe a tiltó listára tenném az "mc"-vel együtt. (Oké, oké, a mount-bind sem szabványos.)

Az rsync jó öttlet, de számomra egy kicsit mágia a működése. Lehet, hogy konzervatív vagyok, de nem biztos, hogy biztosnági másolatot rsync-kel csinálnék.

Thuglife: Köszönjük, majd értesítjük.

Kimaradt a címből, hogy linuxon!

Ave, Saabi.