A backup solution for drupal

Snapshot is a drupal module for making clean snapshot of drupal website. Website, media and database are snapshot. For now, just Mysql with MyIsam engine is supported. Different snapshot method can be used, total or incremental.

Concept

The tactic is simple :

  • Database lock and flush
  • Backup db files and all the website
  • Database unlock

Requirements

  • Access to cron, read access to mysql files
  • Mysql DB with MyIsam engine

Install

Install the drush tool, and this module
Configuration is done in admin page, choose a sync method :

  • Copy : A simple copy.
  • Rsync : There is usually few change between backups, rsync only move delta between files.
  • Rdiff-backup : Rdiff-backup uses rsync engine but keep the delta between differents snapshots. It's like the Apple's Time Machine. Snapshot keeps a daily snapshot for two weeks.

Add a script into /etc/cron.daily

#!/bin/sh
cd /var/www && ./sites/all/modules/drush/drush.php snapshot
chown -R myUser /home/myUser/backup/snapshot

Don't forget the chmod +x

Distant backup

Snapshoting freeze the website. The best way to make a distant backup is to rsync a local backup. Be careful to not sync file while backuping. Rsync over ssh with a public key authentification is the best solution.

rsync -avz -e ssh monsite.net:/home/myUser/backup/snapshot .

Recovery

Backup is nothing, recovery is all.

  • Get a working server
  • Stop Mysql, put backup in the right place, chmod it, start mysql
  • Put drupal backuped files a its place
  • It works!

Backup and Migrate vs Snapshot

There is already a drupal module to make backup : Backup and migrate.
This module is more mature, easier to use, all is done in a web interface.
But :

  • it dumps DB as SQL, wich is slower than copying files.
  • it works as a web process, beware of 30s timeout and RAM limit
  • there is not any lock, the backup may be not consistant
  • only db is backuped, not all the site

Same question, differents answers.

Project Information

Downloads