In my last article, I wrote about how I host my stuff. A topic that goes hand in hand with hosting is backing up data. There are many strategies when it comes to backups. Depending on the type of data that should be backed up, they range from naive to doomsday prepper. For my simple applications, I apply a strategy that is more on the naive side because it will not hurt immensely if I should lose the data.
I started by choosing a place where I wanted to store my backups. My applications run on virtual private servers that I rent. Those servers run in a data center in Germany. Each of those servers has snapshot backup enabled, which makes it possible to reset the server to a previous snapshot for some days. This is the only backup I have enabled for servers that just serve statically generated sites. If something were to happen to those servers, I can just deploy the site to another server and nothing will be lost. For servers that host more dynamic sites that have a database or store uploaded files, I decided to use a tool called restic and back up my data via SFTP to rented storage hosted in Finland. This makes it less likely that my data will be lost if something happens to the data center in Germany.
Restic is a tool written in Go that can securely back up data to different storage types. It is pretty simple to set up and even supports cleaning up old backups via policies. I have it scheduled on my servers via Cron and configured to keep seven daily, four weekly, and three monthly backups. This tool makes it easy to back up all user-generated content of my applications.
Backups always seemed like a very complicated and exhausting topic to me, but after I researched a bit, it wasn’t as tricky as I made it out to be. My final setup utilizing server snapshots, restic, and hosted storage is simple but effective. Of course, if you have to securely back up critical data, it may be best to give this topic a tad more thought.
Something that comes to mind here is the 3-2-1 rule for backups. Three copies of data, two on different media, one is kept off-site. ↩︎