Community & Support

How do I backup everything, Godaddy lost 8 of my sites.

After tons of work on 8 drupal sites Godaddy.com loses all of them and restores from a 11 day old backup of my system. How do I backup and restore all aspects of my drupal sites?

Comments

Bummer dude.

Create a backup script and schedule it to run with a cron job. If you can't schedule a cron job, then your hosting provider sucks and isn't probably what you want for Drupal anyways. After much searching, I chose site5 dot com - but I'm cheap.

I used a shell script cause it's the simplest thing that could possibly work - and it did! I saw some PHP scripts out there, but they looked like a pain in the ass.

My host has a web page that configures cron jobs, but if you have a shell, try running the "crontab" command (you might get stuck in an editor called "VI")

Anyways, create the cron job like this:
17  5 * * *  nice -n 15 bash $HOME/backup_community.sh
Runs at 5:15 am every day. "nice" means don't hog the server. "bash" means use the bash shell.

For *TESTING* you can do something like
*/2  5 * * *  nice -n 15 bash $HOME/backup_community.sh
to run the command every other minute. This is definitely against the rules of your hosting provider - and a jerk move if you forget to turn it off on a shared server.

My account looks like this:

~                                               <- my account home directory
~/public_html/community               <- where my website files live
~/backups/community                    <- where my website backups live

The backup_community.sh script.

cd ~/backups/community

# backup database
mysqldump -uUSERNAME -pPASSWORD --quote-names --allow-keywords --opt DATABASENAME > ~/backups/community/lastdb.sql

# zip it
tar --create --gzip --preserve --file=lastbackup.tar.gz ~/public_html/drupal_site_folder ~/backups/community/lastdb.sql ~/backup_community.sh

# rolling archives
#    daily backups copy to

cp lastbackup.tar.gz Daily.$(date +%d).tar.gz
cp lastbackup.tar.gz Monthly.$(date +%m).tar.gz

Note that the backup files are outside the public_html folder. Otherwise, someone could download your whole site (passwords, photos, private content, and all)

My website is 15 megs when backed up. This script will create daily backups for 30 days, and 12 monthly backups.
15 megs * 42 = 630 megs of space dedicated to backups. I bet you'd agree it's a small price to pay ;-)

If you want to rotate your backups differently, google "date unix" for documentation on the date function.

Obstacles will be:
- Can't run a cron job - new host.
- Can't run a shell script - find a PHP script (or new host ;-)
- Can't run mysqldump or tar - You'll have to find them in the path /bin/whatever/mysqldump
- you might not have the bash shell - if so, contact support.

Also, if all that fails, read your hosts forums - you're probably not the first person who wants to backup a PHP/MySQL app.

Best luck! Sorry about your sites man. The next one will be better, *faster* *STRONGER* You have the technology!

Mike

Godaddy site back up

Things have changed with Godaddy's CRON manager. The easiest way to do a file system back up is with a shell script. There is a simply tutorial at http://www.fortasse.com/2010/01/tutorials/tutorial-automatic-backup-script/ that has a script specifically for Godaddy. Their CRON manager is a little different and this one worked for me.