Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Database login credentials - need to be changed accordingly
  4. dbHost="***"
  5. dbName="**"
  6. dbUser="***"
  7. dbPass="***"
  8.  
  9. #How many days the backups should be kept for before being removed
  10. keepBackupsFor="30"
  11.  
  12. if [ ! -d ~/additional_backups ]; then mkdir ~/additional_backups; fi
  13.  
  14. curTime=$(date +"%m-%d-%y_%H:%M")
  15.  
  16. mysqldump -h ${dbHost} -u ${dbUser} -p${dbPass} ${dbName} > ~/additional_backups/${curTime}-sql_backup.sql
  17.  
  18. find ~/additional_backups -type f -ctime +${keepBackupsFor} -exec rm -f {} \;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement