Test for repository existence


Is there a way of verifying a repository’s existence - that can be tested for via a Bash script? So I can write something like

#<assume repo & pass defined in environment>
if [[ ! restic repo-exists ]] then;
restic init
…continue with backup process


Try something like if file config.xml & directory data, snapshots, keys, locks exist than backup


I checked my code and I detect for config.xml. Whether you should init or throw an error depends on what you’re doing.


The file is called config, not config.xml.


Good point. Autocomplete suggested it and I went with it because I’m lazy typing on my phone.


I do this for Backblaze (in a startup script):

sleep 30

if [ $( ping -c 3 backblaze.com | grep icmp* | wc -l ) -eq 0 ]
ECHO “Backblaze is unreachable. Quitting.”
exit 0

Not quite the same as testing for the exact repo’s existence, but testing for the repo’s provider serves my purposes.


You could do that using:

if [[ ! -f "/path/to/your/repo/config" ]] ; then
  restic init

So if the config file is there it will do nothing.