Merge pull request #4692 from 27149chen/dump-to-existing-file

feat: dump flag --target should be allowed to write existing file
This commit is contained in:
Michael Eischer 2024-02-10 17:44:54 +00:00 committed by GitHub
commit 68cc327b15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View file

@ -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/issues/4678
https://github.com/restic/restic/pull/4682 https://github.com/restic/restic/pull/4682
https://github.com/restic/restic/pull/4692

View file

@ -174,7 +174,7 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
canWriteArchiveFunc := checkStdoutArchive canWriteArchiveFunc := checkStdoutArchive
if opts.Target != "" { 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 { if err != nil {
return fmt.Errorf("cannot dump to file: %w", err) return fmt.Errorf("cannot dump to file: %w", err)
} }

View file

@ -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 $ 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 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 structure to a file using the ``--target`` flag.
if the already file exists.
.. code-block:: console .. code-block:: console
$ restic -r /srv/restic-repo dump latest / --target /home/linux.user/output.tar -a tar $ restic -r /srv/restic-repo dump latest / --target /home/linux.user/output.tar -a tar