Backup / The encryption key
The encryption key
A store that keeps encrypted buckets seals their values with its encryption key. A backup leaves the key out unless asked: a zip without it shows nothing of the sealed values, and a zip with it opens them all. Which one you want depends on where the backup goes.
const plain = await store.backup('backups/nightly.zip') // { files, bytes, keyLeftOut: true }
const full = await store.backup('backups/full.zip', { include: ['app.json'], includeEncryptionKey: true })plain = await store.backup("backups/nightly.zip") # key_left_out=True
full = await store.backup("backups/full.zip", include=["app.json"], include_encryption_key=True)plain, err := store.Backup(ctx, "backups/nightly.zip") // KeyLeftOut: true
full, err := store.Backup(ctx, "backups/full.zip", tinystore.Include("app.json"), tinystore.IncludeEncryptionKey())tinystore backup ./data backups/full.zip --include app.json --include-encryption-keyWhich to choose
| The backup goes to | Choose |
|---|---|
| object storage, another team, a place you do not own | without the key; keep the key in a secret manager |
| a disk you trust as much as the store's own | with the key, so one file restores everything |
- A store that seals values says so of a backup without the key:
keyLeftOutin the answer and in the manifest. A store that seals nothing answersfalse, since nothing is missing. - The zip itself is not encrypted, even with
includeEncryptionKey, which puts the key in the zip as it is. What the engines keep in the clear, rows, events, samples, files, is in the clear in it: keep a backup as safely as the store's directory, or encrypt it where you keep it. - A backup takes the key that seals, never the
older keys. While a value is sealed with an
older key, a backup with the key still says
keyLeftOut. Callresealon each encrypted bucket first, or keep the older key beside the backup. - While values are sealed,
includeEncryptionKeyfails withio, and writes no zip, when the key is not where the store reads it. That happens totinystore backupbeside a server that keeps its key apart with--encryption-key-file, since a backup beside a server reads the key from the store's directory alone.
Restoring without the key
A backup without the key restores like any other, and says what is missing:
● ./data restored from backups/nightly.zip · 1 files, 52 KiB
its encrypted buckets open with the store's key, which the backup left out: put it back firstPut the key back as encryption.key in the restored directory, or open the
store with encryptionKeyFile naming where you keep it. Until then, every
other bucket, table and file reads, and opening an encrypted bucket fails with
an io error that names the missing key. If the key is lost for good, put a
new one there, as Older keys shows. Nothing
recovers a sealed value without its key: keep a copy apart from the backups
that leave it out, and test a restore with it.
The program's own files
include takes a file of the program's by its path inside the store's
directory, / between its parts, and a restore puts it back where it was. A
path outside the directory, or one of the store's own files, an engine's
file, LOCK, the key, is invalid; the key goes only through
includeEncryptionKey.
backup: "encryption.key": the store's encryption key, which include_encryption_key() takes: invalidSee also
- Backup: the engine's overview.
- Encrypted buckets: what the key seals.
- Restore.