diff --git a/changelog/unreleased/issue-1542 b/changelog/unreleased/issue-1542 index 4db090d37..963e8ccb0 100644 --- a/changelog/unreleased/issue-1542 +++ b/changelog/unreleased/issue-1542 @@ -1,9 +1,10 @@ -Enhancement: Add --dry-run/-n option to backup command. +Enhancement: Add --dry-run/-n option to backup command -We added a new --dry-run/-n option to backup, which performs all the normal -steps of a backup without actually writing data. Passing -vv will log -information about files that would be added, allowing fast verification of -backup options without any unnecessary write activity. +We added a new --dry-run/-n option to the backup command, which performs +all the normal steps of a backup without actually writing any changes to +the repository. Passing -vv will log information about files that would +be added, allowing verification of source and exclusion backup options +without committing changes to the repository. https://github.com/restic/restic/issues/1542 https://github.com/restic/restic/pull/2308 diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index eac6c1dc0..ef229ee8a 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -133,10 +133,10 @@ func init() { f.BoolVar(&backupOptions.WithAtime, "with-atime", false, "store the atime for all files and directories") f.BoolVar(&backupOptions.IgnoreInode, "ignore-inode", false, "ignore inode number changes when checking for modified files") f.BoolVar(&backupOptions.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files") + f.BoolVarP(&backupOptions.DryRun, "dry-run", "n", false, "do not upload or write any data, just show what would be done") if runtime.GOOS == "windows" { f.BoolVar(&backupOptions.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)") } - f.BoolVarP(&backupOptions.DryRun, "dry-run", "n", false, "do not write anything, just print what would be done") } // filterExisting returns a slice of all existing items, or an error if no diff --git a/doc/040_backup.rst b/doc/040_backup.rst index 95194a742..086bb4e91 100644 --- a/doc/040_backup.rst +++ b/doc/040_backup.rst @@ -199,7 +199,7 @@ Combined with ``--verbose``, you can see a list of changes: .. code-block:: console - $ restic -r /srv/restic-repo backup ~/work --dry-run -vv | grep added + $ restic -r /srv/restic-repo backup ~/work --dry-run -vv | grep "added)$" modified /plan.txt, saved in 0.000s (9.110 KiB added) modified /archive.tar.gz, saved in 0.140s (25.542 MiB added) Would be added to the repo: 25.551 MiB