mirror of
https://github.com/ThunixdotNet/ansible.git
synced 2026-01-24 13:40:17 +00:00
Keep a second backup set
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user