1
14 Comments

How often do you backup your production database?

What would be a good frequency for keeping backups for a small scale app?

posted to Icon for group Developers
Developers
on May 14, 2020
  1. 3

    I do 2 full backups daily, one at Midnight and the other at Midday. Hourly transaction log backups. All backups are immediately checked for corruption and successful restoring before being kept.

    Everything is a fully automated process that runs backups, quality check and then uploads to S3 bucket and it purges backups they are 91 days old.

    Corrupt backups are as bad as no backups!

  2. 2

    This is really something you have to answer yourself as only you know what your database looks like, how much data we are talking about, how much down time / lost data you can stomach and possibly SLAs with your customers. Is a downtime going to anger your customers or are they just free users?

    Additionally this really depends on what your database is doing. If you are just recording some events from your app and you are okay with losing x hours of events then that's your backup schedule.

    If it's something critical like user data and losing x hours of user data means you are losing paying customers then the goal has to be to make this window as small as possible. You can easily calculate how much revenue you'd be losing in this case and decide based on that.

    That said, there's multiple options, the most popular is probably incremental backups + full backups in a longer interval:

    1. Run incremental backups every hour / 30 min, then have a daily backup, monthly backup and then thin them out after that. That way you are also safe in case there's a regression you don't immediately spot and only realize a few weeks later. (Like silently overwriting some values)

    2. Use a master-slave architecture so you can easily fail over in case there's an issue with your main DB.

    3. Use a hosted database solution and let them worry about it but don't forget to read up what their backup strategy actually is.

    1. 1

      Thanks for the detailed explanation, Dewey. I went with Heroku Postgres with their Continuous Protection enabled. 😁

  3. 2

    Depends on the nature of your app and size of the database. I backup my main site every 15 min, and my blog once a day. Backups are so cheap on S3 there is no reason not to backup very frequently. I also have replication turned on in S3 so every backup in region A is automatically copied to region B. There are much more sophisticated backup schemes but I'm not there yet, this seems good enough for me for now 😄

  4. 2

    I take one every 3 days and upload it to a secure S3 bucket, though I’m considering taking daily snapshots as my user base grows and grows.

  5. 0

    There is no reason to back up your database if you have proper redundancy and replication. If you are using any SQL databases they should have some type of master-slave replication scheme running on Paxos or Raft algorithm. You can configure one of them to be a lag copy that is always several days behind as your backup.

    1. 1

      This is harmful advice, don't do that!

      That's like saying a RAID is a backup. That means that if there's data corruption or you accidentally delete some data it will replicate into your slave and is gone. Sometimes you only discover missing data weeks or months later if it's rarely accessed data or it takes a while to track down problems. Backups are a solved problem so just do what everyone else is doing and don't rely one some side effect of your database availability feature.

      1. 0

        This is not harmful advice.. This is how it is done at FANG.

        1. 1

          There is a well regarded blog post called "You Are Not Google": https://blog.bradfieldcs.com/you-are-not-google-84912cf44afb

          I suggest you give it a read. Trying to model your infrastructure after what FAANG does is harmful advice...if you are not FAANG. You do not have a 24/7 ops team, write your own databases, have your database replicated around the world in different data centers and have a totally different use case and backup strategy.

          If you are not FAANG do database backups like the rest of the industry.

Trending on Indie Hackers
I'm a lawyer who launched an AI contract tool on Product Hunt today — here's what building it as a non-technical founder actually felt like User Avatar 150 comments A simple way to keep AI automations from making bad decisions User Avatar 55 comments “This contract looked normal - but could cost millions” User Avatar 54 comments Never hire an SEO Agency for your Saas Startup User Avatar 42 comments 👉 The most expensive contract mistakes don’t feel risky User Avatar 41 comments The indie maker's dilemma: 2 months in, 700 downloads, and I'm stuck User Avatar 40 comments