Restore persist fails with: Cannot create a file when that file already exists

Please describe what you are doing to trigger the bug:
duplicacy.exe -background -log restore -stats -r 603 -persist -threads 4 -- "+e/*"

Please describe what you expect to happen (but doesn’t):
Restore all files, don’t override existing files. Continue even if errors occur. Any error, just continue until the end.

Please describe what actually happens (the wrong behaviour):

2022-02-12 11:33:15.492 ERROR RESTORE_SYMLINK Can't create symlink e/…2016-11-13/H/Documents and Settings: symlink C:\Users \\?\…\2016-11-13\H\Documents and Settings: Cannot create a file when that file already exists.

CLI version: 2.7.2

You’ll need to specify the -overwrite option. By default Duplicacy doesn’t overwrite existing files.

But I don’t want to overwrite. I want to persist. Use case: Restore all files that do not exist yet.

-persist isn’t meant for that purpose and you still have to -overwrite if files already exist - even though Duplicacy should skip restoring files that exist and match the metadata in the snapshot.

i.e. You can resume a restore if aborted halfway through, and the files that were already restored shouldn’t be downloaded from the backup storage. Or you can start with an existing structure and it’ll only download what’s necessary in order to update the restore location to what’s in the snapshot.

How do you know what -persist is meant for?

Me and a couple of others requested the -persist flag for the exact reason I posted above. As it’s currently implemented it does not make sense. It continues on file error and not on folder errors.

Guys, he doesn’t want to overwrite the files…

He wants the restore to continue even if errors occur, that’s exactly what the -persist option was created for.

I also don’t understand what’s wrong with his command, it seems correct for his purpose.

Given that

why didn’t it skip the file?

Maybe because it’s a symlink?

1 Like

Thank you @towerbr ! Exactly this :slight_smile: I don’t know how I could have expressid it clearer than “Restore all files, don’t override existing files.”…

I looked into the code and fixed it. The problem is that the persist flag is only checked for files and not for symlinks (and a couple of other cases). So: Only if an error occurs that is concerned about a file existing persist continues. The question is: Shall I create a PR for this?

@gchen :eyes: