Backup and Restore using Drush

Final / Up to date -- Last peer review: 20 Aug 2019
This lesson teaches how to Backup and Restore your site data

It is important to backup your site data to either migrate to new site or to use it when we accidentally lose our original data. Luckily Drush makes this work very easy to do. You would learn how to backup and restore files using two methods. The first method will be using the Drush archive-dump command and the second method would be using Backup and Migrate module.


Using Drush archive-dump and archive-restore

1) Open command Prompt and navigate to your site directory. Now use the command

drush archive-dump –-destination=D:/xampp/htdocs/backd7dev/files.tar.gz

Using archive-dump

If you want to exclude .git directory, try:
drush archive-dump –-destination=D:/xampp/htdocs/backd7dev/files.tar.gz --tar-options="--exclude=.git"

2) To restore the backup file, use:

drush archive-restore D:/xampp/htdocs/backd7dev/files.tar.gz

Restoring the files

REMEMBER: You have to first navigate to the location where you want to extract the backup file.

So this was how you can backup and restore files using Drush archive-dump and archive-restore commands.

Using Backup and Migrate module

1) Let us first download the Backup and Migrate module and enable it. Open your Command Prompt and navigate to site directory. Use the following command:

drush dl backup_migrate

Now to enable the module, use

drush en backup_migrate

Downloading and enabling the module

2) Now we can backup our site's files. Use:

drush bam-backup

3) You can get the list of backups using:

drush bam-backups manual

4) Now you can restore the files using the name of the file you found above:

drush bam-restore db manual "[PUT NAME OF THE FILE HERE]"

That's it!

Lesson tags:


Could not find the source 'manual'
Try using 'drush bam-sources' to get a list of available sources or use 'db' to backup the Drupal database.
please what can i do ???

I hit the same problem which I fixed by going into the admin of the site and clicking 'Modules' and then clicking 'Configure' on the 'Backup and Migrate' module (usually at the bottom of the module list under Other), you will see a message on the configure page about the private file system path not being set, click on this and set a path that is outside your site root but accessible to Drupal (e.g. if your site root is /var/www/d7dev you could create a folder in /var/backups/d7dev as your private system folder, remember to set permissions on the folder for the web server to access).