Introduce immutable job IDs across all job-dependent data and workflows
Summary
Jobs currently have no immutable identity. Their effective identity is derived from mutable and overloaded values, primarily:
job_key = <type_id>_<location>
archive_prefix = <type_id>-backup
The wizard exposes Type ID even though it is not a real job type. The same user input is used to derive the job key, archive prefix, filenames, cache paths, log correlation, status grouping, and joins across dependent stores. The system also appends -backup without making the complete stored archive prefix an explicit user-owned value.
Changing Type ID or location therefore looks like deleting one job and creating another to parts of the application. This causes stale or duplicated dashboard entries and can disconnect historical status, reports, restore tests, schedules, notifications, widgets, repository assignments, and restore history from the logical job the user edited.
Introduce a generated immutable job_id, remove Type ID from the new user-facing and canonical job model, and make the complete archive prefix explicit. Use job_id as the only canonical foreign key across every job-dependent subsystem.
This is an application-wide architecture migration, not a dashboard-only fix.
Current problem
Today different areas infer job identity or behavior from one or more mutable values:
- job metadata filename and
job_key, backup_type/ Type ID,location,- status and log filenames,
- archive prefixes derived by appending
-backup, - repository
used_by/source_job_keys, - schedule map keys,
- restore-test filenames,
- runtime control paths and locks.
For example, changing paperless_storagebox to documents_storagebox removes the old metadata key but keeps historical paperless_storagebox status files. The dashboard currently starts with all status keys and only adds missing configured jobs, so both identities may be displayed even though only one configured job exists.
The UI model is also unclear:
Job name: user-facing display label
Type ID: technical fragment with several hidden consequences
Location: repository/storage property and part of the inferred identity
A user entering paperless does not directly own or see every value derived from it.
Goals
- Give every job a generated UUID that never changes during the lifetime of that job.
- Use
job_idas the only canonical foreign key between job-dependent stores and runtime services. - Replace the user-facing Type ID with an explicit complete archive prefix.
- Do not append hidden text to the archive prefix entered or accepted by the user.
- Keep the job name, archive prefix, repository assignment, icon, description, sources, and operational settings editable.
- Derive location from the selected repository and its storage target instead of using it as identity.
- Preserve the existing
archive_prefixesbehavior: the current prefix is first and previous prefixes remain available for restore and retention scoping. - Preserve historical descriptor values as run-time snapshots without using them as identity.
- Keep exactly one dashboard/widget entry per configured job.
- Preserve reports, history, restore tests, restore runs, and archive access across job name and archive-prefix changes within the current repository.
- Migrate existing installations once, atomically, idempotently, and with a complete audit trail.
- Preserve ambiguous legacy data without guessing or silently linking it to the wrong job.
Non-goals
- Do not replace readable Borg archive prefixes with UUIDs.
- Do not use UUIDs as authentication tokens or secrets.
- Do not delete old status, report, restore-test, restore-history, or archive data merely because it cannot be linked automatically.
- Do not keep two permanent internal identity systems after migration.
- Do not add repository assignment history.
- Do not search multiple current or historical repositories for one job.
- Do not move or copy archives when a repository assignment changes.
- Do not change repository deletion rules as part of this issue.
- Do not silently merge jobs because their names, prefixes, repositories, or legacy keys match.
The user-safety warning and confirmation for changing a job repository are tracked separately in #452.
Canonical job model
Example target metadata:
{
"schema_version": 4,
"job_id": "6cd32490-99e2-45df-bafb-81b942decd82",
"name": "Paperless Backup",
"repository_key": "repo_paperless",
"archive_prefixes": [
"documents-backup",
"paperless-backup"
],
"legacy_job_keys": [
"paperless_storagebox"
]
}
Identity and metadata rules:
job_idis generated once with UUIDv4 and is immutable.- The metadata filename is
<job_id>.json. - New jobs do not use
job_key,backup_type, Type ID, or location as identity or canonical active metadata. nameis the editable display label.repository_keyis the one current repository assignment.archive_prefixesis an ordered, de-duplicated list.archive_prefixes[0]is the complete current prefix used for new archives.- Remaining
archive_prefixesentries are previous complete prefixes used to find and manage existing archives in the current repository. - The wizard displays and edits the complete current prefix exactly as stored. It does not append
-backupor another hidden suffix. - A new job may receive an editable archive-prefix suggestion derived from its display name, but the preview must show the exact resulting archive pattern before save.
- When the current prefix changes, the previous prefix is retained in
archive_prefixes. legacy_job_keysexists only for migration, legacy-data resolution, and a bounded API compatibility period. It is never a new active foreign key.- Duplicating or importing a job as a new job always creates a new
job_id. - Updating an existing job retains its
job_id. - Location is resolved from the current repository and storage context. Historical records may retain the location used for that run as a snapshot.
Wizard model
The primary identity and naming fields become:
Job name: Paperless Backup
Archive prefix: paperless-backup
Repository: Paperless repository
Job ID: internal and non-editable
The wizard must show an exact preview such as:
paperless-backup-2026-09-02_03-00-00
Required behavior:
- Do not show
Type IDfor new or migrated jobs. - Do not derive an active key from archive prefix plus location.
- Validate the complete archive prefix as a safe Borg archive-name prefix.
- Keep the current prefix first in
archive_prefixes. - Explain that changing the prefix affects new archives while previous prefixes remain available in the current repository.
- Preserve all existing job-specific settings when only the name or prefix changes.
- Handle repository-change confirmation through #452.
Run status model
New status records include immutable identity and descriptive run snapshots:
{
"job_id": "6cd32490-99e2-45df-bafb-81b942decd82",
"job_name": "Paperless Backup",
"archive_prefix": "paperless-backup",
"repository_key": "repo_paperless",
"location": "storagebox",
"archive_name": "paperless-backup-2026-09-02_03-00-00",
"status": "success"
}
Snapshot fields do not need an _at_run suffix because a run record is inherently historical. Legacy records may retain backup_type and job_key, but new records and readers must not use them as canonical identity.
Status and log filenames remain readable for administrators. Use the archive prefix or a bounded display slug captured for the run plus a short UUID suffix, for example:
2026-09-02_03-00-00_paperless-backup--6cd32490.status
Borg-Backup_paperless-backup--6cd32490--2026-09-02_03-00-00.log
The complete UUID remains in the JSON payload, runtime state, and structured log context. The short suffix is only a human-friendly correlation aid and is not used as identity. Readers use payload or persisted run metadata as the source of truth and never infer canonical identity from a readable filename.
Repository assignment boundary
A job has exactly one current repository_key.
When the repository assignment changes:
job_idremains unchanged.- The old current assignment is removed atomically.
- The new current assignment is added atomically.
- Future backups use only the new repository.
- Existing archives are not moved or copied.
- Browse & Restore for the job uses only the current repository.
- Historical run records may display the repository used at that time as a snapshot.
- No
repository_historyis added to the job.
The dedicated warning and explicit confirmation are implemented separately under #452.
Dependency inventory and required target behavior
| Area | Current dependency | Required behavior with job_id |
|---|---|---|
| Job metadata and discovery | Metadata filename, job_key, backup_type, and location |
Store and discover by immutable job_id; expose name, archive prefixes, and current repository separately |
| Wizard create/edit | Type ID and location derive identity and archive prefix | Create UUID once; edits retain it; edit the complete current archive prefix explicitly |
| Jobs API and UI actions | Run, cancel, enable, edit, delete, and live log use job_key |
Address actions by job_id; return readable name and prefix separately |
| Dashboard | Starts from latest .status per mutable key and supplements configured jobs |
Start from configured jobs by job_id; overlay latest run, runtime state, schedule, restore proof, and repository details |
| Unraid dashboard widget | Joins job/status/cache data by current key | Cache and aggregate by job_id; one widget row/count per configured job |
| Homepage widget API | Reads metadata/status/schedules by job_key |
Use job_id internally and return readable descriptors for display |
| Backup status | Filename and payload use Type ID plus location | Write job_id; keep name, archive prefix, repository, and location as run snapshots |
| Weekly repository snapshots | Maps sizes by mutable status key | Key snapshots by job_id; preserve historical descriptor metadata where useful |
| History | Parses Type ID/location from status filenames | Read status payload and group/filter by job_id; support unassigned legacy records |
| Reports | Discovers report jobs and time series from filenames and parsed job_key |
Select and aggregate by job_id; name/prefix changes remain one continuous report |
| Report mail | Matches planned jobs, metadata, schedules, and statuses by key | Join by job_id; intentionally display current job labels and historical run snapshots |
| Browse and Restore | Uses job_key to resolve repository and archive-prefix filters |
Select by job_id; resolve the current repository and ordered archive_prefixes |
| Archive naming and retention | Prefix is derived from Type ID | Use the explicit current archive_prefixes[0]; keep readable historical prefixes for the current repository |
| Restore precheck and execution | Request and persisted run contain job_key |
Store job_id plus run-time job, repository, prefix, and archive snapshots |
| Restore history | Summary/detail/index store job_key |
Store and filter by job_id; keep historical display descriptors |
| Restore tests | <job_key>.test, policies, and plan rows use key |
Use <job_id>.test; result payload, policy, scheduling, reminders, and proof map use job_id |
| Schedules and cron | schedules.json is keyed by job_key; cron posts job_key |
Key schedules by job_id; cron posts job_id; readable descriptors remain diagnostic only |
| Repository assignment | Repository used_by and source_job_keys contain mutable keys |
Replace with job_ids / source_job_ids; derive display labels from current job inventory |
| Repository reconciliation | Compares repository links to metadata job_key |
Reconcile immutable IDs and report missing IDs explicitly |
| Repository maintenance | Job lookup and archive filtering use mutable key or derived prefix | Resolve by ID, then use current repository and explicit prefix list |
| Runtime manager | In-memory state and subprocess environment are keyed by job_key |
Key runtime state by job_id; include readable values only in logs and snapshots |
| Cancellation control | Runtime paths, control state, and validation use key | Stable control ownership by job_id and independent run_id |
| Resource locks | Lock owner and conflict messages use job_key |
Lock owner is job_id; messages resolve current display labels |
| Runtime recovery | Recovery state stores Type ID/location | Store job_id and run snapshots so recovery remains stable after edits |
| Log files and live log | Filename and lookup use mutable job key/type | Use stable ID for lookup; keep readable prefix/name in filenames and content |
| Notifications | Events contain job_key, Type ID, and location |
Correlate by job_id; retain descriptive run snapshots |
| Reminder state | Deduplication keys contain job_key |
Use job_id to prevent duplicate or lost reminders after edits |
| Overdue detection | Joins schedules, jobs, and latest status by key | Join all three by job_id |
| Source manifests | Proposed manifests would otherwise be job-keyed | Name and associate manifests by job_id |
| Import/export | Collision handling rewrites job_key; selected jobs use keys |
Define preserve, merge, duplicate, and collision rules for IDs |
| Configuration backup/restore | Job files and dependent stores use mutable filenames/keys | Include and validate all ID-based references as one consistent configuration set |
| Support bundle | Diagnostics expose mutable keys from several stores | Include job_id and bounded readable descriptors; add referential-integrity diagnostics |
| System health | Checks metadata/repository assignments by key | Detect duplicate/missing IDs and dangling ID references across active stores |
| Job deletion | Deletes artifacts by Type ID and location patterns | Delete only artifacts referencing selected job_id; require explicit artifact deletion confirmation |
| Factory reset | Removes all stores independently | Include all new ID-based stores/indexes without changing confirmation semantics |
| API logging/security context | Logs job_key |
Log job_id and bounded readable descriptors; UUID is not secret |
Dashboard and live-state rules
The configured job inventory is authoritative.
For every configured job_id, the dashboard combines:
- current job metadata,
- latest completed status for that
job_id, - active runtime state for that
job_id, - schedule and overdue state,
- restore-test proof,
- cached repository information.
Historical status records that no longer map to a configured job never create an additional dashboard card or affect current job counters.
If a migrated job has no new ID-based status yet, its latest unambiguously mapped legacy status may be shown with an indicator such as Last run before identity migration. After the first new run, the normal ID-based status takes precedence.
Reports, history, and historical labels
Reports and History keep continuity when a job is edited:
- filtering and grouping use
job_id, - the current job name is used for navigation,
- each historical row may display the name, archive prefix, location, and repository captured for that run,
- changing name or archive prefix does not split one logical job into multiple reports,
- changing the current repository does not change report identity,
- deleted jobs may remain available as historical jobs identified by former
job_id, - ambiguous legacy records are shown separately as unassigned legacy history and are never attached by guesswork.
A historical repository_key is a run snapshot, not an active repository assignment.
Browse and Restore
Browse & Restore selects a job by job_id and resolves:
- the one current repository assignment,
- the ordered current and historical archive prefixes stored in
archive_prefixes, - the current job display name.
The UUID never becomes part of the Borg archive prefix. Existing human-readable archives remain valid.
Repository assignment history is explicitly out of scope. After a repository change, the job uses only the new repository for Browse & Restore. Existing archives remain unchanged in the previous repository. Issue #452 provides the required warning and confirmation.
Restore tests
Restore-test policy and results belong to job_id.
Required behavior:
- job name and archive-prefix changes do not reset proof status,
<job_key>.testbecomes<job_id>.test,- scheduled and manual tests submit
job_id, - overdue reminders and verification maps join by
job_id, - result payload retains archive, repository, prefix, location, and display-name snapshots,
- deleted jobs can retain historical restore-test results without appearing in the active plan.
Import/export identity rules
- Import as a new job: always generate a new
job_id, even if the exported source contains one. - Merge/update an explicitly selected existing job: retain the target installation's
job_id. - Full configuration restore onto the same installation: preserve IDs when referential integrity is valid.
- Importing a complete configuration onto another installation: preserve IDs only when there is no collision; otherwise require an explicit remap plan.
- Duplicate job action: generate a new ID.
- Never silently merge jobs because name, archive prefix, repository, or legacy key happens to match.
- Export bundles include an ID reference map and validate that all selected dependent objects are present.
Migration design
Proposed migration ID:
immutable_job_id_v1
The migration runs before the scheduler, background writers, widget refresh, or writable APIs become available.
Detect phase
Inventory and validate:
- all canonical job metadata,
- legacy metadata filenames,
job_key,backup_type, location, and existingarchive_prefixes, - repository
used_by/source_job_keys, - schedules,
- active and archived
.statusfiles, - weekly snapshots,
- restore-test files and policies,
- restore active runs and restore history,
- notification/reminder state,
- runtime recovery state,
- widget cache,
- source manifests if present,
- job-keyed logs or control metadata that must survive restart.
Detection returns required: true when any active job lacks a valid UUID, canonical metadata still uses a mutable identity, or a persistent active reference still uses a mutable key.
Planning phase
- Build the complete legacy-key-to-UUID plan before modifying data.
- Reuse an already journaled UUID if an interrupted attempt is resumed.
- Match current jobs by exact canonical legacy metadata key first.
- Determine the current explicit archive prefix from the ordered existing
archive_prefixeswhen present; otherwise derive the legacy value once frombackup_typeby appending-backup. - Preserve and normalize every valid existing prefix without inventing a second prefix-history model.
- Use explicit legacy aliases only when they produce one unambiguous match.
- Never infer identity from display name alone.
- Mark ambiguous or orphaned historical records as unassigned legacy data.
- Abort before writes if active configuration references are ambiguous or inconsistent.
Snapshot phase
Create a migration snapshot containing every affected persistent object, including:
- job metadata directory,
- repository and storage inventories as applicable,
- schedules,
- status and archived-status records,
- weekly snapshots,
- restore tests,
- restore runs and restore-history index/details,
- notification state,
- runtime recovery state,
- widget cache and persistent source manifests.
Write the migration plan and checksums into the snapshot. Do not include secrets beyond files already required by affected configuration, and never log secret values.
Apply phase
- Assign and persist one UUID per active job.
- Normalize
archive_prefixesso the current complete prefix is first and prior prefixes remain de-duplicated. - Remove Type ID, location, and mutable
job_keyas active canonical identity fields after dependent readers are converted. Preserve only bounded legacy aliases required by the migration contract. - Rename canonical job metadata files to
<job_id>.json. - Convert repository current-assignment references to job IDs.
- Convert schedules to job IDs and regenerate cron entries.
- Add
job_idto unambiguously mapped status records while retaining historical descriptors. - Convert weekly snapshot keys to IDs and merge same-job/same-period entries deterministically.
- Rename and update restore-test result files.
- Add IDs to restore active runs and restore history records.
- Convert reminder/deduplication state without sending duplicate notifications.
- Convert runtime recovery records that must survive restart.
- Rebuild the widget cache from migrated canonical data.
- Invalidate all in-memory job, repository, status, and widget caches.
- Verify all active references before marking the migration applied.
Old historical filenames may remain unchanged if their payload has a valid job_id; readers must not depend on the filename. New files use ID-based lookup with readable diagnostic names.
Verification phase
Verify:
- every active job has one unique valid UUID,
- no UUID is shared by two jobs,
- every active job has a non-empty ordered
archive_prefixeslist, - the first prefix is the exact prefix used for new archives,
- no new archive path appends a hidden suffix to that prefix,
- every active schedule references an existing job ID,
- every current repository job reference resolves,
- every restore-test policy/result resolves or is classified as legacy/unassigned,
- all mapped statuses resolve to exactly one job ID,
- current dashboard counts equal the configured active-job set,
- Browse & Restore resolves the same current repository and all stored archive prefixes,
- notification reminder state cannot generate duplicate reminders,
- no writable service starts when verification fails.
Failure and retry behavior
- Follow the existing startup migration contract and audit format.
- Record
pending,applied,skipped,failed,blocked, ornot_applicable. - The operation is idempotent.
- Re-running after success performs no changes.
- Re-running after interruption uses the persisted migration plan and UUID mapping.
- On the first failure, later migrations remain blocked and normal writes/scheduling stay disabled.
- Do not automatically roll back the installed plugin version.
- Keep the migration snapshot for manual recovery and expose details under System Health and Migration.
Compatibility boundary
During a defined transition period, API request parsing may accept a legacy job_key and resolve it through the migrated alias map.
This is boundary compatibility only:
- all internal joins and newly persisted active data use
job_id, - UI requests use
job_id, - legacy-key use is logged as deprecated without exposing secrets,
- ambiguous aliases fail explicitly,
- new jobs do not create new
job_keyidentities, - no permanent dual-write identity model remains.
Advantages
- Editing a job no longer creates an apparent second job.
- The wizard exposes the value that actually controls archive naming.
- Users see the complete archive prefix and exact archive pattern before saving.
- Dashboard and widget counts remain based on configured jobs.
- Reports and History remain continuous across name, prefix, repository, and storage changes.
- Restore tests and reminders remain attached to the logical job.
- Repository links, schedules, runtime state, cancellation, and locks become stable.
- Existing
archive_prefixescontinuity is preserved without repository history. - Future source manifests and other job-specific features gain a safe owner key.
- Deleting one job cannot accidentally match another job's artifacts by filename pattern.
- Referential-integrity checks become possible and meaningful.
Disadvantages and risks
- This is a broad, high-risk migration touching nearly every job-dependent subsystem.
- UUIDs are less readable in files and diagnostics, so UI and logs must resolve friendly labels.
- Removing Type ID requires every remaining behavior to use explicit metadata instead of inferred semantics.
- Old or already orphaned historical records may not be assignable automatically.
- Import/export collision behavior becomes more complex.
- External scripts or bookmarked internal API calls using
job_keyneed a bounded compatibility window. - Status, report, and restore readers must support legacy artifacts during transition.
- The implementation must be split into carefully reviewable stages while preserving one atomic migration contract.
Required test coverage
Identity and job lifecycle
- UUID generation, validation, uniqueness, and immutability.
- Create, edit, rename, archive-prefix change, repository change, and storage/location change.
- Duplicate and delete behavior.
- Job discovery from ID-named metadata.
- No Type ID or derived mutable identity for new jobs.
Archive prefix and wizard
- New jobs store the complete user-visible prefix exactly.
- No hidden
-backupsuffix is appended. - Prefix preview matches the archive name produced by the runner.
- Editing a prefix keeps the new prefix first and preserves prior prefixes.
- Existing
archive_prefixesmigrate without loss or duplication. - Restore and prune use the explicit prefix list.
- Repository-change confirmation remains owned by #452.
Migration
- Fresh installation: migration not applicable.
- Existing installation with one and multiple jobs.
- Jobs with and without existing
archive_prefixes. - Idempotent second run.
- Interrupted run reuses the journaled UUID map.
- Invalid and duplicate active references block migration.
- Ambiguous historical records remain unassigned.
- Snapshot completeness and audit output.
- No later migration or writable service after failure.
Status, dashboard, and widgets
- One card per configured job.
- Edits do not create a second card.
- Legacy status continuity before the first ID-based run.
- Active runtime state overrides the last completed state for display.
- Orphaned history does not affect active counters.
- Widget cache and Homepage widget use the same identity rules.
Reports and History
- Continuous time series across name, prefix, repository, and storage changes.
- Historical labels remain accurate.
- Deleted-job history remains accessible.
- Unassigned legacy history is visible but not merged.
- Weekly snapshots migrate without duplicate periods.
Browse, Restore, and Restore Tests
- Archive filtering uses the complete ordered prefix list in the current repository.
- Restore requests and persisted history use
job_id. - Name and prefix edits keep restore history and restore proof.
- Restore-test files, schedules, policies, reminders, and results migrate correctly.
- Repository changes use only the current repository and never move archives.
Repositories, schedules, and runtime
- Current repository references reconcile by ID.
- Cron invokes jobs by ID.
- Overdue detection joins by ID.
- Runtime state, cancellation, locks, and recovery remain stable during edits.
- Notifications and reminders do not duplicate after migration.
Import/export and diagnostics
- New import, merge, full restore, duplicate, and collision cases.
- Support bundle contains identity diagnostics without secrets.
- System Health reports duplicate IDs, dangling references, and unresolved legacy data.
Acceptance criteria
- Every active job has exactly one immutable UUID.
- Metadata files are named
<job_id>.jsonand discovered by ID. - Changing job name, archive prefix, repository, or storage does not change
job_id. - All active job-dependent areas use
job_idinternally. - New and migrated jobs do not use Type ID,
backup_type, location, orjob_keyas active identity. - The wizard replaces Type ID with the complete editable archive prefix.
- The exact prefix shown in the wizard is used for new archive names without hidden additions.
archive_prefixes[0]is current and previous valid prefixes remain available in the current repository.- Dashboard and widgets display only configured jobs and exactly one entry per job.
- Reports, History, Browse & Restore, restore history, and restore tests retain continuity across job edits within the defined current-repository boundary.
- A repository change does not move archives or add repository history; the separate warning is tracked in #452.
- Archive names remain readable and existing archives remain accessible in the current repository through stored prefixes.
- Existing installations migrate automatically with snapshot, audit log, idempotence, and failure blocking.
- No user data is silently deleted or assigned to an ambiguous job.
- Legacy compatibility is limited to explicit read/resolve boundaries and is not a permanent second identity model.
Phased delivery plan
Issue #447 is delivered through one long-lived integration branch and one final implementation pull request:
- Integration branch:
codex/issue-447-immutable-job-ids - Pull request: one draft PR from the integration branch to
main - Phase work: separate sub-issues and clearly separated commits on the shared branch
- Merge boundary: no phase is merged or released independently
- Stable release: a separate release PR only after the complete test candidate is explicitly approved
Parallel hotfixes continue on independent branches from main. After each hotfix is merged, current origin/main is merged into the #447 integration branch without rebasing or force-pushing. The final test candidate is created only after the last such synchronization.
Implementation phases
- #471 - Freeze the immutable identity contract and migration fixture matrix.
- #472 - Build the inactive migration planner, snapshot, journal, and verifier.
- #473 - Introduce canonical ID-based job metadata and replace Type ID in the wizard.
- #474 - Cut over job APIs, repository assignments, and schedules to
job_id. - #475 - Cut over backup runtime, status, logs, locks, recovery, and notifications.
- #476 - Cut over dashboard, widgets, History, Reports, and overdue state.
- #477 - Cut over Browse and Restore, restore history, and restore tests.
- #478 - Cut over import, configuration recovery, deletion, and identity diagnostics.
- #479 - Activate
immutable_job_id_v1and qualify the end-to-end test candidate.
The ordering is intentional. Later phases depend on the contracts and converted stores from earlier phases. Completion of a sub-issue means its scoped code and automated tests are complete on the integration branch; it does not mean that the intermediate application state is installable or releasable.
Test-channel gate
Phases 1-8 do not require or justify a test-channel package merely because their individual code is complete. Until the real migration and every required reader/writer are integrated, an installed intermediate version may not start normally or may have no safe complete workflow to test.
The first test-channel candidate is produced only in #479 after all of the following are true:
- the migration detects, plans, snapshots, applies and verifies representative legacy states;
- invalid or ambiguous active states block before unsafe changes;
- a successful migration releases startup, scheduler and writable APIs;
- the migrated application can edit and schedule a job, complete a backup, preserve retention scope, browse archives, restore data and complete a restore test;
- restart and retry are idempotent and reuse the same UUID mapping;
- the complete automated migration matrix and full source preflight pass;
- documentation, backup warning, failure guidance and release notes are complete.
If there is no safe end-to-end behavior for a user to verify, no test package is published. Development continues with unit, fixture and isolated integration tests instead.
Related dependency
Issue #470 remains blocked until #447 is fully completed because managed per-job exclusion files require the immutable job-owned storage contract.
Scope clarification agreed during architecture review:
- Jobs keep a single current
repository_key; repository assignment history is out of scope. - Changing the repository remains a deliberate reassignment. Existing archives are not moved and are no longer resolved through that job in Browse & Restore.
- The missing warning and explicit confirmation are tracked separately in #452.
- Historical archive prefixes are already persisted in
archive_prefixes, appended during Type ID changes, and used by Restore. Issue #447 must preserve and migrate this existing behavior under the immutablejob_id; it must not introduce a second prefix-history model.
Deep code and migration analysis
Analysis baseline: main at 65120ed4c55e4c823f6a72baf85116b6d30d5922 (2026-09-02).
Verdict
READY WITH CHANGES
The central direction of this issue is correct: jobs need an immutable UUID, Type ID must stop acting as an overloaded identity field, and the complete archive prefix must become explicit. However, the current issue text should not be implemented unchanged. The code analysis found several missing persistent stores, unsafe migration assumptions, and scope items that do not exist in the current production path.
This comment records the implementation analysis and its recommendations. Recommendations that still require a maintainer decision are listed explicitly at the end so they can be accepted or overridden in follow-up comments before the issue body is reconciled.
A. Current identity model
The effective legacy identity is currently:
job_key = backup_type + "_" + location
archive_prefix = backup_type + "-backup"
This is not confined to the wizard or dashboard. The mutable key is used by job discovery, run/cancel operations, schedules, status and history, reports, restore, restore tests, repository assignment metadata, notifications, runtime recovery, locks, logs, and widgets.
run_id already exists as a separate identity for an individual backup execution. restore_id similarly identifies one restore execution. Neither should be replaced by job_id; the three identifiers have different lifetimes:
job_id -> logical configured job
run_id -> one backup execution
restore_id -> one restore execution
B. Confirmed parser defects
Some readers reconstruct identity from filenames instead of reading the payload. This already breaks valid Type IDs containing underscores.
Example:
testdaten_history_local.status
can be parsed as Type ID testdaten and location history_local, although the actual job is testdaten_history at local.
This affects at least History and restore-test status parsing. The target implementation must never infer canonical identity from a readable filename. The JSON payload and persisted job_id are authoritative.
C. Archive-prefix migration
The current backup runner still creates new archive names from:
backup_type + "-backup"
Therefore, during migration, the current prefix must be derived from the behavior of the legacy runner and placed at archive_prefixes[0]. Existing archive_prefixes must be preserved, normalized, and de-duplicated, but an existing list must not blindly override the prefix that the active legacy runner actually uses.
Recommended semantics:
archive_prefixes[0]is the only prefix used for new backups.- Browse & Restore searches all prefixes in the currently assigned repository.
- Initial prune/retention operations use only
archive_prefixes[0]. - Applying current retention rules to historical prefixes should be a separate, explicit opt-in feature.
The last point avoids unexpectedly deleting older archive series merely because their prefix is retained for restore discovery.
D. Repository assignment and reverse references
Jobs already provide the authoritative current repository_key. Repository deletion safety derives assigned jobs from job metadata. The additional repository fields used_by and source_job_keys are redundant reverse links that can drift out of sync.
Recommended target:
- Keep one current
repository_keyin each job. - Do not add repository history.
- Remove
used_byandsource_job_keysinstead of migrating them tojob_idsandsource_job_ids. - Continue deriving repository usage and deletion protection from the job inventory.
This preserves the existing rule that a repository cannot be deleted while a job is assigned, while reducing the migration surface and eliminating duplicate ownership state.
Repository reassignment remains separate from identity: the same job_id survives the change, future backups use the new repository, archives are not moved, and Browse & Restore only uses the current repository. The warning and explicit confirmation remain tracked in #452.
Two additional implementation details are required:
- Repository-related caches must be namespaced by both
job_idand repository key/hash so stale data is not reused after reassignment. - Restore execution must snapshot the resolved repository and storage context before starting the asynchronous worker. Resolving it again later creates a race if the job is edited while a restore is running.
E. Type ID contains implicit behavior
Removing Type ID is not only a rename or identity migration. Current code also derives behavior from special values such as appdata and vms, including Docker/VM handling. Type-related values are also used for icons, sorting, cache behavior, repository-check flags, legacy locks, and environment fallbacks.
Before backup_type is removed from the canonical model, every remaining behavior must be represented by explicit settings or another existing non-identity property. Migration must materialize those settings for existing jobs. Otherwise, a migrated job could keep its data but silently change operational behavior.
F. Persistent stores missing from the current issue inventory
The migration inventory must also include:
notification-queue.jsonnotification-deliveries.jsonnotification-state.json- runtime recovery state
- active restore runs
- restore history index and details
- restore-test results and policies
- weekly repository snapshots
- generated scheduler/cron state
The queue and delivery stores contain job_key references and are particularly important. Omitting them can break delivery correlation or produce duplicate notifications after migration.
The restore_test schedule key is not a normal job. It represents a singleton/system operation and must not receive a generated job UUID. A clearer target schedule structure is:
{
"jobs": {
"<job-id>": {}
},
"restore_test": {}
}
G. Scope items not backed by the current production path
The following items should not remain mandatory scope unless they are defined as separate features:
- A production-wired status archive. A helper exists, but no complete production flow was found.
- Source manifests. No active source-manifest feature was found.
- A full configuration backup/restore workflow. The current settings restore endpoint restores
backup.conf, while the current job bundle is a partial import/export mechanism rather than a complete installation restore.
Adding migration requirements for nonexistent or incomplete features makes the cutover larger without preserving current user data. These items can be designed separately when their owning features exist.
H. Status and log filenames
Readable filenames are useful but must not be unique only by second-resolution timestamp plus a short job UUID. Two executions of the same job can start within the same second.
Recommended rule:
- Persist the full
job_idandrun_idin the payload. - Include
run_id, or at least microseconds plus an independent collision-safe value, in new status/log filenames. - Treat every readable filename component as diagnostic only.
- Resolve live and historical records by payload identity, never by parsing the filename.
I. Import, export, and duplication
The current bbui-job-bundle-v2 format handles collisions through job_key, and applying a bundle is not a fully transactional full-configuration restore.
Recommended rules for the existing partial job-bundle feature:
- Import as new: always generate a new UUID.
- Duplicate job: always generate a new UUID.
- Update an explicitly selected existing job: preserve the selected target job UUID.
- Treat the UUID contained in an imported bundle as provenance, not as local identity.
- Build one internal source-ID-to-target-ID remap and apply it consistently to bundled schedules and other included dependents.
- Do not silently merge by name, prefix, repository, or legacy key.
Preserving IDs across hosts should only be specified for a real full-configuration restore feature with a transactional referential-integrity contract. That feature does not currently exist.
J. API transition and legacy aliases
All job-addressing APIs must migrate, including:
- run, cancel, enable/disable, edit, and delete
- wizard load/save
- SSE and live-log lookup
- schedules and cron calls
- restore precheck, start, status, history, and tests
- reports and history filters
- repository prune/maintenance actions
- import/export operations
Recommended compatibility boundary:
- Prefer and emit
job_idimmediately after cutover. - Accept legacy
job_keyonly for a bounded transition period. - Resolve legacy keys through one central alias store, for example
config/job-id-aliases.json. - Reject ambiguous aliases and requests where supplied
job_idandjob_keydisagree. - Log deprecated use without logging secrets.
- Write only UUID-based active data after migration.
- Record the version in which legacy request support will be removed.
A central alias map is preferable to permanently storing legacy_job_keys in every active job file because it gives the compatibility layer an explicit lifecycle and keeps the new canonical job model clean.
K. Migration safety and atomicity
Affected data can live on different filesystems, such as /boot and /mnt/user. A literal atomic rename across the whole migration is impossible. The required property should therefore be defined as crash-consistent, resumable cutover, not as one cross-filesystem atomic transaction.
Before applying changes, migration must block while any relevant process is alive. Stopping only the UI PID is insufficient because backup runners and detached notification workers may survive independently.
The migration should use these phases:
-
Quiesce and detect
- Block scheduler, writable APIs, backup/restore starts, repository maintenance, notification writers, and widget refresh.
- Detect live backup runners, restore workers, repository operations, runtime/control state, and detached notification workers.
- Refuse migration until all writers are stopped or safely completed.
-
Plan
- Inventory all active and historical stores.
- Persist the complete legacy-key-to-UUID map before the first data rewrite.
- Classify records as exact active match, unique prefix match, already ID-based, unassigned, ambiguous, or invalid.
- Block on ambiguous active configuration. Preserve ambiguous historical records as unassigned.
-
Snapshot
- Record original paths, sizes, checksums, planned target paths, and planned actions.
- Verify enough free space on every affected filesystem.
- Do not expose secrets in the audit log.
-
Stage
- Write each replacement next to its target on the same filesystem.
- Flush and
fsyncfile and directory metadata where applicable. - Re-read and validate staged JSON before commit.
-
Commit
- Add identity to historical records first where this is non-destructive.
- Write new UUID-named job metadata.
- Rewrite schedules, reminder/delivery state, restore stores, and runtime recovery.
- Remove redundant repository reverse links if that recommendation is accepted.
- Remove legacy active metadata only after all new references verify.
- Regenerate cron last.
- Rebuild derived caches rather than treating them as authoritative migrated data.
-
Verify
- Check unique valid UUIDv4 values and referential integrity across every active store.
- Verify archive prefix order and explicit behavior settings.
- Verify dashboard, schedule, restore, notification, and repository joins.
- Mark the migration applied only after the final integrity check succeeds.
-
Resume/recover
- Reuse the persisted UUID map and migration plan after interruption.
- Compare source fingerprints before continuing so external edits cannot be overwritten silently.
- Keep normal writes blocked after failure until a clean restart completes recovery.
Weekly snapshot collisions require special handling. Identical same-job/same-week values may be merged. Conflicting values must both be preserved in a conflict/unassigned area and reported; migration must not select max, min, or last value without evidence.
L. Downgrade and recovery boundary
The migrated data model is unsafe for an older plugin version. Old discovery expects legacy fields and filenames, and old schedule cleanup can treat UUID-keyed schedules as unknown and remove them.
Therefore:
- Do not promise in-place downgrade compatibility after migration.
- Recovery uses the installed or a fixed newer plugin plus the migration snapshot.
- Document manual snapshot restoration for exceptional recovery.
- If downgrade protection is considered necessary, ship a guard release before the cutover rather than maintaining permanent dual identity.
This matches the repository migration policy: snapshots protect user data, but they are not automatic plugin-package rollback.
M. UUID choice, performance, and indexes
UUIDv4 is sufficient and recommended:
- available in the Python 3.10 standard library,
- no database locality or chronological sorting requirement,
- avoids encoding creation time,
- simple canonical validation with
uuid.UUIDplus version and string checks.
The UUID is an identifier, not a secret or authorization token.
A database is not needed for this issue and would violate the intended architecture boundary. Recommended performance model:
- direct job metadata lookup by
<job_id>.json, - an in-memory job catalog keyed by UUID,
- directory signatures or mtimes for cache invalidation,
- a similar bounded status catalog for dashboard/report reads,
- no persisted status index until measured production volume demonstrates a need.
Repository check caches should be repository-scoped and job-facing caches should include both job ID and repository identity.
N. Recommended delivery sequence
Keep the migration dormant until every consumer can read the new model. A safe review sequence is:
- Identity validation and catalog primitives.
- Explicit archive-prefix model and migration of implicit Type ID behavior into explicit settings.
- Runtime, status, history, reports, logs, dashboard, and widgets.
- Restore, restore tests, schedules, repositories, notifications, and import/export.
- Dormant migration implementation, audit UI, production fixtures, and interruption tests.
- Final UI/API cutover and migration registration as one publishable boundary.
- Later removal of the bounded legacy API alias layer.
No test-channel or stable package should execute the identity migration while any required reader or writer still depends on the legacy model.
O. Required production evidence before implementation/test deployment
The provided appdata_local.json confirms one schema-v3 job with job_key, backup_type, location, and repository assignment, but no archive_prefixes. It is useful evidence, not a complete production migration fixture.
A sanitized inventory is still required for all jobs and dependent stores:
- canonical and legacy job metadata
- repositories, storages, and schedules
- status and restore-test filenames plus selected identity fields
- weekly snapshot keys, weeks, and values or consistent hashes
- restore active runs and restore history
- notification state, queue, and delivery identity fields
- open runtime recovery fields
- the managed BBUI crontab block
- log filenames only
- filesystem/mount layout and free-space information
- current migration state/audit files
Do not collect repository passphrases, private keys, tokens, credentials, hostnames, usernames, or other secrets. The current support bundle is insufficient by itself because it caps status samples and omits several dependent stores.
P. Required test additions
In addition to the issue's current tests, cover:
- migration interruption at every phase and idempotent resume
- blocking while any backup, restore, repository, or notification writer is active
- multi-filesystem staging and insufficient-space failure
- explicit current-prefix derivation from legacy runner behavior
- restore across all prefixes while prune uses only the current prefix
- ambiguous and unassigned historical records
- weekly snapshot conflicts without data loss
- same-second reruns without filename collision
- Type IDs containing underscores in legacy history and restore-test data
- materialization of appdata/VM and other implicit Type ID behavior
- repository reassignment cache isolation
- restore worker repository snapshot race
- import/duplicate UUID remapping and transactional failure behavior
restore_testsingleton schedule separation- cron regeneration failure and recovery
- notification queue/delivery correlation without duplicate sends
- path traversal, symlink, UUID validation, and malformed JSON rejection
- dashboard and widget cardinality after migration
Open maintainer decisions
The following are recommendations, not yet final architecture decisions. They should be resolved by maintainer comments and then reflected in the canonical issue body:
- Remove repository reverse links, or migrate them to UUID reverse links.
- Apply retention only to the current prefix, or also to historical prefixes.
- Use one central, time-bounded legacy alias map, or retain aliases inside each job file.
- Confirm UUIDv4 rather than UUIDv7.
- Confirm that downgrade is unsupported after migration and recovery is snapshot-based.
- Confirm partial bundle imports always receive local target UUIDs.
- Confirm collision-safe filenames include
run_id. - Remove nonexistent status-archive/source-manifest/full-restore scope, or define those features separately.
Once these decisions are recorded, the issue body should be consolidated so it contains one unambiguous implementation contract rather than both the original assumptions and this review.
Mandatory pre-migration backup and administrator confirmation
Issue #447 affects installations that are already in active use and whose persistent data may differ significantly. A warning alone is not sufficient. Creating and verifying a migration snapshot must be a technical precondition for changing any user data.
Release strategy
A preparatory release should be published before the migration release where practical. It should:
- announce the upcoming mandatory migration persistently,
- provide a migration-readiness check,
- inventory the current installation without modifying it,
- report unknown, ambiguous, or inconsistent data,
- allow the administrator to create and download a complete migration snapshot.
The migration release must nevertheless support a direct upgrade from every supported legacy state. Users can skip releases, so installing the preparatory release must not be a prerequisite for safe migration.
First start of the migration release
The new package may be installed before migration, but the first start must enter a restricted migration/maintenance mode:
start new version
-> detect only; do not modify persistent user data
-> block scheduler and all background or API writers
-> create and verify a complete migration snapshot
-> offer the snapshot for download
-> require explicit administrator confirmation
-> execute and verify the migration
-> enable normal operation only after success
While migration is pending, the plugin must not start backups, restores, repository maintenance, scheduled jobs, notification writers, or other operations that can modify affected state. Read-only migration diagnostics, snapshot download, and recovery controls remain available.
This design ensures that installing the new plugin version does not itself mutate the legacy data model. The migration begins only after the safety conditions are met.
Required snapshot contents
The automatically created snapshot must cover every persistent object affected by this issue, including at least:
- job metadata,
- repository and storage configuration required for referential integrity,
- schedules and managed cron state,
- active and historical status data,
- weekly repository snapshots,
- restore-test policy and results,
- active restore runs and restore history,
- notification state, queues, deliveries, and reminder deduplication state,
- runtime recovery state,
- current migration state and audit records.
The snapshot must contain a manifest with:
- migration ID,
- source plugin/schema version,
- creation timestamp,
- original paths,
- file sizes,
- SHA-256 checksums,
- source fingerprints,
- planned target paths/actions where applicable.
The migration must not start if snapshot creation, read-back, checksum verification, JSON validation, or free-space validation fails. Audit output must never contain secrets.
If source data changes after the snapshot was created, the snapshot is no longer valid for the pending plan. The plugin must create and verify a new snapshot before enabling migration.
External copy and explicit confirmation
The migration UI must offer the verified snapshot as a downloadable archive. A snapshot stored only on the same Unraid boot device or array is not an independent backup, so the administrator must be strongly instructed to retain an external copy.
The UI cannot prove that a browser download was stored safely. It can, however, prove that the server-side snapshot was successfully created and verified, and then require a deliberate acknowledgement before enabling the migration action.
Suggested UI copy:
Mandatory job data migration
This plugin version introduces a new internal identity model for backup jobs. Existing jobs, schedules, history, restore information, and related configuration must be migrated.
Backup jobs, restores, schedules, and other write operations will remain paused until the migration is completed.
A verified migration snapshot has been created. We strongly recommend downloading and storing an additional copy outside this Unraid server before continuing.
Required controls:
Download migration snapshot- A mandatory acknowledgement such as:
I have stored a separate copy of the migration snapshot and understand that Unraid does not provide an automatic plugin downgrade. Start migration, disabled until the server-side snapshot is valid and the acknowledgement is checked.
User notification surfaces
The mandatory action should be announced through all available relevant surfaces:
- release notes and plugin manifest changelog,
- a persistent banner in the preparatory version,
- the first-start migration screen in the migration version,
Settings > System Health & Migration,- an Unraid system notification.
Suggested pre-update release-note text:
Required action before upgrading
The next release introduces a mandatory migration of job metadata and dependent history. Before installing it, create and download a current plugin migration backup. After the update, backup jobs and schedules will remain paused until a verified snapshot has been created and the migration has been explicitly confirmed.
Failure and recovery behavior
On any migration failure:
- stop at the first failed migration,
- mark later migrations as blocked,
- keep all normal writers and scheduled operations disabled,
- do not delete or replace unverifiably migrated source files,
- retain the snapshot and migration journal,
- show the failed phase, affected objects, and sanitized cause,
- allow snapshot download and support-bundle creation,
- resume idempotently with the persisted plan and UUID mapping after correction.
The migration snapshot protects persistent data but is not an automatic plugin-package downgrade. Recovery must use the installed or a corrected newer plugin version, with documented manual snapshot restoration for exceptional cases.
Additional acceptance criteria
- No affected persistent user data is changed before a complete snapshot has been created, read back, and checksum-verified.
- Migration cannot be started without an explicit administrator acknowledgement.
- Installing the new package alone does not trigger data conversion.
- Direct upgrades remain safe even when the preparatory release was skipped.
- Pending, failed, or blocked migration keeps every affected writer and scheduler disabled.
- A changed source state invalidates the previous snapshot and plan.
- The verified snapshot remains available after successful migration until the administrator explicitly removes it.
- Migration and snapshot status are visible in the UI without exposing secrets.
Production data analysis and migration clarifications
A read-only analysis was performed against a complete production data copy from plugin version 2026.08.31.0907, built from source commit c95897add7dd7ea13bcb05a462859965f6ac0719. That commit is an ancestor of the current main baseline used for the earlier code analysis.
No secret contents or log contents were read, no Borg repository was contacted, and no production data is attached to this issue.
This comment records the important observed cases and clarifies several earlier recommendations. Where it conflicts with the earlier analysis comments, this production-backed clarification takes precedence.
Production inventory
The inspected installation contains:
- 14 active schema-v3 jobs,
- 13 repositories,
- 3 storage targets,
- 11 schedules, 10 of them enabled,
- 539 active status files,
- 6 active restore-test result files,
- 200 notification-delivery records,
- an empty notification queue,
- no currently persisted restore runs,
- no currently persisted runtime-recovery entries.
All active job metadata files are valid JSON. Their filenames match job_key, and every job_key matches the current <backup_type>_<location> formula. All active job-to-repository references resolve.
This installation is a valuable real migration fixture, but it is not expected to represent every installed state. Safe migration does not require access to every user installation; it requires strict local detection, classification, and fail-closed behavior before the first write.
1. Local detection of unknown installations
The migration must operate against an explicit ownership and format allowlist.
For each application-owned canonical object, preflight classifies the local state as one of:
supported legacy
already migrated
not applicable
historical/unassigned
ambiguous
invalid
unsupported schema
Rules:
- A supported and internally consistent legacy state may be planned for migration.
- An unknown schema, malformed canonical file, duplicate active identity, unresolved active repository reference, or conflicting active relationship blocks migration before any data rewrite.
- Historical records with no active owner are preserved as unassigned legacy history when they do not affect active configuration.
- Unrelated files outside application ownership are ignored.
- Explicitly excluded areas such as
.Recycle.Bin, logs, and Borg caches are left unchanged. - Snapshot creation occurs before any persistent source object is modified.
- The UI must show exact sanitized reason codes and affected paths and offer a diagnostic bundle if preflight blocks.
This allows each installation to validate itself. A user only needs to provide a sanitized diagnostic bundle when that local preflight encounters a state not yet supported.
Known source formats come from released source history, existing startup migrations, repository fixtures, this production fixture, and deliberately constructed malformed/interrupted test cases.
2. Existing repository relationship is not strictly one-to-one
The production installation contains two active jobs assigned to the same repository. The repository contains both jobs in used_by and source_job_keys, and both reverse lists currently agree with the authoritative job metadata.
Therefore, current production behavior permits:
multiple jobs -> one repository
Repository deletion protection does not imply a one-to-one relationship; deletion remains blocked while one or more jobs reference the repository.
Issue #447 must preserve an existing valid shared-repository assignment. It must not silently split, clone, or reinitialize a Borg repository. Enforcing one job per repository would require a separate product decision and an explicit resolution workflow because it cannot be derived safely during this identity migration.
3. Archive-prefix migration is deterministic
Thirteen of the fourteen active jobs have no archive_prefixes field. One edited job contains two values: the current prefix followed by a previous prefix. This confirms that archive_prefixes is currently added when a job is actively edited by a recent version; untouched jobs normally do not have the field.
The current runner still creates archives with:
current_prefix = backup_type + "-backup"
Migration must therefore use this deterministic rule:
current = backup_type + "-backup"
target archive_prefixes = [current] + existing valid prefixes not already present
- Missing or empty
archive_prefixesbecomes[current]. - If the existing list already starts with
current, its order is retained after de-duplication. - Previous prefixes remain behind the current prefix.
- The existing status archive names are a consistency check, not the primary source of the current value.
- An invalid or contradictory prefix list blocks the affected active migration instead of being guessed.
4. Active status files require payload enrichment
All 539 active status files map unambiguously to the 14 active jobs, and every active status-to-log reference resolves.
However, the status payloads contain none of the following:
job_id,- explicit
job_key, run_id,schema_version.
Their legacy identity is derived from backup_type, location, and the filename. The migration plan must map each supported active status to exactly one planned job_id, then add the immutable ID and schema marker while preserving all historical descriptor values and the original filename.
Existing status and log filenames must not be renamed merely to adopt UUIDs. Their current linkage is valid, and canonical identity after migration comes from the status payload.
Legacy status records cannot be assigned a fabricated run_id. run_id is required only for new executions after cutover unless a real existing run identifier is available.
5. Restore-test filename decision
All six active restore-test files map unambiguously to active jobs, but their payloads contain neither job_key nor job_id. Current identity comes from the filename plus type and location.
The canonical active result file should be:
<job_id>.test
This intentionally replaces the earlier suggestion to include the mutable archive prefix in the canonical filename.
A readable prefix in the filename creates unsafe lifecycle behavior. When a prefix changes, renaming the existing result would falsely imply that the old test covered the new prefix. Writing a second readable filename would create two active files for the same job and introduces crash/cleanup ambiguity.
Readability must instead come from the payload and UI. A migrated/new result includes at least:
{
"schema_version": 2,
"job_id": "6cd32490-99e2-45df-bafb-81b942decd82",
"job_name": "Paperless Backup",
"archive_prefix": "paperless-backup",
"tested_archive": "paperless-backup-2026-08-30_03-00-00",
"repository_key": "repo_paperless",
"location": "storagebox"
}
System Health and the restore-test UI should show the mapping from <job_id>.test to current job name and tested prefix.
Restore-proof semantics:
- Changing only the display name does not affect proof validity.
- Changing the archive prefix does not delete or detach the last result; it remains the last test for the same
job_idand retains the prefix/archive actually tested. - If a backup exists under the new current prefix but no archive under that prefix has been restore-tested, the UI should state this explicitly rather than implying that the new archive series was tested.
- A successful test of a new-prefix archive atomically replaces the one canonical
<job_id>.testresult.
6. Notification history contains active and orphaned identities
The 200 delivery records contain 16 distinct legacy job keys:
- 196 records map to the 14 active jobs,
- 4 records belong to two jobs that no longer exist.
The migration must add job_id to the unambiguously active records while preserving the four orphaned records as unassigned legacy notification history. It must not match them to similarly named active jobs.
The notification reminder state contains active legacy keys and must be converted without triggering duplicate reminders.
The production queue is empty, so populated, partially delivered, retrying, and malformed queue states still require synthetic fixtures.
7. Weekly history must merge two live locations
Production contains both:
- a legacy status-directory snapshot file with 107 entries covering earlier weeks,
- the canonical parent-directory snapshot file with 15 entries covering the current observed week.
Across both live files:
- 113 entries belong to active jobs,
- 9 entries belong to historical or unknown job keys,
- no same-job/same-week value conflict exists in this sample.
The UUID migration must read both supported live locations, map and merge active history by job_id and week, retain chronological order, and preserve orphaned entries in an explicit unassigned legacy section. It must not discard the older file merely because the newer canonical file already exists.
Conflict behavior still requires synthetic coverage: identical duplicate values may be de-duplicated; contradictory values must be preserved and reported rather than resolved by max/min/last-value guessing.
8. .Recycle.Bin is not an application status archive
The copied status tree contains additional status files, restore-test files, and a weekly snapshot under .Recycle.Bin. Current application readers use non-recursive *.status and *.test discovery and do not treat this directory as an archive.
Migration must mirror that ownership boundary:
- do not discover
.Recycle.Binas active or archived application state, - do not rewrite, move, delete, or assign UUIDs to its contents,
- do not let its historical/case-variant identities block migration.
If an application-managed status archive is introduced later, it requires its own explicit path and contract. .Recycle.Bin must never be inferred as that archive.
9. Existing logs remain immutable historical artifacts
Every active status record references an existing log file. Additional unreferenced logs contain historical job-key naming variants.
Issue #447 must:
- preserve existing log filenames and contents,
- retain existing status-to-log references,
- avoid assigning orphan logs to active jobs by name similarity,
- use
job_idand collision-saferun_idmetadata for newly created logs after cutover.
The migration snapshot only needs logs if the migration modifies them. With the required no-rewrite behavior, logs are outside the changed-object snapshot and can remain available as historical artifacts.
10. Borg cache is derived repository data and is excluded
The observed size classes are approximately:
- complete persistent
/bootapplication data: 1.6 MB, - active status files: 391 KB,
- active restore-test files: 197 KB,
- logs: 7.3 MB,
- Borg cache: 2.04 GB.
The Borg cache must not be copied into the mandatory migration snapshot and must not be rewritten as job-owned persistent identity data.
Current cache paths include mutable location/Type ID components even though Borg cache content belongs to a repository. The earlier suggestion to key Borg caches by both job ID and repository identity is superseded. If cache paths are changed as part of removing Type ID, the target namespace should be repository-owned, for example by stable repository_key, with Borg's own repository-ID separation retained.
Existing cache directories must not be silently deleted. Reuse, safe retirement, or explicit cleanup after successful repository access requires a separate cache transition policy. Cache state must never block preservation of canonical job data.
11. Repository secrets are not job identity
All 13 repository passphrase references resolve to existing secret files in the production copy. Secret contents were not inspected.
Issue #447 must not rename secret files merely because their existing filenames contain a legacy job-like value. The authoritative reference is the repository's passphrase_ref; secrets belong to repository access, not to the new job identity.
The migration snapshot must include every file it will modify and must verify that referenced secrets exist. Secret contents should not be added to a downloadable migration archive unless an explicitly secured/encrypted export design requires them. No secret value may appear in manifests, logs, diagnostics, or GitHub artifacts.
12. Snapshot boundary for this migration
For the observed installation, the data actually requiring conversion is small. The mandatory snapshot should cover exact source files selected by the persisted migration plan, including jobs, repository metadata if changed, schedules, active statuses, active restore tests, weekly history, notification state/deliveries/queue, restore state, runtime recovery, migration state, and managed cron input/state.
It must explicitly exclude:
- Borg caches,
- installed plugin runtime/vendor files,
- package artifacts,
.Recycle.Bin,- unchanged logs,
- unrelated files outside the application-owned allowlist.
This exact-file snapshot is safer and far smaller than recursively archiving all three production trees.
13. Evidence still required through synthetic tests or local preflight
This production sample does not exercise:
- a populated notification queue,
- a running or interrupted restore,
- populated runtime-recovery state,
- concurrent backup/restore/repository/notification writers,
- malformed or partially written JSON,
- duplicate active keys or IDs,
- conflicting same-week snapshot values,
- insufficient free space,
- cross-filesystem interruption between
/bootand/mnt/user, - actual managed crontab contents,
- mount/filesystem metadata,
- older installations that did not complete one or more previous migrations.
These cases must be covered by repository fixtures and fault-injection tests. Runtime preflight must handle any unsupported real state by blocking safely before writes and producing a sanitized diagnostic report.
Result for the inspected installation
Given the rules above, the active portion of this production installation is unambiguous and should be migratable:
- 14 jobs can receive 14 stable UUIDs,
- all active repository references resolve,
- all 11 schedules can be mapped,
- all 539 active statuses can be mapped,
- all 6 active restore tests can be mapped,
- 196 notification deliveries can be mapped,
- 113 live weekly entries can be mapped,
- remaining historical identities can be preserved as unassigned legacy data.
The existing shared-repository relationship must remain intact, and no cache, log, .Recycle.Bin, or secret content needs to be rewritten for that result.
Follow-up: repository prune and historical archive prefixes
A review of the current repository-maintenance and backup-runner paths found an important retention gap that must be covered by this migration.
Current behavior
Manual prune from the Repositories page is not repository-wide. It resolves one linked job, loads that job's retention values, derives one current archive prefix from the mutable job_key, and runs Borg with a single filter such as:
--glob-archives appdata-backup-*
Automatic prune after a successful backup has the same effective scope: it receives only the current archive prefix used by that run.
Browse & Restore behaves differently. It already combines the current prefix with the stored archive_prefixes list so that archives created under previous Type IDs remain discoverable.
Consequence after a Type ID or prefix change
Given:
"archive_prefixes": [
"paperless-v310-backup",
"paperless-backup"
]
new archives matching paperless-v310-backup-* are covered by retention, while existing archives matching paperless-backup-* remain visible in Browse & Restore but are not selected by automatic or manual prune.
This is currently fail-safe with respect to deletion: old-prefix archives are left untouched. However, they can remain indefinitely and consume storage because the job's retention policy is no longer applied to them.
The Repositories action labelled Prune can therefore be misunderstood as applying to every archive in the repository even though it is scoped to one selected job and only its current derived prefix.
Required behavior for #447
- Resolve repository maintenance by immutable
job_id. - Use the job's one current repository and its complete ordered
archive_prefixeslist. - Treat current and historical prefixes as the archive set of one logical job when applying its retention policy.
- Never include archive prefixes belonging to another job merely because both jobs share a repository.
- Show every effective archive filter and the selected job retention policy in the manual prune confirmation.
- Preserve a clear error when no job or no valid retention policy can be resolved.
- Add tests for a renamed prefix, multiple historical prefixes, a shared repository, and isolation from unrelated archives.
- Define the behavior for malformed, duplicated, or conflicting prefix ownership as fail-closed instead of guessing.
The all-zero safety rule is separate and is implemented by #458: both automatic prune and manual repository prune must stop before Borg is started when every retention value is 0. An explicit future keep-all mode must skip prune rather than encode keep-all as four zero values.
Phase 1 contract consolidated (#471 / draft PR #480)
The first phase is implemented on the shared integration branch, commit 9ac8715. The consolidated contract records the baseline, ownership checklist and resolutions below. Please use it when reviewing and implementing later phases; some earlier examples in this issue are superseded by the later safety/production findings.
- The current legacy prefix comes from what the runner actually creates
(
<backup_type>-backup), then valid stored prefix history is retained in order. The existing first list entry is not necessarily the current one. - Retention applies once to the combined prefix set in the current repository. Separate per-prefix prune runs would change keep-N semantics. Ambiguous archive ownership between jobs must block destructive actions.
- Installation/startup is not consent to convert data. Require a verified exact-file snapshot and explicit administrator acknowledgement. The current runner's pending-state/writer gate needs extension in #472/#479; do not register automatic apply before this is complete.
- Quiesce detached backup/notification workers too. Use a durable ID map and resumable per-file replacements across filesystems; preserve protected snapshots and do not promise an automatic plugin downgrade.
- Do not infer the stale
config_localschedule's owner frompfsense_localprefix history. Active ambiguity blocks; orphan historical data is retained unassigned and cannot create configured dashboard jobs. - Existing log paths/bytes, Borg cache contents, secrets' existing references, recycle-bin data and unowned nested archives remain untouched. Read both live weekly snapshot locations and retain conflicting observations.
- Keep restore-test evidence and its original scope; old evidence cannot certify archives in a different current repository. Use independent full job/run identity for new records, not short UUID filename suffixes.
- Preserve the approved per-job aliases and UUID reverse references. The earlier suggestions to remove those stores were not approved. Full installation restore and hypothetical source manifests remain outside this implementation; existing partial transfer gets explicit ID rules.
There are 35 entirely synthetic cases and 146 passing focused tests. This validates the phase-1 contract/oracle, not a working migration. #472 owns the real inactive planner/snapshot/journal implementation; #479 owns guarded activation and the first complete installable test candidate.
No runtime code, production files or release artifacts were modified in phase 1. PR #480 stays draft; final preflight/build remain deferred to #479 under the approved single-branch/single-PR delivery plan.