From affd04c125c69d1cd2a9702c3e024981ddcbe752 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 21 Apr 2023 22:56:31 +0200 Subject: [PATCH] doc: recommend `cat config` to check if a repository exists This will be much faster if a large number of snapshots exists. --- doc/075_scripting.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/075_scripting.rst b/doc/075_scripting.rst index 712a70244..dc7f782dc 100644 --- a/doc/075_scripting.rst +++ b/doc/075_scripting.rst @@ -22,18 +22,18 @@ Check if a repository is already initialized You may find a need to check if a repository is already initialized, perhaps to prevent your script from initializing a repository multiple -times. The command ``snapshots`` may be used for this purpose: +times. The command ``cat config`` may be used for this purpose: .. code-block:: console - $ restic -r /srv/restic-repo snapshots - Fatal: unable to open config file: Stat: stat /srv/restic-repo/config: no such file or directory + $ restic -r /srv/restic-repo cat config + Fatal: unable to open config file: stat /srv/restic-repo/config: no such file or directory Is there a repository at the following location? /srv/restic-repo If a repository does not exist, restic will return a non-zero exit code and print an error message. Note that restic will also return a non-zero exit code if a different error is encountered (e.g.: incorrect password -to ``snapshots``) and it may print a different error message. If there -are no errors, restic will return a zero exit code and print all the -snapshots. +to ``cat config``) and it may print a different error message. If there +are no errors, restic will return a zero exit code and print the repository +metadata.