mirror of
https://github.com/restic/restic.git
synced 2025-08-26 09:28:01 +00:00
backup: implement --skip-if-unchanged
This commit is contained in:
@@ -767,6 +767,8 @@ type SnapshotOptions struct {
|
||||
Time time.Time
|
||||
ParentSnapshot *restic.Snapshot
|
||||
ProgramVersion string
|
||||
// SkipIfUnchanged omits the snapshot creation if it is identical to the parent snapshot.
|
||||
SkipIfUnchanged bool
|
||||
}
|
||||
|
||||
// loadParentTree loads a tree referenced by snapshot id. If id is null, nil is returned.
|
||||
@@ -880,6 +882,13 @@ func (arch *Archiver) Snapshot(ctx context.Context, targets []string, opts Snaps
|
||||
return nil, restic.ID{}, nil, err
|
||||
}
|
||||
|
||||
if opts.ParentSnapshot != nil && opts.SkipIfUnchanged {
|
||||
ps := opts.ParentSnapshot
|
||||
if ps.Tree != nil && rootTreeID.Equal(*ps.Tree) {
|
||||
return nil, restic.ID{}, arch.summary, nil
|
||||
}
|
||||
}
|
||||
|
||||
sn, err := restic.NewSnapshot(targets, opts.Tags, opts.Hostname, opts.Time)
|
||||
if err != nil {
|
||||
return nil, restic.ID{}, nil, err
|
||||
|
Reference in New Issue
Block a user