Bluhalo IT


Using cron to create website and MySQL backups that rotate nicely over a week

Posted in Storage, linux by Simon Green on the May 9, 2009
Tags: , , ,

I wrote this for a PHP/MySQL site that needed to have it’s databases backed up hourly and the whole site including uploads backed up daily. They wanted all databases going back 24 hours every hour, and then all content going back 7 days every day.  This creates a directory structure that looks like the following:

In this scenario assume the following:

  • /mnt/backup/servername is an NFS mounted location I am backing up to
  • /var/www is the location where the website is stored

Firstly for the impatient, here is the 2 lines you need to put into crontab:

0 0 * * * mkdir -p /mnt/backup/servername/`date +\%A`;  mysqldump -uUser -pPassword --all-databases > /mnt/backup/servername/`date +\%A`/all-databases-daily.sql; tar -czf /mnt/backup/servername/`date +\%A`/www.tar.gz /var/www/
0 * * * * mysqldump -uUser -pPassword --all-databases > /mnt/backup/servername/all-databases-hourly-`date +\%H`.sql

For the less impatient I’ll explain how it works. (more…)

Storing lots of data in a Home/Small Office enviroment

Posted in Storage by Simon Green on the January 19, 2009
Tags: , , , , , , , ,

OK so me and my housemate have a problem. We have accumulated to much stuff over the years between us, we’ve pretty much run out of solutions to hold it all without buying an enterprise style SAN, but keeping it all in the same volume. Obviously this is to expensive for a home user! We’re looking at finding a home for ~3.5 terabytes of data, including music, backups, films, TV, iTunes mounts etc. I’ve decided to post this on here because it’s also useful to SOHO and medium business who need a storage solution.

We looked at various methods of achieving loads of storage, but have settled on a stand alone NAS. The main reason for this is power consumption; we calculated having a server running with a load of hard disks was going to cost us £30 per month whereas a NAS would only cost us £4 per month!

These are the solutions we rulled out:

  • OpenFiler – Way to restrictive on it’s own with sharing and user management
  • OpenFiler + iSCSI + Windows 2003 Server – Gets around the restriction above, but costs a fortune having to run 2 servers!
  • Windows 2003 Software RAID alone – Unstable, and slow. We actually ran with this for a while but it kept resynching which would take transfer speed down to <6Mb/s. Also there is no expansion option!
  • Windows 2003 with a motherboard RAID solution – Most of these come down to runing it off a motherboard unless you spend silly money. On board RAID was usually fine until you wanted to change anything. You can’t move the disks around, it’s slow to rebuild, you can’t expand, etc etc. You are also limited to the number of ports on your motherboard.
  • Windows 2003 with PCI-E RAID Card – We could get a seperate RAID card but there is really only 2 SATA2 RAID cards out there and they cost a fortune. You can get cheap SCSI cards, but SCSI disks are both expensive and small capacity.

So we settled on the fact it’s going to be easiest, most economic, and most reliable to buy a standalone NAS appliance. This however throws up the question: which one! There are loads on the market, so we trawled the web and found the most popular, and drew up the following chart to compare them all (PDF version beneath). We are torn between the QNAP TS-509 with 1TB disks and TS-409 with 1.5TB disks. That’s up to next months bank balance I guess!

NAS Comparisson Chart

NAS Comparison Chart

(You can download as a PDF here)