Skip to content

Commit

Permalink
Merge pull request #4692 from 27149chen/dump-to-existing-file
Browse files Browse the repository at this point in the history
feat: dump flag --target should be allowed to write existing file
  • Loading branch information
MichaelEischer committed Feb 10, 2024
2 parents 6a2b10e + 15d6fa1 commit 68cc327
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/issue-4678
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Restic `dump` always printed to the standard output. It now permits to select a

https://github.com/restic/restic/issues/4678
https://github.com/restic/restic/pull/4682
https://github.com/restic/restic/pull/4692
2 changes: 1 addition & 1 deletion cmd/restic/cmd_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
canWriteArchiveFunc := checkStdoutArchive

if opts.Target != "" {
file, err := os.OpenFile(opts.Target, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o666)
file, err := os.Create(opts.Target)
if err != nil {
return fmt.Errorf("cannot dump to file: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions doc/050_restore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ To include the folder content at the root of the archive, you can use the ``<sna
$ restic -r /srv/restic-repo dump latest:/home/other/work / > restore.tar
It is also possible to ``dump`` the contents of a selected snapshot and folder
structure to a file using the ``--target`` flag. The ``dump`` command will fail
if the already file exists.
structure to a file using the ``--target`` flag.

.. code-block:: console
$ restic -r /srv/restic-repo dump latest / --target /home/linux.user/output.tar -a tar

0 comments on commit 68cc327

Please sign in to comment.