Do not prune when a backup misses an earlier mount point (closes #395)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
snapshot create --prune purged the older snapshots holding a volume's files when the volume, mounted below a configured path, was not mounted: its empty mount point read as deleted files. The scan now records in the local index each directory at or below a configured path that holds an entry and is on a different device from its parent directory, looked up once the walk has listed it, as listing mounts an automounted volume. Under --prune, when an earlier snapshot of that name recorded such a directory and this run does not, the run skips the prune, keeps every older snapshot and exits non-zero, naming the directory. For a volume retired on purpose, snapshot purge removes the older snapshots. Model: opus-5-5
This commit is contained in:
@@ -518,8 +518,8 @@ type CleanupStats struct {
|
||||
//
|
||||
// The cleanup is performed in a specific order to maintain referential integrity:
|
||||
// 1. Delete other snapshots
|
||||
// 2. Delete orphaned snapshot associations (snapshot_files, snapshot_blobs)
|
||||
// for deleted snapshots
|
||||
// 2. Delete orphaned snapshot associations (snapshot_files, snapshot_blobs,
|
||||
// snapshot_mount_points) for deleted snapshots
|
||||
// 3. Delete orphaned files (not in the current snapshot)
|
||||
// 4. Delete orphaned chunk-to-file mappings (references to deleted files)
|
||||
// 5. Delete orphaned blobs (not in the current snapshot)
|
||||
@@ -948,8 +948,8 @@ func (sm *SnapshotManager) deleteOtherSnapshots(
|
||||
return nil
|
||||
}
|
||||
|
||||
// deleteOrphanedSnapshotAssociations deletes snapshot_files and
|
||||
// snapshot_blobs for deleted snapshots
|
||||
// deleteOrphanedSnapshotAssociations deletes snapshot_files,
|
||||
// snapshot_blobs and snapshot_mount_points for deleted snapshots
|
||||
func (sm *SnapshotManager) deleteOrphanedSnapshotAssociations(
|
||||
ctx context.Context, tx *sql.Tx, currentSnapshotID string,
|
||||
) error {
|
||||
@@ -983,6 +983,19 @@ func (sm *SnapshotManager) deleteOrphanedSnapshotAssociations(
|
||||
log.Debug("[Temp DB Cleanup] Deleted snapshot_blobs associations",
|
||||
"count", rowsAffected)
|
||||
|
||||
// Delete the mount points other snapshots recorded
|
||||
query := "DELETE FROM snapshot_mount_points WHERE snapshot_id != ?"
|
||||
database.LogSQL("Execute", query, currentSnapshotID)
|
||||
|
||||
result, err = tx.ExecContext(ctx, query, currentSnapshotID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("deleting orphaned snapshot_mount_points: %w", err)
|
||||
}
|
||||
|
||||
rowsAffected, _ = result.RowsAffected()
|
||||
log.Debug("[Temp DB Cleanup] Deleted snapshot_mount_points rows",
|
||||
"count", rowsAffected)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user