Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Database credentials
- # Getting username and password from .my.cnf
- # [mysqldump]
- # password=PASSWORD
- # user=USERNAME
- host="localhost"
- db_name="NAME"
- # Other options
- backup_path="/path/to/backups"
- date=$(date +"%Y-%m-%d")
- # Set default file permissions
- umask 177
- # Dump database into gzipped SQL file
- mysqldump --host=$host $db_name | gzip > $backup_path/$db_name-$date.sql.gz
- # Delete files older than 30 days
- find $backup_path/* -name *.sql.gz -mtime +30 -exec rm {} \;
Add Comment
Please, Sign In to add comment