How to pass AWS key for second repo

Hello,

I’m wondering how I can copy to (or init) a second repository while both require different AWS credentials?

Regards,
Matthias

AFAIK the only way is to configure one (or both) repository in rclone and use the rclone-Backend.

Ah yes, that would be a solution. Thank you!

You can always write a wrapper script that:

  • Sets the AWS_ACCESS_KEY_ID environment variable
  • Sets the AWS_SECRET_ACCESS_KEY environment variable
  • Invokes restic
  • use different versions of the script (or a parameter to the script) to select the proper credentials

Something like this:

#!/bin/bash
# ar.sh - AWS restic wrapper
# this script forms a restic command that is pointed at a repository
# hosted on S3
export AWS_ACCESS_KEY_ID="My-Access-Key"
export AWS_SECRET_ACCESS_KEY="My-Secret"
BASE_REPO="aws-bucket-url"

#check usage
[ -z "$1" ] && {
echo no repository specified.
echo usage: $0 repository-name operation parameters
echo example: $0 my-backup snapshots
exit
}

[ -z "$2" ] && {
echo no operation specified.
echo usage: $0 repository-name operation parameters
echo example: $0 my-backup snapshots
exit
}

OPERATION=$2
shift 2

#execute the command
restic -r ${REPOSITORY} ${OPERATION} $*

@David This isn’t the problem. The problem is that some backends, e.g. the S3 one, only knows about one name for the environment variables it use for authentication. So when you use the copy command in restic and need to specify two repositories, it’s a problem when you can only provide one set of credentials. The solution to this is to use the rclone backend (specifying the two repositories in rclone instead).

Instead of $* you should use "$@" (the quotes are important).