Can you assign a name to a repository?

I am wondering if there is a way to assign a short name to your repositories? Having to type in for example, s3://example.us@s3.us-east1.cloud.container-storage.app.cloud/picturebackup to look at a repository is cumbersome and time consuming. It would be great if you had a way to assign a name like
mycloudbackup to it.

So you’d be able to run commands like this:

restic -r mycloudbackup snapshots
restic -r mycloudbackup stats

Also is there a way to show a list of all repositories you have configured on your system?

AFAIK Restic itself doesn’t include a way to do this unfortunately. I think what you’re after is essentially a config file, which has this issue open for it: Configuration File · Issue #16 · restic/restic · GitHub

If you want the ability to do this right now, I think using one of the restic configuration wrappers/profile managers written by the community is the way to go. I’ve personally used and been happy with both crestic and resticprofile, and browsing the recipes section of the forum should showcase other options.

You might like the wrapper approach. My hosts have restic-b2/restic-s3s for their B2/S3 repos.

[david@pc ~]$ sudo cat /usr/local/bin/restic-s3
#!/usr/bin/bash

export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
export RESTIC_PASSWORD='...'
export RESTIC_REPOSITORY='s3:https://s3.amazons3.com/...'

exec restic "$@"
[david@pc ~]$
1 Like

No need to complicate things - use your shell for what it’s designed to provide.

E.g. put mycloudbackup=s3://example.us@s3.us-east1.cloud.container-storage.app.cloud/picturebackup in your ~/.profile and then run restic -r $mycloudbackup snapshots (after sourcing or in a new shell of course).

That’s pretty much exactly what you asked for. You can put multiple “names” (variables) in that file and they’ll all be available for use just as easily.

1 Like

Is there anyway to add multiple repositories directly to .bashrc since you have to add the export command for the AWS keys, etc.
Your example worked great for my first repository but not sure if .bashrc will be able to distinguish between multiple export AWS lines

I’m sorry, but your question does not make sense. You don’t add repositories to .bashrc, you add whatever shell related stuff you want in there, such as for example environment variables like in our first example.

You can indeed add multiple environment variables, with different names and values, and use those just like the first one in our example. I’m not really sure what you are asking.

Sorry that I was confusing.

If I have two S3 type repositories from two different providers, they both have their own AWS keys, etc.

So for our example:
I can add this to my .bashrc file:

mycloudbackup=s3://example.us@s3.us-east1.cloud.container-storage.app.cloud/picturebackup

But to get this to run:

restic -r $mycloudbackup snapshots

I have to run the following commands from my bash shell FIRST:
export AWS_SECRET_ACCESS_KEY="
export AWS_ACCESS_KEY_ID=

Once I run these then I can run the command example you gave me:

restic -r $mycloudbackup snapshots

So let’s say I have another called $mycloudbackup2. I would have to rerun those export commands manually from my shell first BEFORE I would be able to call the repository:

restic -r $mycloudbackup2 snapshots

So I guess I would need to know if there is a way to call the AWS stuff from the .bashrc entry

Right, this is simply beyond names for a repository. For this use case you can easily make a script that lets you run restic with the proper settings.

The simplest way would be to create a restic wrapper, e.g. restic-aws:

export AWS_SECRET_ACCESS_KEY=""
export AWS_ACCESS_KEY_ID=""
export RESTIC_REPOSITORY=""
exec restic "$@"