Backing up WordPress database and files

The way that I backup our site is two-fold. Via our web host (rackspace) and manually every time I write any code for the site. DISCLAIMER: this is just what I do by habit, I don’t claim it’s the best or only way to do it. Just sharing.

Firstly your provider may have an automated way to create a server image schedule.

Look into your server settings on your Server Control panel or contact them directly. It may be a paid option but often means you can schedule a weekly /daily / monthly image (like a snapshot) of your server which you can easily restore from.

Secondly you can do it through your (S)FTP program & terminal.

I usually just make a compressed .tar.gz version of my wordpress root folder, rather than the individual folders as is easier to copy across. You can use your (S)FTP client for this.

Once that is done I log into the CMS on my terminal using:

ssh -l cms IP ADDRESS like (13.14.9.10)

Put your password

Then

mysqldump -u root -pROOTPASSWORD DATABASENAME > DATABASEBACKUP.db.dump.sql

Which puts a nice .sql file into your CMS folder to copy across in the (S)FTP client.