We have done some work on our site and it gets to the point where we start worrying about what would happen if something goes wrong and we lose everything, or if a change in the site will need a rollback that may be tedious. Drush provides a couple of commands to deal with this:
For example, let's create a directory out of our Drupal project where we will store our backups and then create one and place it there. Whenever you start to use this command on production environments, it is highly recommended that you copy these backups periodically to a safer machine, out of the server where the site runs.
$ cd /home/juampy
$ mdkir backups
$ cd projects/drupal
$ drush archive-dump
Archive saved to [ok]
/home/juampy/drush-backups/archive-dump/20120321213658/drupal.20120321_093700.tar.gz
That's it. Note that if you want to backup a named site, you would have to specify it by appending it as an argument as shown in the following example:
$ drush archive-dump --destination=/home/juampy/backups/drupal.tar mysite.com
If we go to the backups
directory, we will find the file drupal.tar
. Go ahead and open it with a file compression software. This file contains the following:
archive-dump
, these will be included in the backup. By default, if no arguments are defined, all sites are included. .sql
containing the database dump of our site. MANIFEST.ini
that holds a structured description of the contents and properties of the backup. Here is an example of the one created by the previous command:[Global] datestamp = "1325108195" formatversion = "1.0" generator = "Drush archive-dump" generatorversion = "4.5" [default] docroot = "/home/juampy/projects/drupal" sitedir = "sites/default" files-public = "sites/default/files" database-default-file = "./drupal.sql" database-default-driver = "mysql"
Now, we are going to restore our backup to another machine. Copy the drupal.tar
file to another system, open a terminal, and execute the following command:
$ drush archive-restore drupal.tar
The command archive-restore
will open the packaged file, read the MANIFEST.ini
file, and perform the extraction and assembly of the contents into a new folder called drupal
.
3.144.193.129