Last summer I accidentally left my Chromebook power cord on the wrong side of the country and had to wait a few weeks to get it back. Since I was traveling without my "real" laptop I was without a machine. It was an idyllic time during which I contemplated my relationship with technology. But this post is not about that, it's about what happens after I plug my Chromebook back in and realize everything is gone.

It turns out that if your Chromebook completely exhausts its battery it disables legacy boot mode and has to boot into ChromeOS. Well, I had wiped ChromeOS to replace it with Linux so I have to wipe the drive again and reinstall ChromeOS. My files were not spared in this process.

However, this story has a happy ending. I lost almost nothing. Code and text for my projects is saved on Github while raw data is stored on my "real" laptop and on a cloud storage service. The only real loss was the time it would take to reinstall Linux and my favorite software.

This could have been a nightmare however. As someone whose work is mostly code, suddenly having it all disappear would be a serious matter. While the probability of such a loss seems fairly low (this is the first time I've ever lost anything), the magnitude is large enough that it's worthwhile to protect against it. Fortunately, that's fairly easy to do.

For code/text there's nothing better than Github. As a student I have access to free unlimited private1 repos so I store everything: problem sets, research, Project Euler solutions, Advent of Code solutions, Backup is as easy as a commit and push. Even better, because it's a version control system you never have to worry about overwriting something; you have access to all previous versions. Git isn't even as complicated as people make it out to be; as long as you restrict yourself to `git add`, `git commit`, and `git push` I can't think of anything that can reasonably go wrong. You're not getting the collaborative benefits and your log might get messy, but you probably have the best plain text backup system available.

You'll need another tool when you have files that aren't plain text; usually this is raw data and figures. The figures generally don't need to be saved; if your project is reproducible you can simply regenerate these files as necessary. But for data, or computationally intensive figures you'll need something other than Github to store them.

The most popular solution among people I know is Dropbox 2. My main problem with Dropbox is that managing files requires either using the web interface or saving files in a particular directory. To be clear, this is mostly an aesthetic problem for me. I solve this by using rclone. It's like rsync except you can access Dropbox and several other cloud services. So backing up my library of papers/notes is as easy as `rclone sync papers dropbox:papers`. It also works with Google Drive with `rclone sync papers gdrive:papers` in case you want to diversify your storage.

That's basically all you need to avoid the heartbreak of losing your work. The amazing thing is that they're not particularly onerous. You should already be using git and if you're not it's fairly simple to learn the basics. Dropbox can sync automatically or you can write a cron job to do so. Losing your data shouldn't worry you.

Footnotes:

1

Private is important if you're worried about somebody scooping your work or copying your problem set solutions.

2

How do I know? Because when I look at their R code it always has a `setwd("~/Dropbox/$subdir")` even after I lecture them about the virtues of using relative paths.