Make a copy


The first line of defense to protect at least your text content (including any code) is revision control. Activate the creation of revisions by:
  • going to Edit content type, Workflow settings
  • check the field Create new revision
  • Save content type
  • This will add a Revisions tab above your content. Here you have the possibility to Revert to a previous version.
  • Do this for every content type you might need to revert. Normally all.
Remember this only protects your text, not any files. Once in a while you should tranfer your complete files folder to your local computer with FTP. Depending on the type of files (video, images, etc) it can take a bit of time and bandwidth. In the near future I will try to find out if there is a way only to tranfer any new or changed files.

Then all your tweaks and patches to core, modules and themes should be documented. Make a page on your site, named mods or something like that, with file attchments of your patched or tweaked files and patches, along with a description of what you tweaked/patched and why. If you had to use the full path to files on your site (sometimes it might be necessary), keep a list of those too.

Besides this, try to have good habbits. Preview content before saving it, especially when using script- or PHP code in your content (full-HTML or PHP input format). When something renders wrong, you just go out without saving and everything is back to normal. If you use a WYSIWYG-editor you probably have an Undo button in your toolbar at the top of the editing Body area. When writing a longer article from scratch, save you content once in a while.

Make a backup of the complete database regularly. When developing I do it almost daily, due to an increased risk something goes wrong.
  • In cPanel go to Databases, phpMyAdmin.
  • Select a database and go to the Export tab.
  • Don't change anything in the main area, only in the bottom area add -%F to the File name template to have the actual date added and choose Compression: "gzipped".
  • Save to a logical location on your hard disk.
Have three working copies of your site:
  • One on the same server but another Drupal installation and using the same modules, plugins and themes in the sites/all folder.
    • Copying the files folder is really fast. No downloading needed.
    • If it's working here, you know it does not depend on your server.
    • Remember to use a relative path as much as possible (/sites/default/files instead of http://yoursite.com/sites/default/files).
    • Before importing your database with phpMyAdmin, drop all the existing tables in your clone.
    • After importing, which can take a while, run update.php on your clone.
    • Put it in maintenance mode, otherwise it will be found and indexed, penalizing the original site by the search engines for having duplicate content elsewhere. Put also the following lines in the robots.txt: 
      User-agent: * 
      Disallow: /
    • Subsritute all the API-keys (like Google map) and keep them documented somewhere.
    •  
  • On your local machine.
    • It's quick and you don't depend on an internet connection. Ideal for developing and demonstration purposes.
    • Remember to keep Apache, PHP and MySQL version as much the same as the one you have on your server.
    • API-keys might not work (e.g. Google maps) and third party scripts only when you are connected.