Guest User

Untitled

a guest
Jan 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ## Specify a prefix for the database backup files
  4. SERVERNAME="myServer"
  5. ## Specify how long to keep the backups
  6. DAYS="30"
  7. ## Specify database credentials
  8. USER="username"
  9. PASSWORD="password"
  10.  
  11. ## dump and compress all databases to a backup location, add the date to the file name
  12. mysqldump -u$USER -p$PASSWORD --all-databases | gzip > /home/backupbot/MySQL_Backup/$SERVERNAMEDatabases_$(date +'%m-%d-%y').sql.gz
  13.  
  14. ## remove backup files older than 30 days
  15. find /home/backupbot/MySQL_Backup -type f -name '$SERVERNAME*' -mtime +$DAYS -exec rm {} \;
Add Comment
Please, Sign In to add comment