Jul 29 2012
Automating WordPress Backups on Godaddy
If you have ever tried to backup a wordpress site on godaddy you are in for a treat, I decided to write this article in case I ever needed to go through this again and in the hopes that it may help someone else. If you’re like me, you have one or more wordpress sites that you would like to ensure are backed up before a disaster occurs and rather than use wordpress plugins which may break due to software upgrades I’d rather roll my own that leverages cron, tar, and scp.
Turn on SSH
If you want to test out your backup script before you add it to cron you will need to activate SSH. Godaddy doesnt have ssh on by default so you have to enable it. To do this go to the “Hosting Control Center” and select “SSH” under the “Settings” menu.
From here you can click the “Enable” button to turn on ssh access. SSH will use the same FTP username and password you have configured for the godaddy account. You should be able to connect using any ssh client, for you windows users I recommend putty. Once you have logged in you should be at a bask prompt. I should note that if you have an ultimate hosting account and are hosting more than one website you should be ssh’ing to the primary domain which is under “Settings” and “Hosted Domains”.
There are a million different ways to skin this cat, for me I like Godaddy’s built in file restore and database backup but always want to make sure I have a full off-site backup just in case. To accomplish this I will run a weekly cron job to back up all wordpress sites and the associated databases so that in case of an emergency they can be restored to Godaddy or even another hosting provider. The script below is an example of the script I run, you will need to customize this based on your environment.
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/bash DATE=`date +%m%d%y` /usr/bin/mysqldump -h databasehostaddress.db.hostedresource.com -u databaseusername -pdatabaseuserpassword databasename > $HOME/html/_db_backups/daily/databasename.$DATE.sql cp -r $HOME/html/wordpressfolder $HOME/html/_db_backups/daily # Zipping directory structure... tar -cvzf $HOME/html/_db_backups/$DATE.tar.gz $HOME/html/_db_backups/daily/* # Cleansing backup folder rm -r $HOME/html/_db_backups/daily/* |
To run this script you will need to create the _db_backups directory as well as the daily subdirectory otherwise the primitive script will fail. Using the FTP file manager from godaddy you should be able to create the backup.sh script file under the _db_backups folder. You will also need to mark it as executable so it may run. In FTP File Manager just click the check box of the shell script file and “permissions” at the top and make sure executable is checked you will see a additional graphic next to the file once you apply the change.
Now you are ready to create a Cron Job for your shell script to execute. To diagnose any errors you may get make sure when creating the Cron Job you include an email address for the errors to be delivered. Enable the Cron Job and change the Frequency to “Weekly” and Minute to whatever is closest for the script to execute.




Apr 15 2014
Creating Self Signed Certificates
Have you ever created a self-signed certificate and then seen the following errors in the apache error log?
Well this is likely because you are using a certificate that is used to sign other certificates as your SSL cert rather than using a cert that is just for SSL. The remainder of this document will walk you through the correct steps to generating a self-signed certificate. This guidance is based on the instructions provided by Heroku.
The openssl library is required to generate your own certificate. Run the following command in your local environment to see if you already have openssl installed installed.
2
/usr/bin/openssl
If you have openssl installed, the first step is to generate a private key and certificate signing request.
2
3
4
5
6
7
8
9
10
$ sudo openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
// Removes password from RSA private key
$ sudo openssl rsa -passin pass:x -in server.pass.key -out server.key
// Remove the original private key
$ sudo rm server.pass.key
// Certificate Signing Request
$ sudo openssl req -subj /C=US/ST=Virginia/L=Alexandria/O=IT/CN=www.openfisma.org -new -key server.key -out server.csr
// Self-signed certificate generated from server.key private key and server.csr
$ sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
By James Ford • Apache, SSL, System Administration 0