How to restore folders to their original destination using duplicity?

13,702

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.

Share:
13,702

Related videos on Youtube

Question Overflow
Author by

Question Overflow

I don't have any formal education on programming. I guess it is the passion that gets me started and keeps me going. Thanks everybody for sharing your knowledge. Don't worry, I am no critic. I see no wrong answer, only good and not so good answers. All are welcome to learn and to share.

Updated on September 18, 2022

Comments

  • Question Overflow
    Question Overflow almost 2 years

    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
    
  • Question Overflow
    Question Overflow almost 10 years
    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!
  • bernie
    bernie almost 5 years
    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
  • Andrew DeFaria
    Andrew DeFaria almost 3 years
    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.