From d4b28cea6c91676554242fdd94b04f9db41a891d Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 26 Jul 2024 20:09:46 +0200 Subject: [PATCH] docs: clarify how to pass arguments using backup --stdin-from-command --- doc/040_backup.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/040_backup.rst b/doc/040_backup.rst index 81d99e071..25c5a8ad1 100644 --- a/doc/040_backup.rst +++ b/doc/040_backup.rst @@ -584,11 +584,13 @@ Reading data from a command Sometimes, it can be useful to directly save the output of a program, for example, ``mysqldump`` so that the SQL can later be restored. Restic supports this mode of operation; just supply the option ``--stdin-from-command`` when using the -``backup`` action, and write the command in place of the files/directories: +``backup`` action, and write the command in place of the files/directories. To prevent +restic from interpreting the arguments for the commmand, make sure to add ``--`` before +the command starts: .. code-block:: console - $ restic -r /srv/restic-repo backup --stdin-from-command mysqldump [...] + $ restic -r /srv/restic-repo backup --stdin-from-command -- mysqldump --host example mydb [...] This command creates a new snapshot based on the standard output of ``mysqldump``. By default, the command's standard output is saved in a file named ``stdin``. @@ -596,7 +598,7 @@ A different name can be specified with ``--stdin-filename``: .. code-block:: console - $ restic -r /srv/restic-repo backup --stdin-filename production.sql --stdin-from-command mysqldump [...] + $ restic -r /srv/restic-repo backup --stdin-filename production.sql --stdin-from-command -- mysqldump --host example mydb [...] Restic uses the command exit code to determine whether the command succeeded. A non-zero exit code from the command causes restic to cancel the backup. This causes