Drush Archives

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

drush ard

drush archive-dump of drush ard creëert een archief-bestand, inclusief bestanden en database. Deze archiefbestanden zijn beduidend kleiner dan wanneer ik zelf met bv. tar aan de slag ga. Drush ard genereert trouwens tar.gz-bestanden.

Simpel voorbeeld

drush ard

In dit geval wordt de backup geplaatst in de drush archive folder. De output van drush ard vermeld trouwens locatie + naam, dus geen zweet.

Met pad+bestandsnaam

drush ard --destination=/var/www/site/backups/example.tar

Alleen een bestandsnaam opgeven werkt trouwens niet:

drush ard examplesite-drush-archief
Archive saved to /home/hiero/drush-backups/archive-dump/20151020145004/none.20151020_145004.tar.gz

drush help ard

Backup your code, files, and database into a single file.

Examples:
 drush archive-dump                        Write an archive containing 3 sites in it.                                                         
 default,example.com,foo.com
 drush archive-dump @sites                 Save archive containing all sites in a multi-site.                                                 
 drush archive-dump default                Save archive to custom location.                                                                   
 --destination=/backups/mysite.tar                                                                                                            
 drush archive-dump                        Omits any .git directories found in the tree as well as sites/default/files.                       
 --tar-options="--exclude=.git                                                                                                                
 --exclude=sites/default/files"                                                                                                               
 drush archive-dump                        Placeholder %files is replaced with the real path for the current site, and that path is excluded. 
 --tar-options="--exclude=%files"

Arguments:
 sites                                     Optional. Site specifications, delimited by commas. Typically, list subdirectory name(s) under /sites.

Options:
 --description                             Describe the archive contents.                                                                            
 --destination                             The full path and filename in which the archive should be stored. 
                                           If omitted, it will be saved to the drush-backups directory and a filename will be generated.
 --generator                               The generator name to store in the MANIFEST file. The default is "Drush archive-dump".
 --generatorversion                        The generator version number to store in the MANIFEST file. The default is 6.2.0.
 --no-core                                 Exclude Drupal core, so the backup only contains the site specific stuff.
 --overwrite                               Do not fail if the destination file exists; overwrite it instead.
 --pipe                                    Only print the destination of the archive. Useful for scripts that don't pass --destination.
 --preserve-symlinks                       Preserve symbolic links.
 --tags                                    Add tags to the archive manifest. Delimit multiple by commas.
 --tar-options                             Options passed thru to the tar command.

Aliases: ard, archive-backup, arb

drush arr

Met drush archive-restore of drush arr zet je een archiefbestand terug. Syntaxis:

drush arr [--destination] [--db-prefix] [--db-url] [--db-su] [-db-su-pw] [--overwrite] <bestandsnaam> <site-naam>

In sommige gevallen zul je drush uli nodig hebben om het beheer-wachtwoord te resetten.

Voorbeeld --db-url

drush arr ./example.tar.gz --db-url=mysql://root:pass@127.0.0.1/dbname

Voorbeeld --destination

drush arr ./example.tar.gz --destination=/var/www/example.com/docroot

Let op het =-teken. Verder moet dit een lege map zijn.

Compleet voorbeeld

Handig om bv. een testsite snel te resetten

  • Verwijder de database en maak deze opnieuw aan (waarschijnlijk kan deze stap overgeslagen worden)
  • Verwijder alle bestanden (bv. met rm -rf * vanaf de juiste locatie)
  • Installeer het archief, bv. met zoiets als drush arr ./example.tar.gz --db-url=mysql://root:pass@127.0.0.1/dbname --destination=/var/www/example.com/docroot --overwrite. settings.php wordt automatisch bijgewerkt door Drush
  • Rechten bijwerken. Aangezien dit een ontwikkelomgeving betreft: chmod -R o+rwx .
  • Root-wachtwoord wijzigen: drush upwd --password="Wachtwoord" admin
  • $base_url aanpassen in settings.php

Denk ook aan...

  • Bestandspermissies
  • CleanURLs/Apache-configuratie/.htaccess
  • Base-path in settings.php

drush help arr

Expand a site archive into a Drupal web site.

Examples:
 drush archive-restore ./example.tar.gz    Restore the files and databases for all sites in the archive.                   
 drush archive-restore ./example.tar.gz    Restore the files and database for example.com site.                            
 example.com                                                                                                               
 drush archive-restore ./example.tar.gz    Restore archive to a custom location.                                           
 --destination=/var/www/example.com/docro                                                                                  
 ot                                                                                                                        
 drush archive-restore ./example.tar.gz    Restore archive to a new database (and customize settings.php to point there.). 
 --db-url=mysql://root:pass@127.0.0.1/dbn                                                                                  
 ame

Arguments:
 file                                      The site archive file that should be expanded.                                
 site name                                 Optional. Which site within the archive you want to restore. Defaults to all.

Options:
 --db-prefix                               An optional table prefix to use during restore.                                                                               
 --db-su                                   Account to use when creating the new database. Optional.                                                                      
 --db-su-pw                                Password for the "db-su" account. Optional.                                                                                   
 --db-url=<mysql://root:pass@host/db>      A Drupal 6 style database URL indicating the target for database restore. If not provided, the archived settings.php is used. 
 --destination                             Specify where the Drupal site should be expanded, including the docroot. Defaults to the current working directory.           
 --overwrite                               Allow drush to overwrite any files in the destination.

Aliases: arr

Casus okt. 2015: Snel een locale kopie

Server-sided:

cd /home/account/public/example.com/public
drush ard --destination=/home/account/inmap/example.com

Bronnen