Wordpress Auto-Backup via SSH
sufehmi Feb 18th, 2018 (edited) 196 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- ### THIS SCRIPT ASSUMES THE FOLLOWING
- # 1/ You can do SSH password-less login to the server
- # How : https://easyengine.io/tutorials/linux/passwordless-authentication-ssh/
- # 2/ You have created a correct ~/.my.cnf file
- # How : https://easyengine.io/tutorials/mysql/mycnf-preference/
- # ====== START BACKUP ============
- today=`date +%A`
- # backup database
- ssh $wordpress_server "mysqldump -h $mysql_server $mysql_database > $wordpress_location/db-$today.mysql"
- ssh $wordpress_server "gzip $wordpress_location/db-$today.mysql"
- # download everything
- rsync -avuz $wordpress_server:$wordpress_location/* $backup_location/
- # delete database backup
- # so no one can download it via the website
- ssh $wordpress_server "rm $wordpress_location/db-$today.mysql.gz"
- # done !
RAW Paste Data