Skip to content

Instantly share code, notes, and snippets.

@juliavdkris
Created December 21, 2022 12:29
Show Gist options
  • Select an option

  • Save juliavdkris/841518c31162ca5bfcc344f6bdf46b96 to your computer and use it in GitHub Desktop.

Select an option

Save juliavdkris/841518c31162ca5bfcc344f6bdf46b96 to your computer and use it in GitHub Desktop.
Cyclic backup script
#!/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