Add checking if we have enough backups

Signed-off-by: Amy Aronsohn <WagThatTail@Me.com>
This commit is contained in:
Amelia A 2018-11-08 12:51:41 -08:00
parent 962e2e75aa
commit d1675d1df5
Signed by: amy
GPG Key ID: 70C320ABA95D38C1
1 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,15 @@
#!/usr/bin/env bash
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
BACKUP_DIR="$CURRENT_DIR/backups"
/usr/bin/find "$CURRENT_DIR/backups" -mtime +5 -name "gitea-dump-*.zip" -exec /bin/rm '{}' \;
##
# Verify there is at least 5 backups
BACKUPS=$(/usr/bin/find "$BACKUP_DIR" -name "*.zip" -print | wc -l)
if (( BACKUPS < 5 )); then
echo "There is less than five backups so we won't prune!"
exit 1
fi
/usr/bin/find "$BACKUP_DIR" -mtime +5 -name "gitea-dump-*.zip" -exec /bin/rm '{}' \;