⚠️ WARNING ⚠️

Use of drush archive:dump and drush archive:restore command on production/sandbox VPS server is discouraged, because they are heavy, intrusive operation that bundle code, files and database together. Because is resource heavy, it may result in long processing time, or memory exhaustion that causes the website to freeze !


Backup Drush Commands - drush archive:dump

1
2
3
drush archive:dump --db   --destination=./20XX-XX-XXTYYYYYY-[database].tar.gz -vvv # Backup Database Only
drush archive:dump --code --destination=./20XX-XX-XXTYYYYYY-[codebase].tar.gz -vvv # Backup the codebase (excluding the file directory)
drush archive:dump --file --destination=./20XX-XX-XXTYYYYYY-[filebase].tar.gz -vvv # Backup Drupal File Directory

Note that:

  • The following directories will be excluded from a --code archive: .git, vendor (Composer packages installed path, show via running composer info --path --format=json), <root>/sites/@/settings.@.php, sites/default/files (Drupal file directory)
  • The following directories will be excluded from a --file archive: <files-root>/css, <files-root>/js (the aggregated css/js files), <files-root>/styles, <files-root>/php

Restore Drush Commands - drush archive:restore

Restore (import) your code, files, and database.

1
2
3
drush archive:restore --db   --destination=./20XX-XX-XXTYYYYYY-[database].tar.gz -vvv # Restore Database Only
drush archive:restore --code --destination=./20XX-XX-XXTYYYYYY-[codebase].tar.gz -vvv # Restore the codebase
drush archive:restore --file --destination=./20XX-XX-XXTYYYYYY-[filebase].tar.gz -vvv # Restore Drupal File Directory

Reference