2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

add program version to snapshot

This commit is contained in:
Michael Eischer 2023-06-19 19:30:41 +02:00
parent a280b7364e
commit bbac74b172
4 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,7 @@
Enhancement: Include client version in snapshot metadata
The client version number is now included in the `program_version` field of a snapshot.
It can be inspected by using either `restic cat snapshot snapshotID` or `restic snapshots --json`.
https://github.com/restic/restic/issues/4188
https://github.com/restic/restic/pull/4378

View File

@ -645,6 +645,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
Time: timeStamp, Time: timeStamp,
Hostname: opts.Host, Hostname: opts.Host,
ParentSnapshot: parentSnapshot, ParentSnapshot: parentSnapshot,
ProgramVersion: "restic " + version,
} }
if !gopts.JSON { if !gopts.JSON {

View File

@ -680,6 +680,7 @@ type SnapshotOptions struct {
Excludes []string Excludes []string
Time time.Time Time time.Time
ParentSnapshot *restic.Snapshot ParentSnapshot *restic.Snapshot
ProgramVersion string
} }
// loadParentTree loads a tree referenced by snapshot id. If id is null, nil is returned. // loadParentTree loads a tree referenced by snapshot id. If id is null, nil is returned.
@ -796,6 +797,7 @@ func (arch *Archiver) Snapshot(ctx context.Context, targets []string, opts Snaps
return nil, restic.ID{}, err return nil, restic.ID{}, err
} }
sn.ProgramVersion = opts.ProgramVersion
sn.Excludes = opts.Excludes sn.Excludes = opts.Excludes
if opts.ParentSnapshot != nil { if opts.ParentSnapshot != nil {
sn.Parent = opts.ParentSnapshot.ID() sn.Parent = opts.ParentSnapshot.ID()

View File

@ -25,6 +25,8 @@ type Snapshot struct {
Tags []string `json:"tags,omitempty"` Tags []string `json:"tags,omitempty"`
Original *ID `json:"original,omitempty"` Original *ID `json:"original,omitempty"`
ProgramVersion string `json:"program_version,omitempty"`
id *ID // plaintext ID, used during restore id *ID // plaintext ID, used during restore
} }