Automate daily backup of Wordpress

Hi everyone, What is the best way to back up Wordpress site automatically (daily) and upload it to google drive (preferably) or any other place?

There are a lot of backup plugins out there but I would recommend Updraftplus in your case. You should know though that configuring the free version of the plugin to work with Google Drive requires attention to detail as you follow the provided instructions. Once you have managed to configure the plugin everything is handled automatically though. Backups are done at set intervals.

I’d write a Bash script to mysqldump the database, and rsync the entire site (plus MySQL dump) to a remote location. Then you add a cronjob to launch this script every day at same hour (2AM, e.g.).

Actually I use this approach on every server of mine. I hate backup plugins, I can’t trust any of them.

Would you mind sharing this script for other EE users?

Here’s an automatic database & webroot backup script for you guys https://pastebin.com/sYsnFUpz

I spent hours with it today.

For automatic cron jobs, it needs to rsync with the other server without login prompts. You have to make a ssh key (other than the root). Also chmod the /home/user/.ssh/authorized_keys to 600: http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id

1 Like

Im using a crontab with static commands, however, your script seems good.

For those who dont know how to enable the rsync process, you will need to run these commands in order to generate the certificate and the move it to the other side:

  • ssh-keygen
  • sh-copy-id -i /root/.ssh/id_rsa.pub @ (you will be promped for 's password, just enter it)

Thanks!

Btw the link I provided for creating the ssh-key includes all the necessary info. I don’t do it so often so that’s why I have the site bookmarked :slight_smile: