11

After performing a backup of a couple of directories like so:

# duplicity\
 --exclude /home/user/Documents/test1/file\
 --include /home/user/Documents/test1\
 --include /tmp/test2\
 --exclude '**'\
 / file:///home/user/Backup

I wanted to test how the restoration works by deleting the backed up directories:

# rm -rf /home/user/Documents/test1 /tmp/test2

And then, restoring the backup,

# duplicity file:///home/user/Backup /

But I got the error,

Restore destination directory / already exists.
Will not overwrite.

So it appears that I can't restore to the original destination without emptying the root folder even though the destination of these included folders have already been cleared.

Is there a better way than to restore it to another location and then moving each folder one by one?

# duplicity --file-to-restore home/user/Documents/test1 file:///home/user/Backup /home/user/Restore1
# mv /home/user/Restore1/home/user/Documents/test1 /home/user/Documents/test1
# duplicity --file-to-restore tmp/test2 file:///home/user/Backup /home/user/Restore2
# mv /home/user/Restore2/tmp/test2 /tmp/test2

1 Answer 1

19

It's really easy - use the --force flag.

duplicity --force file:///home/user/Backup /

This will probably not only restore missing files to the directories you've backed up, but also replace newer versions of backed up files if they exist, but it's better than nothing.

4
  • Indeed, setting the --force flag works. I wonder why the man page does not document this behaviour for the restore option. It saves me the additional step of having to rsync from a different location. Thanks! Commented Sep 7, 2014 at 8:57
  • Note that even with the --force flag, Duplicity will NOT delete files in / that are not present in the backup. Tested in Ubuntu 18.04LTS + Duplicity 0.7.17
    – bernie
    Commented Aug 6, 2019 at 7:10
  • 1
    deja-dup (a gui for duplicity) provides a "--restore-missing" parameters. Duplicity command line should have the same to avoid extracting everything. Commented Jan 4, 2021 at 1:25
  • 1
    It would be amazing if the man page actually mentioned that but it doesn't. Instead is says "--force Proceed even if data loss might result. Duplicity will let the user know when this option is required". But it doesn't let the user know. Additionally, the --force option is mentioned on things like the remove command and the cleanup command but not mentioned at all on the restore command. Commented Sep 20, 2021 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .