Translate this page :

WordPress Auto-Backup via SSH

This script will enable you to backup your WordPress websites automatically. Just put it in a crontab / automatic scheduling software somewhere.

Also available on Pastebin : https://pastebin.com/nZ2fiL8j

Enjoy.

=====
#!/bin/bash

### 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/

wordpress_server=MyUser@MyServer.com
wordpress_location=/home/MyUser/MyWebsite
backup_location=/MyDisk/MyBackup

mysql_server=mysql.MyWebsite.com
mysql_database=MyDatabase_db

# ====== 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 --delete $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 !

5 Responses to “WordPress Auto-Backup via SSH

Leave a Reply

 

Subscribe without commenting

            








SEObox: Web Hosting Murah Unlimited Komik Indonesia Homeschooling Indonesia