mirror of
https://github.com/restic/restic.git
synced 2026-09-29 23:40:29 +00:00
backup/diff/dump/restore/stats: List snapshots before index
During a backup the index is written before the corresponding snapshots. To ensure that a concurrent/later restic run can read a snapshot's data, restic thus must first load the snapshots and only afterwards the index. Otherwise it is not possible to ensure that the loaded index is recent enough to cover all of the snapshot's data.
This commit is contained in:
@@ -144,11 +144,6 @@ func runDump(opts DumpOptions, gopts GlobalOptions, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
err = repo.LoadIndex(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var id restic.ID
|
||||
|
||||
if snapshotIDString == "latest" {
|
||||
@@ -168,6 +163,11 @@ func runDump(opts DumpOptions, gopts GlobalOptions, args []string) error {
|
||||
Exitf(2, "loading snapshot %q failed: %v", snapshotIDString, err)
|
||||
}
|
||||
|
||||
err = repo.LoadIndex(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tree, err := repo.LoadTree(ctx, *sn.Tree)
|
||||
if err != nil {
|
||||
Exitf(2, "loading tree for snapshot %q failed: %v", snapshotIDString, err)
|
||||
|
||||
Reference in New Issue
Block a user