change: improve backup restore #113

Merged
jkeffects merged 19 commits from feature/#76-improve-backup-restore into develop 2026-11-03 12:53:32 +00:00
Owner

Closes #76

Closes #76
mission_protocol_file keeps its wrapped keys as base64 text. The rotation read them raw and passed the string to
unwrapKey, which threw and counted every key as unreadable: the keys stayed with the old secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
configure only added values to the cache, so a setting removed by a restore stayed active until the next start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The list of encrypted columns moves out of the rotation, as the backup needs it as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tables are read and written without entities or transformers, every cell as text and cast back by its real column
type: json numbers lose digits of numeric and bigint. New tables and columns need no adjustment. One parameter per
statement removes the limit of 65535 parameters and the row order problem of self references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Encrypted cells are detected by decrypting them, the auth tag makes this reliable. This covers legacy values and
columns nobody registered. The registration is only needed to tell unreadable values from text and for wrapped keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every restore now brings all values to the current format and keys inside its transaction, no restart is needed.

- the file is read once, what is checked is what gets restored
- values nobody can read never replace a working one and are part of the returned report
- settings and module settings come back on a restore, they were skipped for every instance
- isOwner, mail and login data of existing users can not be set by a backup, new users never become owner
- dependencies of a selection are only completed, not overwritten
- crypto material of format 2 files survives, the buffers were written as [object Object]
- the api is enabled after the commit and a restore point is created after the checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
decrypt and entityBaseCoding no longer know the legacy format. Only conversions read it: the startup conversion for
databases of older versions and the backup path. A technical failure of the startup conversion keeps the api disabled
now, as regular reads could not open legacy values otherwise. Unreadable values still do not prevent the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Header readable without keys and bound to the payload as AAD, gzip and AES-256-GCM with a random data key. The data key
is wrapped by a key of the instance or a passphrase. It lives outside the AAD, so a rotation only replaces this block.
The key id tells apart a foreign file from a changed one. The keys do not depend on EncryptionHelper.configure, as
backups also run in applications without file encryption and in migrations by the typeorm cli.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Backups are read from the raw tables and hold neutral values, so they do not depend on the format or keys of a value.
Legacy values and columns nobody registered are covered by the detection, a value which fails to decrypt no longer ends
up empty. Format 2 stays restorable.

- a changed file is rejected, also with ignoreManipulation
- auto-restore skips changed and foreign files and takes the newest safe one
- a secret rotation moves backups to the new keys, its restore point stays with the old ones
- withFallbackKeys is gone, it only existed for the entity based backup during a rotation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore takes tables, a conflict rule and whether missing rows get removed, which replaces keepNewerData. The preview runs
the same way as a restore and rolls it back, so its numbers can not differ. It also names the table of a conflict.

Exports hold selected tables and are protected by a passphrase, so another instance can read them. A reference which
must not be empty brings its table along. An optional one is cleared by default, otherwise master data could pull
personal data into the file.

- core tables need the owner, format 2 needs the owner and a confirmation instead of ignoreManipulation
- sessions only end if core tables were restored, so importing master data logs nobody out
- BackupHelper.registerTableGroups names tables for the selection, the rest ends up in "other"

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BACKUP_UPLOAD_MAX_SIZE limits uploads, default 200 MB. The file type is checked by its extension instead of the mime type
sent by the client, the file name can not leave the folder and a file which is no backup is removed right away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The export modal needs the groups and core tables before anything is selected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PackageConfigVals.applicationKey replaces the displayed name in the header, as different applications can share a name.
Restore hooks also get the conflict rule and whether it is a preview, they run in a preview as well. A backup warns about
encrypted binary data, which only opens with the keys it was created with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The version was fixed in the code, so nobody could use the rewrap. Raising the optional env moves all wrapped keys without
changing secret, salt or tokens. All versions derive from the same secret, a leaked secret still needs the rotation.
The daily rewrap only reads the header of a file now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A column with this transformer can not be forgotten in a secret rotation anymore. CodingHelper.isReadable lets callers
check a stored value before they derive something from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
change: logout on restore
Some checks failed
ci / Lint (pull_request) Has been cancelled
ci / Build (pull_request) Has been cancelled
ci / Lockfile (pull_request) Has been cancelled
ci / Status im Pull Request (pull_request) Has been cancelled
pr-title / Titel (pull_request) Has been cancelled
bd00b0cf0d
Merge branch 'develop' into feature/#76-improve-backup-restore
All checks were successful
ci / Lockfile (pull_request) Successful in 3m8s
pr-title / Titel (pull_request) Successful in 3m6s
ci / Lint (pull_request) Successful in 3m17s
ci / Build (pull_request) Successful in 3m17s
ci / Status im Pull Request (pull_request) Successful in 3m7s
1723d4bad9

✅ CI-Prüfung

Prüfung Ergebnis
Lint ✅ bestanden
Build ✅ bestanden
Lockfile ✅ bestanden

Details und Logs: CI-Lauf

<!-- ci-status --> ### ✅ CI-Prüfung | Prüfung | Ergebnis | |---|---| | Lint | ✅ bestanden | | Build | ✅ bestanden | | Lockfile | ✅ bestanden | Details und Logs: [CI-Lauf](https://code.jk-effects.cloud/FF-Admin/ff-admin-core-server/actions/runs/4299)
jkeffects merged commit 11218d8051 into develop 2026-11-03 12:53:32 +00:00
jkeffects deleted branch feature/#76-improve-backup-restore 2026-11-03 12:53:32 +00:00
jkeffects referenced this pull request from a commit 2026-11-03 22:26:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
FF-Admin/ff-admin-core-server!113
No description provided.