Command line noob needs help with setting up CLI version in Windows

I haven’t used command line programs much and need some help, please. I’m following the CLI quick set up guide and can’t get past the “init” command. I’m doing this on a Windows PC and trying to backup to B2.

First I downloaded the EXE program and saved it to a new C:/Duplicacy folder.
Then I opened the command prompt, went to C:/Duplicacy and typed in the name of the win64 exe file. That seemed to run.
Then I went up one level to my C drive since that is what I want to backup.
Then I typed in "duplicacy init [my label for this repository] b2://[my bucket name]/[the name of the folder I created in the bucket]
Then I get the response “duplicacy is not recognized …”

What am I doing wrong? Thanks for any tips you may have!

The trick with CLI on Windows is that, for ease of use, it’s best to add the path of your executable to the $PATH environment variable so that Windows can find and run it no matter where your current working directory (cd) is set to.

Duplicacy needs your current working directory set to the root of your repository, so you either have to specify the relative or absolute path to the .exe - i.e. duplicacy\duplicacy_win_x64_2.1.2.exe init blah (relative to C:) or just C:\duplicacy\duplicacy_win_x64_2.1.2.exe init blah for an absolute path.

Or just add the path to the environment variables. (A quick way to get to System Properties is to click Start and type sysdm.cpl > Advanced tab etc.) Add C:\Duplicacy to the list of paths.

I’d also recommend renaming duplicacy_win_x64_2.1.2.exe to just duplicacy.exe. Then you can just use duplicacy init blah from then on.

However, you might want to consider backing up a smaller section like C:\Users instead of the whole C drive, because unless you exclude a whole bunch of stuff like in C:\Windows and Program Files, you’ll likely get a lot of permission errors (unless you run as administrator and use the -vss volume shadow copy option). And there’s little point backup up system files on Windows using a file-based backup tool because there’s no clean way to restore them properly. Concentrate on backing up important data.

2 Likes

Great advice and tips you have … thanks!

So, instead of doing all of C, is there a way to list multiple folders for backup or do I have to repeat the INIT command in each one? Also, if in the future, I create a new folder in C, is there a way to automatically include it without having to go and add it using the INIT command?

You can do it a couple ways.

Firstly, multiple repositories with multiple init's - that’s kinda the suggested way. e.g. C:\Users and maybe C:\ProgramData. Stick to placing data within your profile directory or a separate data partition.

Just give each repo a different name and add each backup job to a batch file. You’d ‘cd’ into each directory and do a duplicacy backup. A bit long-winded but fairly simple to get to grips with.

Alternatively, backup C:\ but definitely exclude a whole bunch of system files that you don’t need. There’s a few examples floating about, but that would include any new folders automatically.

1 Like

Great … thanks again for the help!

For anyone: Feel free to use the :heart: button on the posts that you found useful.

For the OP of any #support topic: you can mark the post that solved your issue by ticking the image box under the post. That of course may include your own post :slight_smile:

Hey, I thought of another question. Does CLI Duplicacy for Windows keep running automatically once I set it up, or do I have to put it in some kind of boot or startup directory so it always starts up when the PC is started up?

Oh most definitely not automatic, you have to set up a scheduled task…

There’s a few ways to do this. One is to create a .bat file, but these days Microsoft is pushing to replace that with PowerShell, so that’s what I’d suggest. Pretty much the same commands, though.

Create a text file called duplicacy.ps1 and put it in C:\Duplicacy (it doesn’t have to go in there but it’s a good place to put it), with the following as example:

cd "C:\Users"
duplicacy -log backup -vss -stats

cd "E:\ProgramData"
duplicacy -log backup -stats

Replace pathnames as appropriate, add or remove sections for each repository you want to back up.

Press the Start button, type ‘task’ and select Task Scheduler. Right-click Task Scheduler Library on the left and Create Basic Task. Run through the wizard - you want to Start a program.

For program/script, put simply Powershell.exe

For Add arguments, put -ExecutionPolicy Bypass C:\Duplicacy\duplicacy.ps1 (don’t forget the minus/dash immediately before ExecutionPolicy)

Tick Open the Properties dialog… before clicking Finish so you can make a minor change. On the next dialog, tick Run with highest privileges and then OK.

That’s it.

To test, right-click the task and Run. Otherwise, it’ll run on your schedule.

Some notes… Because you want to backup your user profile under C:\Users, those files will be in use, so the example above adds the -vss switch to tell Duplicacy to make a shadow copy snapshot before backing up that repository. This requires elevated privileges, hence the minor change to the basic task.

3 Likes

Wow, thanks for all the details! You’ve pretty much written a great guide for new users in your answers to me. I appreciate your help!