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: http://technet.microsoft.com/en-us/library/hh295851.aspx
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: