How do you specify the repository location

How do you specify the repository location? Using duplicacy cli in scripts requires changing the directory to the repository. Or perhaps you can specify a preferences file location?

In the init command you can specify the -repository option. This will give you the option to back up a directory other than the current working directory.

Thanks, what about other commands like list or check?

The path to the folder to backup you specify in the init is saved in the .duplicacy/preferences in the current folder. All other commands can fetch it from there if needed along with all other configuration data.

Which means you will still need for cd to the folder your initialized duplicacy in to run all those commands. I don’t think it supports “global” config accessible from anywhere.

But you can emulate that behavior with an alias that would cd there, run the command and cd back.

I was hoping to avoid cd as it could be come problematic. It would be great if there was a way to target a specific .duplicacy/preferences file.

Ultimately I’m looking to build out a method to audit a server, get an idea on all of the instances of duplicacy, the storage setup, how many snapshots and the amount of storage in-use.

An example would be a server with 70 duplicacy repositories with local and remote storage.

1 Like

Yeah, it appears -pref-dir is only honored in init: duplicacy/duplicacy_main.go at cdf8f5a8575fa50e22cad126a00140e38618b9fc · gilbertchen/duplicacy · GitHub.

If you are going to be running duplicacy in the shell (as opposed to directly) you can write a shell function to replace duplicacy in your .zshrc or .bashrc:

duplicacy () (
   cd "~/.config/duplicacy" && /usr/local/bin/duplicacy "$@"
)

The () will create a sub-shell so the cd won’t affect your current session.

Yea, 100% it will work, I just thought it might be better to be able to target a specific repository versus having to cd into the directory. I would consider it an improvement :wink: I’ll stick to the cd for now.

1 Like

Duplicacy does search for a repository config in the parent hierarchy: duplicacy/duplicacy_main.go at cdf8f5a8575fa50e22cad126a00140e38618b9fc · gilbertchen/duplicacy · GitHub

If you don’t bury the preference folder and keep it in e.g. ~ it will “just work” from anywhere under ~, you wont need to CD.

Not the same of course but may work depending on your circumstances.

That’s great, but I’m looking to target specific repositories on a server that may have 200+

git solves this easily with -C or --git-dir Run git from any directory: git -C vs git --git-dir | by Heba Waly | Medium

I agree, not restricting -pref-dir to init would be a simple but useful feature.