mirror of https://github.com/restic/restic.git
Compare commits
10 Commits
4503aea0df
...
8479390d7c
Author | SHA1 | Date |
---|---|---|
rawtaz | 8479390d7c | |
Fabien-Jrt | 756f43d5f9 | |
Michael Eischer | 1dd873b706 | |
Michael Eischer | 7a60d9e54f | |
Michael Eischer | 3001dd8c2b | |
Michael Eischer | ba16904eed | |
Michael Eischer | 2841a87cc6 | |
Michael Eischer | fab4a8a4d2 | |
Michael Eischer | e604939e72 | |
Michael Eischer | 37aca6bec0 |
|
@ -78,5 +78,6 @@ func CleanupHandler(c <-chan os.Signal) {
|
|||
// given exit code.
|
||||
func Exit(code int) {
|
||||
code = RunCleanupHandlers(code)
|
||||
debug.Log("exiting with status code %d", code)
|
||||
os.Exit(code)
|
||||
}
|
||||
|
|
|
@ -282,6 +282,7 @@ func Warnf(format string, args ...interface{}) {
|
|||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unable to write to stderr: %v\n", err)
|
||||
}
|
||||
debug.Log(format, args...)
|
||||
}
|
||||
|
||||
// resolvePassword determines the password to be used for opening the repository.
|
||||
|
|
|
@ -71,6 +71,7 @@ func testRunBackupAssumeFailure(t testing.TB, dir string, target []string, opts
|
|||
defer cleanup()
|
||||
}
|
||||
|
||||
opts.GroupBy = restic.SnapshotGroupByOptions{Host: true, Path: true}
|
||||
backupErr := runBackup(ctx, opts, gopts, term, target)
|
||||
|
||||
cancel()
|
||||
|
@ -362,6 +363,55 @@ func testBackup(t *testing.T, useFsSnapshot bool) {
|
|||
testRunCheck(t, env.gopts)
|
||||
}
|
||||
|
||||
func TestBackupWithRelativePath(t *testing.T) {
|
||||
env, cleanup := withTestEnvironment(t)
|
||||
defer cleanup()
|
||||
|
||||
testSetupBackupData(t, env)
|
||||
opts := BackupOptions{}
|
||||
|
||||
// first backup
|
||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
||||
snapshotIDs := testRunList(t, "snapshots", env.gopts)
|
||||
rtest.Assert(t, len(snapshotIDs) == 1, "expected one snapshot, got %v", snapshotIDs)
|
||||
firstSnapshotID := snapshotIDs[0]
|
||||
|
||||
// second backup, implicit incremental
|
||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
||||
|
||||
// that the correct parent snapshot was used
|
||||
latestSn, _ := testRunSnapshots(t, env.gopts)
|
||||
rtest.Assert(t, latestSn != nil, "missing latest snapshot")
|
||||
rtest.Assert(t, latestSn.Parent != nil && latestSn.Parent.Equal(firstSnapshotID), "second snapshot selected unexpected parent %v instead of %v", latestSn.Parent, firstSnapshotID)
|
||||
}
|
||||
|
||||
func TestBackupParentSelection(t *testing.T) {
|
||||
env, cleanup := withTestEnvironment(t)
|
||||
defer cleanup()
|
||||
|
||||
testSetupBackupData(t, env)
|
||||
opts := BackupOptions{}
|
||||
|
||||
// first backup
|
||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata/0/0"}, opts, env.gopts)
|
||||
snapshotIDs := testRunList(t, "snapshots", env.gopts)
|
||||
rtest.Assert(t, len(snapshotIDs) == 1, "expected one snapshot, got %v", snapshotIDs)
|
||||
firstSnapshotID := snapshotIDs[0]
|
||||
|
||||
// second backup, sibling path
|
||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata/0/tests"}, opts, env.gopts)
|
||||
snapshotIDs = testRunList(t, "snapshots", env.gopts)
|
||||
rtest.Assert(t, len(snapshotIDs) == 2, "expected two snapshots, got %v", snapshotIDs)
|
||||
|
||||
// third backup, incremental for the first backup
|
||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata/0/0"}, opts, env.gopts)
|
||||
|
||||
// test that the correct parent snapshot was used
|
||||
latestSn, _ := testRunSnapshots(t, env.gopts)
|
||||
rtest.Assert(t, latestSn != nil, "missing latest snapshot")
|
||||
rtest.Assert(t, latestSn.Parent != nil && latestSn.Parent.Equal(firstSnapshotID), "third snapshot selected unexpected parent %v instead of %v", latestSn.Parent, firstSnapshotID)
|
||||
}
|
||||
|
||||
func TestDryRunBackup(t *testing.T) {
|
||||
env, cleanup := withTestEnvironment(t)
|
||||
defer cleanup()
|
||||
|
|
|
@ -533,8 +533,11 @@ Restic does not have a built-in way of scheduling backups, as it's a tool
|
|||
that runs when executed rather than a daemon. There are plenty of different
|
||||
ways to schedule backup runs on various different platforms, e.g. systemd
|
||||
and cron on Linux/BSD and Task Scheduler in Windows, depending on one's
|
||||
needs and requirements. When scheduling restic to run recurringly, please
|
||||
make sure to detect already running instances before starting the backup.
|
||||
needs and requirements. If you don't want to implement your own scheduling,
|
||||
you can use `resticprofile <https://github.com/creativeprojects/resticprofile/#resticprofile>`__.
|
||||
|
||||
When scheduling restic to run recurringly, please make sure to detect already
|
||||
running instances before starting the backup.
|
||||
|
||||
Space requirements
|
||||
******************
|
||||
|
|
|
@ -46,6 +46,7 @@ func (f *SnapshotFilter) findLatest(ctx context.Context, be Lister, loader Loade
|
|||
}
|
||||
absTargets = append(absTargets, filepath.Clean(target))
|
||||
}
|
||||
f.Paths = absTargets
|
||||
|
||||
var latest *Snapshot
|
||||
|
||||
|
|
Loading…
Reference in New Issue