I'm using ubuntu, and I accidentally deleted my project last weak. I tried to recover it but no luck.

Which is the best way to backup my project automatically including my Database (my database is Mysql)? What do you recommend?

  • This seems more a question about how to backup files, and databases files, where Drupal is only a marginal element. You could ask the same question for any other CMS, and you would get similar answers. – kiamlaluno May 17 '11 at 2:16

First of all, let me just state the obvious: the solution that I'm about to propose is not going to bring your files back; it is a measure that you'll have to take from now on in order to prevent similar disasters in the future.

Basically, since you are working in your local machine (if you were working in the cloud you could automate a snapshot-taking process) you will have to keep a backup of 2 different things: the files and the database. Assuming that you are following the "drupal best practices code" and you are keeping every new file in the sites folder of your drupal installation, all you have to do is keep a regular backup of this folder and the database. So:

1) Regarding the "sites" folder: you can create a simple cron job that will compress and archive the folder regularly (even though it is out of the scope of this answer, you can find more information on crontab here)

2) Regarding the database: the solution here is actually pretty simple: "Backup and Migrate" module. It gives you the option to schedule your database backup and save the file through FTP in a remote server, send it through email or save it in your local machine. It's basically more than you'll ever need for this purpose.

P.S: I'm pretty sure that you will get some answers that you should be running a version control system to avoid things like that in the future. It's true that a version control system would be the ideal way to make sure that your files will not be lost in the future (the database is another story). However, the solution that I mentioned above is considerably faster and can get you up and running in no time. If you have time though, I would strongly suggest that you take a look at SVN or GIT (or any subversion control system that you like for that matter).

P.P.S: If the data that you lost is important, you can do a google search for data recovery software. A very quick search that I did gave me this.

  • 1
    Oh fyi: P.S.2 = P.P.S – chrisjlee May 16 '11 at 15:54
  • lol ty! Didn't know that :) - edited – F1234k May 16 '11 at 16:00
  • Thank you! I don't mind the last project which i lost. i already started from scratch. a version control system i was just looking bzr i thinks that is a good idea but backing up the database that will be manual. Thank you again for your advice. – jone May 17 '11 at 8:23
  • Actually, if a backup is manual, it should not be called a backup: you will not be always there to backup your database, and usually disasters happen when you forgot to do your backup for a long time :P You can either use the "Backup and Migrate" module that allows you to automatically backup on a schedule, or you can use mysqldump and schedule it with crontab. – F1234k May 17 '11 at 8:26

Another option is to use "rsync" in Ubuntu, you can set it to perform regular cron jobs. I use this with the "luckybackup" graphical front-end and it is fast. Both are available from the ubuntu repositories and are quite easy to set up. I find it very effective, and I suppose its one of the many options available, but I find it very fast at backing up remote VPS installations, including the MSQL databases folder found on Ubuntu at /var/lib/mysql.

  • /var/lib/mysql Thanks i was looking that directory:) – jone May 17 '11 at 8:30
  • Backing up /var/lib/mysql doesn't look like a very practical solution to back up a database, I'd rather use "Backup and migrate" or some very simple mysqldump script. – tostinni May 19 '11 at 1:12
  • Sure, its a matter of choice. The difference between dumps/exports and backing up system files is that the restore is done on the system, rather than through an import/upload. So its a backup solution in the traditional "hard disk backup" sense. See [stackoverflow.com/questions/2482491/… – David May 19 '11 at 11:56

You should use a source control system for your code, github offers free hosting for public projects, or you can create a sandbox project on drupal.org.

Your database is a little more tricky, use mysqldump to export the database, and back it up via something like drop box. You can put the database into source control as well if you like, but it isn't ideally suited to that.

  • 1
    Or assembla.com for private projects (Git/SVN) – chrisjlee May 16 '11 at 15:52
  • I don't think a sandbox on Drupal.org can be used for a personal project to which nobody else would be interested, or for which the user is not interested in sharing it. – kiamlaluno May 17 '11 at 2:12

Take a look at the drush commands. drush helps you dumping your database with extra features (e.g. gzipping, import/export via rsync, filtering tables and more...). Take a look at the following commands:

It also makes syncing the filesystem easy. For this check out the core-rsync command. In combination these features can be very handy. Make sure to check out the other drush commands as well.

  • Thank you that seems cool for backing up my database i will check that. thanks – jone May 17 '11 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.