Ubuntu – How to restore a broken Deja Dup backup manually

backupcommand linedeja-duprestore

For various reasons (possibly this bug) a Deja Dup backup I made failed. I have been following this guide to restore my backup by hand. The steps have been:

In the folder containing the backups run:

for t in duplicity-full.[yournumbershere].*.difftar.gz; do tar xf $t; done

This gave me two folders: multivol_snapshot and snapshot. In the multivol_snapshot folder are all of my files but split up into smaller files. I could join each manually by running cat * > file.txt but this would take a very long time. The page provides a script called duplicity_join.py which joins them together. However, it doesn't preserve the folder structure and so any files or folders with the same name get overwritten.

Is there an existing method available for joining the files automatically that preserves the folder structure?

Best Answer

Copying the solution from this guide with my modifications:

Open a Terminal and navigate to the directory containing your backups. This folder contains all of your files archived into many .gz files. Mine was in a folder called multivol_snapshot. Unpack all the archives with the following command:

for t in duplicity-full.[yournumbershere].*.difftar.gz; do tar xf $t; done

This might take awhile. I had 138GB of data which took five hours to untar.

Running this will give you your files and folders back in the correct structure with one caveat: All of the files are split into smaller pieces. You can join these files back manually easily by running the following command:

cat * > examplefile.txt

However, if you have thousands of files doing this could take a very long time. David Huss wrote a Python script called duplicity_joiner.py to make this easier. Download it here.

To run it, you need python and tk. Install this by running:

sudo apt-get install python-dev sudo apt-get install python-tk

Using this script you can select the folder where to restore your files, with one caveat: This script doesn't maintain the folder structure. So, if you have many folders and files with the same name there is a possibility that they will be overwritten.

I have rewritten the script to address this. It will preserve the folder structure but can result in very long folder paths. Download it here.