forked from thunix/ansible
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
|
||||
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)
|
||||
|
||||
if [ -e $LEVEL0 ] && [ $INCR -le $DUMPS ]
|
||||
|
@ -14,6 +14,8 @@ then
|
|||
else
|
||||
TYPE=full
|
||||
rm -f $BACKUPS/*.snapshot
|
||||
# Remove dumps and the previous backup if there is another one.
|
||||
find $BACKUPS -name "*tgz" ! -newer $LEVEL0 -exec rm {} \;
|
||||
fi
|
||||
|
||||
tar -cz \
|
||||
|
@ -45,8 +47,6 @@ chmod 640 $BACKUPS/{*.tgz,$TYPE.snapshot}
|
|||
if [ $TYPE = full ]
|
||||
then
|
||||
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
|
||||
|
||||
# Database backup
|
||||
|
|
Loading…
Reference in New Issue