Created
December 21, 2022 12:29
-
-
Save juliavdkris/841518c31162ca5bfcc344f6bdf46b96 to your computer and use it in GitHub Desktop.
Cyclic backup script
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 | |
| DIR=/srv/backups/prime-server/recent | |
| PRESERVE_COUNT=30 | |
| # Delete all but the 30 latest backups | |
| find $DIR -type f -printf '%T+\t%p\n' | sort | cut -f2 | head -n -$PRESERVE_COUNT | xargs -r rm -v | |
| # Create a new backup | |
| mysqldump primeserver > "$DIR/`date +\%d-\%m-\%Y`-primeserver.sql" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment