Browse Source

Add checking if we have enough backups

Signed-off-by: Amy Aronsohn <WagThatTail@Me.com>
main
Amelia A 3 years ago
parent
commit
d1675d1df5
Signed by: amy GPG Key ID: 70C320ABA95D38C1
  1. 12
      backup_prune

12
backup_prune

@ -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 '{}' \;

Loading…
Cancel
Save