Change default storage

If I have previously init-ed a repository and then subsequently (after some time, backups and other operations have transpired with only the original/default storage) add-ed one or more additional storages, is there a way to make one of the new storages the ‘default’ and provide a name to the original default storage? Is it as simple as editing the preferences file, or is there more to this?

Yes, you can directly edit the first "name": entry in the preferences file for the name that you want.

2 Likes

Ah, I see. So, is the new ‘default’ determined position-ally (i.e. the first one) or by have an empty name “”?

From my understand, there is no “default” storage, it’s just a nomenclature. The contents of the preferences file are actually a list of configured storages. These storages may be compatible or not, depending on how they were created (chunks sizes, encrypted or not, etc.), and if the -copy option was used with the add command.

In fact, in a recent release, the -storage-name option in the init command was introduced to create the storage with a specific name instead of “default”.

Hmm, my understanding (perhaps very incorrect) has been that the default storage is used whenever the -storage value is not specified (for example on a backup command). My experience so far (albeit limited and experimental) appears to support this as I have never specified that parameter in my trials to date - and it appears to be putting the data in the one with name = “”.

Just for quick reference, here is the backup wiki page I initially got this perception from: backup

This is also true, if you don’t use the -storage option the backup will be performed to the “default” storage.

As a good practice, I always use the -storage option to have more control over the commands execution.

Ok, so the only lingering question I have, is how to make one of the new storages I ‘add’ the new ‘default’ one, please? Do I just make the name empty, or do I move it to top, or something else?

If no -storage option is given, Duplicacy will always find the storage with the name default. If no such storage exists, it will take the first one in the array regardless of its name.

So I think in your case you can change the storage name by editing .duplicacy/preferences. Remove the entire .duplicacy/cache directory after that, and you may also need to reenter passwords/credentials.

4 Likes

I cannot confirm this. I just renamed my storages so that the first storage in the preferences file was no longer called default but something else and the second one was called default. duplicacy still used the first one. Only when I switched the order of the storages in the preference file so that default was the first again did duplicacy pick it up. So, in short: it looks like duplicacy always uses the first entry as default. Is this a bug?

Looking at the code – yes, you’re right. If you don’t provide the storage name it will use the first one even if there is another one named storage.

you mean "named default" right?