Updated June 04, 2004
Created June 04, 2004


Autogenerated Site Map
Search this Site!:
Search this site powered by FreeFind

Re-syncing a snapshot directory... when it gets off track:

The following will sync up dated snapshot directories that
are configured as YYYYMMDD. They come out in order when
doing a simple ls.
cd /snapshots/cpqlinux.com/
df -h .
df -h . | grep -v Filesystem | awk '{print $4}' | grep G || exit
                                                                                                                             
LIST=`ls -d [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]`
                                                                                                                             
for X in `seq 1 \`expr \\\`echo "$LIST" | wc -l\\\` - 1 \``; do
    echo "$LIST" \
        | sed --silent $((X++)),${X}p \
        | tr '\n' ' '
    echo
done | while read PREV CURR; do
    rsync -av --link-dest=../$PREV/ ./$CURR/ ./$CURR-n/
    mv ./$CURR ./$CURR-delete
    mv ./$CURR-n ./$CURR
    rm -rf ./$CURR-delete &
done
Note: Do not put a trailing slash on the rm -rf $CURR unless
you put a check for $CURR being blank. If you're not careful
then you'll wind up performing an rm -rf of root which would
be more than just a litle counter-productive. On a positive
note you'll have plenty of free space afterwards ;-) Thank
goodness I didn't actually execute the code when I had it in
that state... Ok, I've added a ./ before each of the dirs
which should help any accidents you might have when attempting
to modify this script.

Search this Site!:
Search this site powered by FreeFind

Homepage: http://www.cpqlinux.com
Site Map: http://www.cpqlinux.com/sitemap.html