Add checking if we have enough backups
Signed-off-by: Amy Aronsohn <WagThatTail@Me.com>
This commit is contained in:
parent
962e2e75aa
commit
d1675d1df5
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…
Reference in New Issue