WordPress Backup on CentOS

Now that I’ve moved my website over to CentOS, I’ll be showing you how I do backups.

My Setup

  • VirtualBox – CentOS web server running WordPress
  • iMac – connected Drobo


  • Run daily mysql backups
  • Run weekly website backups
  • Only keep the latest two backups
  • Run daily rsync’s to my Drobo from my iMac

CentOS — Create a backup directory within your home folder

mkdir -p /home/tommy/backup/itsmetommy.com

CentOS — Backup MySQL Database

How to run it manually.

/usr/bin/mysqldump -u tommy -psupersecretpassword itsmetommy > /home/tommy/backup/itsmetommy.com/itsmetommy_$(date '+%Y%m%d-%H%M%S').sql

CentOS — Backup Website Directory

How to run it manually.

/bin/tar -czvf /home/tommy/backup/itsmetommy.com/itsmetommy_$(date '+%Y%m%d-%H%M%S').tar.gz -C /var/www/ itsmetommy.com

You can see that both files are located in /home/tommy/backup/itsmetommy.

ls -l /home/tommy/backup/itsmetommy.com
total 6731528
-rw-r--r-- 1 root root 9927065 Dec 25 21:55 itsmetommy_20151225-215541.sql
-rw-r--r-- 1 root root 6883148434 Dec 25 22:04 itsmetommy_20151225-215602.tar.gz

CentOS — Setup cron

No one wants to run backups manually, so lets add these commands as a cronjob.

crontab -e
@daily /usr/bin/mysqldump -u tommy -psupersecretpassword itsmetommy > /home/tommy/backup/itsmetommy.com/itsmetommy_$(date '+\%Y\%m\%d-\%H\%M\%S').sql
@weekly /bin/tar -czvf /home/tommy/backup/itsmetommy.com/itsmetommy_$(date '+\%Y\%m\%d-\%H\%M\%S').tar.gz -C /var/www/ itsmetommy.com

If you’re having problems, check your cron logs.

tail -f /var/log/cron

MAC — Setup rsync on my MAC

I first created a backup directory on my Drobo.

mkdir -p /Volumes/Drobo5D02/Backup/itsmetommy.com

How to run it manually.

rsync -hva -e ssh --delete --progress tommy@itsmetommy.com:/home/tommy/backup/itsmetommy.com/ /Volumes/Drobo5D02/Backup/itsmetommy.com

MAC — Setup cron

Note: My iMac is always on, so this isn’t a problem for me. Obviously you may need to revisit the timing or method if your computer is not always on and connected to the internet.

Run everyday at 1am.

crontab -e
0 1 * * * /usr/bin/rsync -hva -e ssh --delete  tommy@itsmetommy.com:/home/tommy/backup/itsmetommy.com/ /Volumes/Drobo5D02/Backup/itsmetommy.com > /dev/null

The above setup works, but I really only want to keep the last two backups of both the .sql and .tar.gz files, otherwise I’d run out of space.

CentOS — only keep the last two backups

How to run it manually.

cd /home/tommy/backup/itsmetommy.com; ls -t | grep sql | tail -n +3 | xargs rm; ls -t | grep tar | tail -n +3 | xargs rm

CentOS — Setup cron

crontab -e
@weekly cd /home/tommy/backup/itsmetommy.com && /bin/ls -t | /bin/grep sql | /usr/bin/tail -n +3 | /usr/bin/xargs /bin/rm
@weekly cd /home/tommy/backup/itsmetommy.com && /bin/ls -t | /bin/grep tar | /usr/bin/tail -n +3 | /usr/bin/xargs /bin/rm

OS X Yosemite: Enable FileVault 2

With FileVault 2 you can encrypt the contents of your entire drive to help keep your data secure. FileVault 2 uses full disk, XTS-AES 128 encryption to help keep your data secure. Using FileVault 2, you can encrypt the contents of your entire drive.

System Preferences > Security & Privacy > FileVault tab

(click the lock to make changes if necessary)
Mac FileVault 2 01
Choose your recovery method.
Mac FileVault 2 02
Restart your computer.
Mac FileVault 2 03

iTunes 12.0.1 Update Loop

If you’re like me, you’ve just updated to Yosemite and noticed that it keeps showing an iTunes 12.0.1 update even after you’ve updated.

iTunes 12.0.1 Update Loop

There’s a simple fix for this update iTunes 12.0.1 loop issue. Simply download it directly from Apple via http://www.apple.com/itunes/download/.

Once you install it, the update will no longer show within the App Store updates section.

Mac OS X: Set / Change Default Application for Specific File Type

It can be a little tricky to change the default application when opening up specific files on a Mac. In my case, I wanted to change from the default Quicktime player application to VLC for file extensions such as mp4, m4v and mkv.  That’s where Rubicode comes in to save the day, making it extremely easy to manage your default applications on your Mac.