Keep a second backup set
This commit is contained in:
parent
85f3f39383
commit
f5f15dc887
|
@ -5,7 +5,7 @@ DATE=$(date +%Y%m%d)
|
||||||
BACKUPS=/var/backups
|
BACKUPS=/var/backups
|
||||||
DUMPS=7
|
DUMPS=7
|
||||||
|
|
||||||
LEVEL0=$(find $BACKUPS -name "*full.tgz")
|
LEVEL0=$(find $BACKUPS -name "*full.tgz" | sort | tail -n1)
|
||||||
INCR=$(find $BACKUPS -name "*incremental.tgz" | wc -l)
|
INCR=$(find $BACKUPS -name "*incremental.tgz" | wc -l)
|
||||||
|
|
||||||
if [ -e $LEVEL0 ] && [ $INCR -le $DUMPS ]
|
if [ -e $LEVEL0 ] && [ $INCR -le $DUMPS ]
|
||||||
|
@ -14,6 +14,8 @@ then
|
||||||
else
|
else
|
||||||
TYPE=full
|
TYPE=full
|
||||||
rm -f $BACKUPS/*.snapshot
|
rm -f $BACKUPS/*.snapshot
|
||||||
|
# Remove dumps and the previous backup if there is another one.
|
||||||
|
find $BACKUPS -name "*tgz" ! -newer $LEVEL0 -exec rm {} \;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tar -cz \
|
tar -cz \
|
||||||
|
@ -45,8 +47,6 @@ chmod 640 $BACKUPS/{*.tgz,$TYPE.snapshot}
|
||||||
if [ $TYPE = full ]
|
if [ $TYPE = full ]
|
||||||
then
|
then
|
||||||
cp -p $BACKUPS/full.snapshot $BACKUPS/incremental.snapshot
|
cp -p $BACKUPS/full.snapshot $BACKUPS/incremental.snapshot
|
||||||
# Remove dumps and the previous backup if there is another one.
|
|
||||||
[ -e $LEVEL0 ] && rm $LEVEL0 $BACKUPS/*incremental.tgz
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Database backup
|
# Database backup
|
||||||
|
|
Loading…
Reference in New Issue