How to Backup a Drupal 7 Site using Backup and Migrate Module
Backing up a site is very important. A site made with Drupal is no exception.
In this tutorial, we learn how to backup a site made with Drupal. In this tutorial, our focus is on Drupal 7, but I believe this method can also be used for backing up Drupal 5 and 6.
A Drupal site is made of two general parts: Database and the Files (Drupal core, images, documents, etc.) hosted on a server. Therefore, to backup a Drupal site, we should backup the database and the files separately.
Drupal core files and folders are located in site's root: includes, misc, modules, profiles, etc.
Of the Drupal core files & folders, "sites" folder matter the most (for backup), because rest of files and folders rarely change (Sometimes except ".htaccess" and "robots.txt" files).
Site settings, images, documents ... are all located in sites folder, so, save it! If you have edited ".htaccess" and "robots.txt" files, save them, too.
Saving other Drupal core files is not necessary, since you probably already have Drupal installation files, and those only will increase the size of your backup.
Backup Database using "Backup and Migrate" Module
To save site's database, you can use Backup and Migrate module.
Install Backup and Migrate module. After installing the module, it is necessary to specify the "private file system path". If you have not specified the "private file system path", go to "File system" page (located in Configuration > Media), and enter your desired path in "Private file system path" field. For example: "sites/default/files/private".
To check out "Backup and Migrate" settings, and to backup site's database, go to Configurations > System > Backup and Migrate.
In "Destinations" tab, you may specify the "Scheduled Backups Directory" and "Manual Backups Directory". For example, the default path for manual backups directory is "private://backup_migrate/manual", which leads manual backups to be stored in path "sites/default/files/private/backup_migrate/manual".
Go back to "Backup" tab, in second box in "Quick Backup" section, specify whether you like to "Download" the database, or save it in the path we mentioned above (Manual Backups Directory). Now click on "Backup now" button.
Restore the Backup
Imagine the site you made with Drupal 7 is completely lost due to sever breakdown! But you have backup of the sites folder and database of the site. Go through the following steps to restore your site backup:
1. Install Drupal 7 (e.g., How to Install Drupal 7 Locally (using XAMPP))
2. Install Backup and Migrate module.
3. Go to Configurations > System > Backup and Migrate. Open "Restore" tab. In "Upload a Backup File" field, select the database backup you previously saved (By default, and with the configurations we had, it would be a file with mysql.gz extension). Now click "Restore now" button, so that database of the site will be restored. It may take some time.
4. Now, store the "settings.php" file located in "sites\default".
5. Replace the current "sites" folder with the "sites" folder you saved earlier (You saved it in "Save Files" section).
6. Replace the "settings.php" file with the "settings.php" file you stored in step 4.
Now, your Drupal 7 site must be restored. If there are any problems, go to "Performance" page (Configurations > Development), and "Clear all caches".
It is better not to rely on only one method to backup the site. For example, if you are using cPanel as the control panel of your site, it is recommended to also backup the site using cPanel's backup system.
Don't forget to test your backups before relying on them!