Use System Center Orchestrator to Backup a Hosted WordPress

I recently had some issues with my hosted WordPress (this blog) being hacked. So I wanted to start backing up a local copy and I did not want to do this all manually. A friend of mine (a fellow MVP Islam) also needed something like this for his blog because recently the hosting provider of his WordPress site deleted the entire thing!

WordPress on the backend consists of a database and a folder with the actual site files in it. I needed a way to back up the database and the site files. My WordPress database runs on MySQL. I needed a way to do a MySQL Dump of the database. Then the dump needed to be placed into a specific folder before downloading it. So to sum this up I need to somehow backup the MySQL database for my site, place this somewhere so it can be downloaded, delete the previous database file so that disk space is not being wasted before future dumps, then zip my blog files and download both the zip and MySQL Dump.

I was excited about this project because when I set out to accomplish I knew I would look to System Center first to help me out. Just my luck I am able to accomplish everything I need with System Center Orchestrator (SCORCH).

Here is a summary of how SCORCH will accomplish the task:

  • SCORCH will connect to the web server via SSH
  • SCORCH will issue a command that will remove any previous MySQL backups of my database
  • SCORCH will issue a MySQL command to back up the database to a specific folder
  • SCORCH will check for a previous .zip of my blog files and remove it if it is there
  • SCORCH will create a new .zip of my website files
  • SCORCH will connect to the web server via FTP and download the database and download the .zip of my blog

Before doing this you need a couple of things setup on your web server and depending on your host some of these options may not be available. Here is what you need:

  • You need a static IP so that you can access SSH remotely (Some hosts will give you a FQDN to connect to instead)
  • Then you need SSH turned on and configured (Make sure this is secured.)
  • Create a folder for your MySQL database backups
  • You need an FTP account setup to access your MySQL backups and the website files remotely

Ok now let’s jump into the actual setup of this in SCORCH.

Go download and deploy the FTP Integration Pack for SCORCH.

Here is the link:

Register the integration pack and deploy it to your Runbook server. Once you have the FTP integration pack in your SCORCH go to the SCORCH Runbook designer and setup the FTP account for your host. This can be found under Options>>FTP.


You just need to click Add and then input your FTP settings. Click OK when done and your FTP connection will be listed under Configurations. Click Finish.


The next thing you need to do is create the Runbook. You will be using the System (Run SSH Command) and FTP (Download File) Activities.



Go ahead and setup your Runbook like so:


Here are the SSH commands you will need in those SSH Activities:

  • (Remove Old MySQL Dump)

rm www/mysqlbackup/YOURSITEDBNAMEHERE.sql

  • (MySQL Dump)


  • (Remove Old QP Zip)

rm www/

  • (Make New WP Zip)

zip -r www/ www/

You could technically put these commands in a Linux script file (.SH) and use one SSH activity by referencing the .SH file in the Command Set File field. For my scenario I wanted to break it out into parts in case something failed. I could then troubleshoot each SSH command separately.

Here are a couple of screenshots of what your settings should look like in the SSH command activities:



Ok. Now let’s look at the properties of the FTP download activities. Something to note here is that SCORCH can download files but not folders. This is the reason we had to use SSH to Zip the folder before we can download it.

Below is a screenshot with the settings I used on the FTP download activity. There are other settings I did not need but you might depending on your host.


NOTE that I placed a Send Email activity at the end of my Runbook that sends me an email when it completes. This is optional.

Once you finish configuring your Runbook activities go ahead and run the Runbook through the Runbook Tester to make sure it all works. NOTE this will actually perform the steps on your LIVE webserver so make sure you are ready for that.

Ok, as long as the Runbook passed the Runbook Tester we will put the finishing touches on this by adding a schedule in the Runbooks properties.


Now your Runbook should run on a schedule and get a local copy of your WordPress blog. 🙂

One last thing to note: if your company hosts a website with a web hosting company this same method can be used to have SCORCH pull down a local copy for an added backup. The hosting provider may already be doing backups but it never hurts to have more. This method should also work with sites that are hosted on other platforms such as Drupal, Joomla, etc… and with other databases as well such as PostgreSQL.

Print Friendly, PDF & Email

1 thought on “Use System Center Orchestrator to Backup a Hosted WordPress”

  1. Pingback: URL

Leave a Comment