Advertisement
Guest User

Untitled

a guest
May 11th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #!/bin/bash
  2. # Database credentials
  3. user="mysql-username"
  4. password="mysql-password"
  5. host="server ip"
  6. db_name="database name"
  7. # Other options
  8. backup_path="/path/to/store/backup/files"
  9. date=$(date +"%d-%b-%Y")
  10. # Set default file permissions
  11. umask 177
  12. # Dump database into SQL file
  13. mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql
  14. # Delete files older than 30 days
  15. find $backup_path/* -mtime +30 -exec rm {} \;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement