Add comments to the backup script sentences

This commit is contained in:
Blade of Darkness 2022-04-28 16:03:44 +02:00
parent 97b1fd4412
commit d1f72826e1
1 changed files with 4 additions and 1 deletions

View File

@ -5,16 +5,19 @@ DATE=$(date +%Y%m%d)
BACKUPS=/var/backups
DUMPS=7
# Search for the last full backup.
LEVEL0=$(find $BACKUPS -name "*full.tgz" | sort | tail -n1)
# Search and count incremental dumps newer than the last full backup.
INCR=$(find $BACKUPS -name "*incremental.tgz" -newer $LEVEL0 | wc -l)
# If there is at least one full backup and less than specified incremental dumps
if [ ! -z $LEVEL0 ] && [ $INCR -le $DUMPS ]
then
TYPE=incremental
else
TYPE=full
rm -f $BACKUPS/*.snapshot
# Remove dumps and the previous backup if there is another one.
# Remove the first backup set (full and incremental dumps) if there is a second one.
find $BACKUPS -name "*.tgz" ! -newer $LEVEL0 ! -wholename $LEVEL0 -exec rm {} \;
fi