Created
August 29, 2017 03:19
-
-
Save roguesherlock/c734dac3a06f7d7f517a383d4acc751f to your computer and use it in GitHub Desktop.
delete old postgres backups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOG="path/to/logs" | |
BACKUP_DIR="path/to/backupdir" | |
START_TIME=$(date +%s) | |
echo "Clean Old Backups :: ScriptStart -- $(date '+%Y-%m-%d_%H-%M-%S')" >> $LOG | |
echo "[INFO] find $BACKUP_DIR/* -name "*.gz" -mtime +30 -type f -delete" >> $LOG | |
find $BACKUP_DIR/* -name "*.gz" -mtime +30 -type f -delete >> $LOG | |
END_TIME=$(date +%s) | |
ELAPSED_TIME=$(expr $END_TIME - $START_TIME) | |
echo "Clean Old Backups :: ScriptEnd -- $(date '+%Y-%m-%d_%H-%M-%S')" >> $LOG | |
echo "Elapsed Time :: $(date -d 00:00:$ELAPSED_TIME '+%H-%M-%S')" >> $LOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment