Last active
December 1, 2015 02:17
-
-
Save mick-shaw/8aebb6ec102bdf0941b5 to your computer and use it in GitHub Desktop.
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 | |
| # This backup script will delete files in a directory defined as $bkupdir. | |
| # It will only delete files if there is a minimum number off files defined as $filecounter | |
| # If there are at least the minimum number of files in the defined backup directory, | |
| # it will check the age of files defined as $daycounter. Any files with a timestamp | |
| # that is X days old will be deleted. | |
| # Set the minimum number of backups that should remain | |
| filecounter=10 | |
| # Set the backup directory to check | |
| bkupdir='/home/sftpadmin/backups/cm/' | |
| # Set how many days old backups must be for deletion | |
| daycounter=9 | |
| # This variable should not have to change | |
| bkup=$(/bin/find "$bkupdir" -type f | wc -l) | |
| if [ $bkup -ge $filecounter ]; then | |
| /bin/find "$bkupdir" -type f -mtime +$daycounter -exec rm -rf {} \; | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment