Hi,

i've looked through the modules but didn't find any ...

i'm looking for a module that does the following:

1)it takes a dump of the database
2)makes a tar of ALL the files one the drupal system ...

combines these two in another TAR-ball ....

so you can acutally have a backup of the WHOLE site in just ONE FILE ....

any one ???

thanks

Comments

bsherwood’s picture

You can do this with a simple bash script. I am also sure that most of the drupal community will also recommend this method as well.

If you are using dreamhost, they have a great wiki article that shows you step by step how to do it. If your not using dreamhost, the article is still a great resource to show you how to do it. I think you need to go to wiki.dreamhost.com and search for 'automated backups'.

While drupal could to this, coding it would be rather pointless (for a simple site) the tools are already at your disposal within the bash shell. If your using windows and IIS, you would need to create a .bat file and set scheduled tasks to run it. The methods are almost identical, just one or two key differences.

It should be rather easy though in bash

#! /bin/bash

tar directory structure into tarball
mysqldump database into tarball
combine tarballs into one tarball
compress tarball

I would copy the script from wiki.dreamhost.com as customize it to your needs. then create a cron job and voila automatic backups.

risharde’s picture

It seems the backup module is only compatible with the 5.x version. I'm hoping for the best but this is such an essential tool. Yes its true that you can do it from bash but not everyone is a command prompt guru...

sunset_bill’s picture

not any kind of guru, but this works for me:

#!/bin/bash

stamp=$(date "+%Y.%m.%d-%H%M")

tar czf mysite_backup_files-$stamp.tgz [site base directory]

mysqldump -h[db host] -u[db user] -p[db password] [db name] --opt --quote-names --allow-keywords --complete-insert | bzip2 -c > mysite_backup_db-$stamp.sql.bz2

tar cvf mysite_backup_all-$stamp.tgz mysite_backup_files-$stamp.tgz mysite_backup_db-$stamp.sql.bz2

find mysite_backup_* -mtime +2 -exec rm {} \;

I run this script as a cron job on my server once a day. It makes date-stamped backups and the 'find' line deletes backup files that are more than 2 days old.

Note: I use bzip2 for my database backup because I'm not a guru enough to get tar to work from STDOUT.
Important: Despite how it looks above, that mysqldump command *is* all on one line. If you copy'n'paste this, be sure to get rid of that linebreak!

salud,
Bill

foursticks’s picture

Just curious, with database backups, should the site be put off line first?

Any chance of corruption if the database is getting backed up at the same time someone is making a change?

sunset_bill’s picture

I'm not real sure, but since mysqldump is a mysql function, all that's likely to happen if you're doing a backup while someone is making a change is that your backup won't pick up the change (until the next backup runs).

One thing I do know is that if you're running a backup to move your site to a different server, you will need to disable Clean URLs (if they're on) before doing your backup.

foursticks’s picture

Thanks

taskcore’s picture

I have created cron jobs in directadmin but I am not sure how I would create the one shown by sunset_bill. Any advice?