|
Thursday, 30 July 2009 18:09 |
|
The method I have for backing up my Joomla-powered websites is a little on the cheap n' nasty side but its easy to maintain & it works. Its a two-stage process:
- I use a cronjob to dump the database contents into a plain text file once a day. This is done via a small script called databaseBackups.sh which does a mysqldump on each website on the server:
#!/bin/sh
# This scripts runs nightly via a cronjob & backs up all the databases to text file # These text files are then backed up onto the server in my house via rsnapshot
mysqldump --user=foo --password=bar database1 > /home/cianer/databaseBackups/website1.com.db mysqldump --user=foo --password=bar database2 > /home/cianer/databaseBackups/website2.com.db Then create a cronjob to invoke that script once a day:cianer@viking:~$ crontab cianers.crontab cianer@viking:~$ crontab -l # min hour day/mon month day /week command 0 1 * * * /home/cianer/databaseBackups.sh
cianer@viking:~$
- I then use rsnapshot to pull the entire Joomla installation, along with the database files, to the backup server in my house as described here.
Notes on (in)security: - Obviously you have to make sure databaseBackups.sh is in a directory not accessible via the web and make sure to chmod 700 databaseBackups.sh.
- If anyone with shell access on the server does a ps when your script is running they will see your database password. This is not an issue for me since I trust the guy I share the server with (and he has root access so he could do worse damage if he chose so its irrelevant) but it might be for you.
- You can get rsnapshot to run the mysqldump for you over an ssh connection if you want (you'll have to RTFM for that) but I like having the most recent database on the server anyway. Came in very handy the one time a site of mine was hacked!
|