Created
October 25, 2012 12:23
-
-
Save johanmeiring/3952290 to your computer and use it in GitHub Desktop.
Backup file rotation
This file contains 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 | |
DEST=/root/BACKUPS | |
# Code to actually create backup files goes here... | |
# Check if we need to rotate the backup files. | |
FC=`ls ${DEST}/*.tar | wc -l` | |
if [[ $FC -gt 6 ]]; then | |
echo "Too many backup files. Deleting oldest one..." | |
DELETE_FILE=`ls -tr ${DEST}/*.tar | head -1` | |
rm $DELETE_FILE | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment