I'm looking for a backup tool for ext4 which can take a copy from a running filesystem like /var with no collisions in the system after recovering such a filesystem. I know BSD dump has an '-L' option, which tells him to work on a snapshot. But neither dump nor dumpe2fs from repositories have such an option. I've read about a patchset for ext4 providing snapshot support, but replies about it are very different, so I'm here to ask about your experience with this patchset.
3 Answers
dump
does not need a switch to work on a snapshot. Just make the snapshot with LVM, and dump it.
I have a nightly cron job that does just that, using a 5 level tower of hannoi backup pattern. This means I only have to do a full backup every several months when I feel like the level 1 dumps dumps are getting too large. Level 1 dumps are made on the 1st and 17th of the month.
#!/bin/bash
set -e
declare -a LEVELMAP=(1 5 4 5 3 5 4 5 2 5 4 5 3 5 4 5 1 5 4 5 3 5 4 5 2 5 4 5 3 5 4 5)
DATE=`date +%-d`
LEVEL=${LEVELMAP[$DATE-1]}
echo Performing a level $LEVEL dump
/etc/init.d/apache2 stop
sync
lvcreate -s -n snap vg0/root -L 400m
/etc/init.d/apache2 start
dump -$LEVEL -quz9 -b 1024 -f /backup/dump.$LEVEL /dev/mapper/vg0-snap
lvremove -f vg0/snap
-
-
2@user685107, then your backup will contain corrupted files if they were being modified at the time the snapshot was taken. You need to ensure that files aren't being written to for a correct backup; the purpose of snapshots is that you only need to do so for the moment it takes to make the snapshot, instead of the whole time it takes to make the backup.– psusiAug 25, 2011 at 15:30
-
That's ugly LVM-way. Current filesystems have better support of snapshots, but they don't guarantee stability i need.– tijagiAug 28, 2011 at 13:38
-
2@user685107, generally no, they don't support snapshots. Btrfs and ZFS do, but neither are ( yet ) considered stable and supported, and you asked specifically about ext4. Regardless of whether it is done in the block layer or the filesystem, it is impossible to get a consistent snapshot while your applications are writing, so they must either be shut down, or placed into a temporary read only mode while the snapshot is taken. Most database engines support a temporary read only mode for this purpose.– psusiAug 29, 2011 at 13:45
-
update: FreeNAS recommends ZFS, I think it's pretty stable and tested today.– PaoloDec 17, 2013 at 17:07
Try amanda backup. It's a complete backup tool and works on a variety of platforms/architectures
Have you considered RSync for this purpose? There is a really great article here on how to setup snapshot-style backups with rsync in linux from scratch. Another alternative, also based on rsync, but a little more baked, is rsnapshot.
-
3You can't make a snapshot with rsync. A snapshot is an atomic operation that creates a copy of the state of a whole set of files at a precise instant. rsync creates a copy of a tree, but it reads different parts of the tree at different times. For example, if a file is moved while rsync is traversing the tree, the file could be present twice or never in the copy. Aug 23, 2011 at 21:43
-
I'm agree with @Gilles, rsync doesn't suit in this case. I think about XFS, it has native snapshot support.– tijagiAug 25, 2011 at 15:12