mirror of
https://github.com/restic/restic.git
synced 2025-12-04 02:41:52 +00:00
new sub-option for backup: time
New option to specify the timestamp for a backup
This commit is contained in:
@@ -29,7 +29,7 @@ type Snapshot struct {
|
||||
|
||||
// NewSnapshot returns an initialized snapshot struct for the current user and
|
||||
// time.
|
||||
func NewSnapshot(paths []string, tags []string, hostname string) (*Snapshot, error) {
|
||||
func NewSnapshot(paths []string, tags []string, hostname string, time time.Time) (*Snapshot, error) {
|
||||
for i, path := range paths {
|
||||
if p, err := filepath.Abs(path); err != nil {
|
||||
paths[i] = p
|
||||
@@ -38,7 +38,7 @@ func NewSnapshot(paths []string, tags []string, hostname string) (*Snapshot, err
|
||||
|
||||
sn := &Snapshot{
|
||||
Paths: paths,
|
||||
Time: time.Now(),
|
||||
Time: time,
|
||||
Tags: tags,
|
||||
Hostname: hostname,
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func TestCreateSnapshot(t testing.TB, repo Repository, at time.Time, depth int,
|
||||
t.Logf("create fake snapshot at %s with seed %d", at, seed)
|
||||
|
||||
fakedir := fmt.Sprintf("fakedir-at-%v", at.Format("2006-01-02 15:04:05"))
|
||||
snapshot, err := NewSnapshot([]string{fakedir}, []string{"test"}, "foo")
|
||||
snapshot, err := NewSnapshot([]string{fakedir}, []string{"test"}, "foo", time.Now())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user