Merge pull request #4299 from MichaelEischer/update-scripting-docs

doc: recommend `cat config` to check if a repository exists
This commit is contained in:
Michael Eischer 2023-04-30 16:04:59 +02:00 committed by GitHub
commit 850cd9aace
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,18 +22,18 @@ Check if a repository is already initialized
You may find a need to 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 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 .. code-block:: console
$ restic -r /srv/restic-repo snapshots $ restic -r /srv/restic-repo cat config
Fatal: unable to open config file: Stat: stat /srv/restic-repo/config: no such file or directory Fatal: unable to open config file: stat /srv/restic-repo/config: no such file or directory
Is there a repository at the following location? Is there a repository at the following location?
/srv/restic-repo /srv/restic-repo
If a repository does not exist, restic will return a non-zero exit code 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 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 exit code if a different error is encountered (e.g.: incorrect password
to ``snapshots``) and it may print a different error message. If there 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 all the are no errors, restic will return a zero exit code and print the repository
snapshots. metadata.