Python for Scientists – Disaster Recovery

Disasters happen: coffee spills on a laptop, electronics are dropped, hard disks fail or become corrupt. The combination of Conda environments and version control provides a near-bullet-proof disaster mitigation strategy. We will also discuss disaster recovery for when disasters happen.

Topics covered in this post:

  • Disaster Mitigation
  • Disaster Recovery

Click here for a list of related posts.

Updated: 2020-05-03

Disaster Mitigation/Recovery

Having a method to regenerate a project’s Conda environment is very important.  Instructions to generate an environment specifications file, which is used to recreate a Conda environment, are provided in the Conda Environments post. The specifications text file provides a quick way to recover a working Python environment after total data loss. Ensure that each project has an updated specifications text file within each project top-level directory.

You can also use a YAML environment file if exact reproducibility is not a concern. While YAML files are better for cross platform environments, you probably won’t be recovering into a different operating system than the one you used before disaster. I recommend having both a YAML environment file and an environment specifications file. That way you’re covered either way.

A solid disaster mitigation strategy is to have at least 3 working copies of your projects. One will be on the local computer, another copy will be on a remote Git repository (e.g. GitLab), and another should exist on either a cloud server (such as DropBox), or an external USB/hard drive (or use both, a cloud service and USB/hard drive). This strategy provides a local and remote backup in case your place of work/home burns down, or succumbs to some other unforeseen disaster.

Let’s say you’re having a bad day and your hard drive fails. All work is lost. If you had been pushing local Git commits to a remote repository, backing up the repository on another storage device (just in case the remote Git repository also fails), and had a Conda specifications file, then recovery is quick and easy (after a new hard drive and operating system are installed).

To recover, install Git on the restored local computer, create a Projects folder (e.g. ~/Documents/Projects/), and clone your remote Git repository into the Projects folder. Then, install Miniconda3 and recreate the Conda environment. Viola, you’re back in business.


Related Posts

Comments are closed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑