Site restore script

Caution: This script has no safeguards against accidental restores. Since a restore, by definition, overwrites the existing website do NOT use this script unless you understand what it is doing.

To use this script modify the variables in the Configuration block to specify the instance where the data will be restored.

To restore a site run the script specifying the backup file in parameter P1. e.g.:
  $ sh fullsiterestore.sh fullsitebackup-2006-04-14.tgz
  $ bash fullsiterestore.sh fullsitebackup-2006-04-14.tgz

You will be prompted for the database password and may be prompted for permission to delete a file if it is permitted read-only.

If multiple websites are hosted on the same system create a copy of the script and rename it to reflect the restore it will perform. For example, for a site named mysite1, create a copy of fullsiterestore.sh named mysite1fullrestore.sh.

Usage notes and warnings:

  • The backup script uses the mysqldump --add-drop-table option. On a restore this allows the database tables to be removed and recreated. No prompt is given before this happens.
  • Write access is required on all files and directories (this is sometimes a problem in hosted configurations)
  • Enough file space must be available to allow unpacking of the backup file
  • This script does not lock out users while the restore is in progress
  • This script does not understand Drupal multisite configurations
  • Commands may need to be modified for your operating system (e.g., The default tar command in Solaris does not support compression)
  • If restoring over top of a Drupal instance that contains modules that are not in the backup there will be "orphaned" module tables. Depending on the situation, you may wish to drop and recreate the database before doing the restore.
  • When restoring to a different server the file permissions may require updating

No Drupal configuration is required if restoring a backup to the same location it was backed up from.

If restoring a backup to a different location the configuration must be updated according, specifically $db_url and $base_url in settings.php. The article Creating a Test Site workflow contains information on automating this using a command line utility named sed.

 
 

Drupal is a registered trademark of Dries Buytaert.