Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm looking for a backup tool for ext4, which can take a copy from a running FS like /var with no collisions in system after recover such FS. I know BSD dump has an '-L' option, which tells him to work on a snapshot. But nor dump nor dumpe2fs from repositories have such 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 patches.

share|improve this question
add comment

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
share|improve this answer
    
I cannot stop apache or any other daemon for taking a snapshot. –  tijagi Aug 25 '11 at 15:08
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. –  psusi Aug 25 '11 at 15:30
    
That's ugly LVM-way. Current filesystems have better support of snapshots, but they don't guarantee stability i need. –  tijagi Aug 28 '11 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. –  psusi Aug 29 '11 at 13:45
    
update: FreeNAS recommends ZFS, I think it's pretty stable and tested today. –  Guandalino Dec 17 '13 at 17:07
add comment

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.

share|improve this answer
3  
You 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. –  Gilles Aug 23 '11 at 21:43
    
I'm agree with @Gilles, rsync doesn't suit in this case. I think about XFS, it has native snapshot support. –  tijagi Aug 25 '11 at 15:12
add comment

Try amanda backup. It's a complete backup tool and works on a variety of platforms/architectures

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.