Here are some details on working with duplicacy and the MacOS keychain that I’ve now clarified for myself. Parts of the below pieces of info are scattered across the forum, but I have not previously read an overall synopsis of how duplicacy works with keychain.
- When you
init
the repo it creates an entry in keychain, but doesn’t save the password. - When you run your first
backup
it asks for the password and then saves it in keychain. - As indicated elsewhere, if you do not give the storage a unique name, the storage will be given the name “default” in Duplicacy’s preference file.
- Duplicacy saves all items in keychain with the service name (-s flag in MacOS
security
command) of “duplicacy.” This shows up in both the Name and Where fields of they keychain access app. - If storage name = default, duplicacy will assign the account name (-a flag in
security
; Account field in keychain access) as “password”. - If a distinct storage name is given, duplicacy will assign the account name as “StorageName_password”.
-
If you
init
another storage on the same Mac without a unique storage name, duplicacy will overwrite the first one (with account name “password” and service name “duplicacy”). - If you have a unique storage name with the corresponding unique account name in keychain, “StorageName_password”, duplicacy will successfully retrieve that information for all commands except the
info
command. - It works this way: if you enter any of those commands with the debug (-d) flag, duplicacy reports that it is reading an environment variable with this distinct name. For example, if you name your storage BOB; save your password with keychain (such that duplicacy saves it with the account name of BOB_password); and then run
duplicacy -d check
, duplicacy will reportReading the environment variable DUPLICACY_BOB_PASSWORD
and it will succeed. - But if you try to run
info -e
duplicacy will look for the default password; it will reportReading the environment variable DUPLICACY_PASSWORD
and then it will fail. That is, the way theinit
command functions, it assumes a storage name of default, unless told otherwise. In contrast, other commands can get the proper storageName_password on their own. - You fix this by giving the
info
command the-storage-name
flag and the correct storage name. So with a storage named “BOB” you need this:duplicacy -d info -e -storage-name=BOB /path/to/storage
Duplicacy then looks for DUPLICACY_BOB_PASSWORD and it works fine.
#10 may not be a bug, but it is an idiosyncrasy that could be better documented. It seems to me that the CLI help on the info
command should specify that if your storage name is not default, then you must provide it in the command. Right now the flag is described this way:
-storage-name <name> the storage name to be assigned to the storage url
But that’s what the flag does in the init
command. In this listing under info
perhaps it should say something like
this flag is required for any storage with a unique name
#7 strikes me as a bug.
Only when trying to figure this out did a realize that I ran into this when I first tried out duplicacy 5 years ago and at that time @gchen helpfully explained to me the interaction between storage names and stored keychain passwords (I, of course, completely forgot this). Still, understanding that this is how it works doesn’t seem to be enough: it feels to me like overwriting a user’s encryption password simply shouldn’t be this easy to do. It wouldn’t be odd at all for a user to init a repo on their Mac (default storage) and assume their encryption password is safely saved in the Mac keychain. Then later they decide to backup some other directory, so they init
a completely different repo (again, default storage) – and suddenly their earlier encryption password is just gone (I, at least, don’t know how to recover it).