r/gitlab • • 24d ago

general question How do you check that your self-managed GitLab backups actually restore?

I run a self-managed GitLab and I'm trying to understand how other people verify their backups, not selling anything.

  1. How do you test a restore today (never, manually now and then, scripted)?

  2. When did a restore last fail or surprise you (missing gitlab-secrets.json, version mismatch, DB errors)?

  3. What did that cost you in hours or downtime?

  4. Have you paid for a tool or written your own script for this? What and how much?

  5. How many repos or users is your instance?

13 Upvotes

9 comments sorted by

15

u/pwkye 24d ago

Create VM. Restore. Scripts to count repos branches issues.

I guess you could even use the docker container

6

u/reubendevries 24d ago

We had a staging environment, and I would restore the production environment's month end backup every month over the staging environment, it kept staging close to production and ensured my team was ready for a restore in the situation where it was needed.

5

u/Lumethys 23d ago

delete prod database, just like Gitlab themselves do

4

u/_tenken 24d ago

Gitlab secrets is not exported in the backup by default, so there are certain items you have to track manually for backups.

I have run backups daily for years to Amazon S3 via the official backup utility included with the docker image. I have restored at least once fully to production because it was easier to migrate between hosts this way. It never broke and I would say it's gotten better in the last couple of years where the version number of the export explicitly states what version the export was created from and I think like what it can restore to. I have run Gitlab-ce since 4.x and am on 19.5.3 now.

I don't know if the issue has been resolved but when I did a restore, the git owner of certain internal directories of the backup restore was not enforced upon or recreated upon the restoration process completing. So some items were failing such as I think the container registry to write images because the dir owner was incorrect. This was a known issue that had a issue in gitlabs repo it had never clearly even addressed. But I did find the issue and just changing owners of certain directories fixed the issue. I kind of wish that the import task took care of it when re-creating from a backup. But this was a long time ago.

2

u/Mahsunon 24d ago edited 24d ago

The gitlab toolbox pod can run restore just fine

2

u/Torutofu_Raeva 24d ago

scheduled restore into a throwaway vm then run gitlab-rake gitlab:check and gitlab:doctor:secrets, that's what catches a missing gitlab-secrets.json before you actually need it

2

u/Snowy32 24d ago

Restore it on a test instance

1

u/firefarmer 23d ago

Stand up a replica of your production environment and test it.

  1. I have staging and production environments. Staging is a smaller size compared to production but I destroy staging, build it from scratch using IaC, then test a restore of production on staging at least once a quarter.

  2. For our FEDRAMP GitLab we ran into this failure https://gitlab.com/gitlab-org/gitlab/-/work_items/587492 Before that I never saw a failure with restore.

  3. You test in a staging environment so no downtime. In hours, it costs cloud resources and my time. The restore command to perform a backup does take a while; like 6-ish hours.

  4. No, I have the cloud resources automated but not the backup/restore operation; that is documented with a few manual steps. We talk about automating it but haven’t yet. Not sure why you would pay for an external tool. Gitlab makes it pretty straight forward.

  5. 700+ users; thousands of repos.

1

u/kbp80 21d ago

I actually have done this recently, and did a restore to a new machine, with same gitlab version. And my container images did not restore for some reason… I’m still trying to figure that out. And also to figure out if it really is 100% complete (other than the missing container registry entries).

Your questions:

  1. ⁠How do you test a restore today (never, manually now and then, scripted)?
    - Manually right now, working on an ansible scripted method

  2. ⁠When did a restore last fail or surprise you (missing gitlab-secrets.json, version mismatch, DB errors)?
    - Missing docker registry container images, missing secrets. I avoided the version mismatch by explicitly installing a matching version as I already knew this would be an issue.

  3. ⁠What did that cost you in hours or downtime?
    N/A

  4. ⁠Have you paid for a tool or written your own script for this? What and how much?
    Written my own script, some of bash, some of ansible; now using AI (Claude) to improve

  5. ⁠How many repos or users is your instance?
    My instances are small - like 20 users, but several hundred repos