diff --git a/roles/shell/files/usr/local/bin/backup b/roles/shell/files/usr/local/bin/backup index fe7819d..3ce1e91 100644 --- a/roles/shell/files/usr/local/bin/backup +++ b/roles/shell/files/usr/local/bin/backup @@ -6,19 +6,19 @@ BACKUPS=/var/backups DUMPS=7 # Search for the last full backup. -LEVEL0=$(find $BACKUPS -name "*full.tgz" | sort | tail -n1) +LASTF=$(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) +INCR=$(find $BACKUPS -name "*incremental.tgz" -newer $LASTF | wc -l) # If there is at least one full backup and less than specified incremental dumps -if [ ! -z $LEVEL0 ] && [ $INCR -le $DUMPS ] +if [ ! -z $LASTF ] && [ $INCR -le $DUMPS ] then TYPE=incremental else TYPE=full rm -f $BACKUPS/*.snapshot # 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 {} \; + find $BACKUPS -name "*.tgz" ! -newer $LASTF ! -wholename $LASTF -exec rm {} \; fi nice tar -cz \