Last active
November 19, 2018 05:58
-
-
Save i-sync/7f442841e8e44dd6627631e92a558a8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Database credentials | |
| user="xxx" | |
| password="xxx" | |
| host="xxx" | |
| db_name="xxxx" | |
| # Other options | |
| backup_path="/data/backup/mysql" | |
| d=$(date +"%F-%T") | |
| # Set default file permissions | |
| umask 177 | |
| # Dump database into SQL file | |
| mysqldump --user=$user --password=$password $db_name > $backup_path/$db_name-$d.sql | |
| # Delete files older than 30 days | |
| find $backup_path/* -mtime +30 -exec rm {} \; | |
| #scp to remote server | |
| sshpass -p "xxxx" scp $backup_path/$db_name-$d.sql xxx@domain.com:/path/backup/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment