Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## Specify a prefix for the database backup files
- SERVERNAME="myServer"
- ## Specify how long to keep the backups
- DAYS="30"
- ## Specify database credentials
- USER="username"
- PASSWORD="password"
- ## dump and compress all databases to a backup location, add the date to the file name
- mysqldump -u$USER -p$PASSWORD --all-databases | gzip > /home/backupbot/MySQL_Backup/$SERVERNAMEDatabases_$(date +'%m-%d-%y').sql.gz
- ## remove backup files older than 30 days
- find /home/backupbot/MySQL_Backup -type f -name '$SERVERNAME*' -mtime +$DAYS -exec rm {} \;
Add Comment
Please, Sign In to add comment