[ILUG] tar + cdrecord...
kevin lyda
kevin at suberic.net
Mon Sep 3 04:26:26 IST 2001
i'm finally getting around to implementing real backups at home.
copying some files to multiple hd's doesn't really count i guess.
i'm using a cdr as the backup device and i'm wondering if anyone has ever
just dumped a tar file directly to cdrecord - skipping the mkisofs step.
mkisofs is better for multisession cd's i suppose so i'll go with that
in the end i suppose, but just wondering if anyone has done it.
i've enclosed the backup script so far. i haven't implemented incremental
backups yet - well i have but they aren't tested. the idea is to get
a list of all the rpms and put them where they'll be backed up (i put
them in ~root). then get a list of all the files managed by rpm and cut
that list down to the files that haven't changed. then get a list of
the files in all the dirs i care about, remove the files manged by rpm
(that i haven't changed), and then back those files up.
for incrementals i'll compare those files to a touch file created at
the start of the last backup and only back up the ones that are newer.
anyway, someone might find it useful. the nice thing is that restoring
the system is as simple as reinstalling it, getting the list of rpms
that were there before, installing all of them, and that doing a tar
Ixpf of the tarfile.
kevin
---- snip here ----
#!/bin/sh
PRUNE_LIST="/dirs/to/prune /like /dev /or /proc"
EXCLUDE='some|files|to|egrep -v|off|the|list'
LAST_BACKUP_TOUCH=/u5/backup.last
RPM_LIST=/root/rpm.list
RPM_VA=/var/tmp/bkup.rpm.changed
RPM_QAL=/var/tmp/bkup.rpm.list
FIND_PRUNE=/var/tmp/bkup.file.find
RPM_VIRGIN=/var/tmp/bkup.rpm.unchanged
FTB=/var/tmp/bkup.files.to.backup
BACKUP_TARBALL=/u5/backup
echo "Backup begins"
touch $LAST_BACKUP_TOUCH.tmp
echo "Generating RPM list"
rpm -qa | sort > $RPM_LIST.tmp 2> /dev/null
if cmp -s $RPM_LIST $RPM_LIST.tmp; then
rm $RPM_LIST.tmp
else
mv $RPM_LIST.tmp $RPM_LIST
fi
echo "Generating list of unchanged rpm files"
rpm --noscripts --nomd5 --nodeps --verify --all | grep '^S' | \
sed 's-^[^/]*/-/-' > $RPM_VA 2> /dev/null
rpm -qal | sort -u > $RPM_QAL 2>/dev/null
sort $RPM_VA $RPM_VA $RPM_QAL | uniq -u > $RPM_VIRGIN
echo "Generating list of all files that are in interesting directories"
for d in $PRUNE_LIST; do
PRUNE="$PRUNE -path $d -prune -o"
done
PRUNE="$PRUNE -path /home/ftp -prune"
if [ -f $LAST_BACKUP_TOUCH ]; then
NEWER="-newer $LAST_BACKUP_TOUCH"
else
NEWER=""
fi
find / \( $PRUNE \) -o $NEWER -print > $FIND_PRUNE
echo "Generating list of files that will need to be backed up"
sort $RPM_VIRGIN $RPM_VIRGIN $FIND_PRUNE | uniq -u |
egrep -v "$EXCLUDE" > $FTB
echo "Generating backup image"
tar -S --no-recursion -I -c -P -p -T $FTB \
-f $BACKUP_TARBALL.`date +'%Y-%m-%d.%H:%M:%S'`.tar.bz2
echo "Cleaning up"
rm -f $RPM_VA $RPM_QAL $FIND_PRUNE $RPM_VIRGIN
mv $LAST_BACKUP_TOUCH.tmp $LAST_BACKUP_TOUCH
---- snip! ----
--
kevin at suberic.net simple four line sigs -
fork()'ed on 37058400 bandwidth friendly; nice to do.
meatspace place: home some admins clueless.
http://suberic.net/~kevin --netiquette haiku 2001
More information about the ILUG
mailing list