How to take backup using Drush?
While migrating our site to a new server or even updating the Drupal version, all come across backing up the database and files. Many might have done database backup through bash command.
We can simply take a copy of the database by,
mysql -u root -p drupal_database > drupal_database_backup.sql
This would simply do it. If you want to make its copy in a path of your own, do specify the path in right portion. There is no choice left other than to backup the site files manually.
However, we need to run many errands to take the backup of the database and files of Drupal installation.
No worries, if you good at Drush. May be Drush developers have developed this considering the burden of back up's.
In Drush we can backup the database as well as the files using a single command, ie., drush archive-dump,
drush archive-dump default
--tar-options="-z --exclude=sites/default/files"
--destination=/_`date +%F`.tar.gz
This command would give as a copy of both the database and the files folder of your Drupal installation at the destination specified. If you don't specify the destination folder, the backups would be available at drush-backup in home folder under today's date.
This command supports 10 options. Few are,
- Description --description option for archive-dump will let you give a description for the contents you have backed up.
- No core --no-core which lets you not to include Drupal core files while backing up.
- Zipping the content --tar-options is the folder that've been asked to be zipped.
- Overwrite --overwrite, Suppose if the backup file specified is already been created once, on running the command with this option will overwrite the existing backup file.
- Destination --destination, is the path along with the file name for the copy.
- Tags --tags, As such as description the command also let as tag the contents to the most relevant tags. We can include more than one tag by comma separation.
As of current developments in this command, it is not taking the back up of the database, but only the files. I assume people to try sql-dump command to create the backup of the database.
Find more drush tips, please have look over here.
Please get in touch with us to know more.