Creating and storing website backups is not just an element of website best practices, it is the most important step to ensure website stability and a requirement for all forms of development!
Basic advantages of a backup strategy
- If for any reason your website goes awry restoring it from a recent backup is sometimes the only option available.
- New development environments can be created and refreshed very easily.
- Upgrades and patches can be tested singly or in groups with high confidence when using a recent backup of your production site.
To create a complete copy of the website both the database and the custom files will need to be backed up. An automatic backup strategy is easy to implement using the Backup & Migrate module, and a manual backup can be created before major updates or new implementations, providing a convenient restore point taken immediately prior to the changes going in.
Backup & Migrate
The Backup & Migrate module facilitates emergency recovery and site migration. You can configure it for automatic backups saved to the filesystem - with more frequent backups during development.
You can also create a manual backup before undertaking any complex configuration changes or major updates. That way, you have a "restore point" in case of disaster.
While there may be some issues of security when you save the database and content as a file (you could exclude certain tables, perhaps), the benefits of having a rollback in case of disaster are significant.
The module also facilitates migration of the site. I just moved a complex site with Views, APK, CiviCRM etc., about 12,000 files. I moved the files, created a new database, edited settings.php and civicrm.settings.php for the new database, exported the database from the existing site and imported it in the new site's database with phpMyAdmin and VOILA - site moved! (sometimes I copy the files, make a default installation, enable the Backup & Migrate module, and import the database in the module interface - that works too).
Drush also integrates with the Backup & Migrate module.
Drush archive-dump creates an archive of your files and database with the archive-dump command.
Drush sql-dump uses mysqldump to back up your database. It is particularly effective when combined with Drush aliases so you do not have to be in your site directory, and you can backup a remote server db if you have SSH access on it.
Example sql-dump command (without alias) adding timestamp to filename:
drush sql-dump --result-file=PATH/TO/BACKUP/DIR/DBNAME_`date +"%m_%d_%Y-%H:%M"`.sql
Command line interface
If your webhost gives you access to the Command line: You can perform a database dump with the