Learn / Infrastructure / Lesson 11

Backups and secrets

A backup you have never restored is a hope, and a password in a git repository is public. One company that nearly lost everything, one that did, and one that hid a breach for a year.

Last updated: 2026-09-19

What it is

Backups are copies of your data you can bring back after a mistake, a failure or an attack. Secrets are the keys to everything else: database passwords, API tokens, signing keys. One protects you from losing data; the other protects you from someone else taking it.

Why it is a rule

Backups

Secrets

How to do it

Backups: 3-2-1, and practise the restore

Secrets: never in git

gitignore
.env
.env.*
!.env.example
*.pem
*.key

Least privilege

Each key can do only its job. The web app's database user cannot drop tables. A deploy token cannot read customer data. A leaked key then opens one door, not all of them.

Rotate

Change secrets on a schedule and immediately when someone leaves or a key may have leaked. Build it so rotating is a routine step, not an emergency.

How we do it here

Secrets live only in the hosting provider's environment, and the repository's ignore file has a secrets block at the top that is never shortened. The server lists any missing secret at boot. Database dumps taken before a migration are kept out of git because they hold real client rows.

Benefits

Disadvantages

Checklist

Sources

Read this lesson as Markdown