Skip to content

Instantly share code, notes, and snippets.

@hwmrocker
Created November 14, 2011 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwmrocker/1365425 to your computer and use it in GitHub Desktop.
Save hwmrocker/1365425 to your computer and use it in GitHub Desktop.
restore broken dejadup / duplicity fullbackup without manifest
#!/usr/bin/env python
import os
FROM = '/media/New Volume/dejadup-bakup'
TO_TMP = '/home/johndoe/tmp'
TO_MULTI = TO_TMP + '/multivol_snapshot'
TO_SNAP = TO_TMP + '/snapshot'
def do(stuff):
print stuff
os.system(stuff)
def m2s(path):
assert path.startswith(TO_MULTI), 'It must be a multivol path'
tmp = path.replace(TO_MULTI, TO_SNAP, 1)
if tmp.endswith('/'):
tmp = tmp[:-1]
return tmp
def main():
# restore broken dejadup / duplicity fullbackup without manifest
# Step One
# untar
os.chdir(TO_TMP)
do("for t in \"" + FROM + "/\"*.difftar; do echo $t; "
"tar xf \"$t\"; done;")
# Step Two
# join multipart files
for (path, dirs, files) in os.walk(TO_MULTI):
print path
if len(dirs) == 0:
# we need to combine all these elements
do("cat \"" + path + "\"/* > \"" + m2s(path) + "\"")
#do("rm *")
else:
do("mkdir -p \"" + m2s(path) + "\"")
if __name__ == '__main__':
main()
@zwenson
Copy link

zwenson commented Apr 28, 2014

add
for f in files:
os.rename(os.path.join(path, f),os.path.join(path, str(f).zfill(10)))
to line 36
to solve issues with files which consist of more than [0-9] parts

@udara86
Copy link

udara86 commented Dec 9, 2015

How to use this script to restore my backup files in my cloudvps remote server ? Can anyone share the steps need to be followed ?? Thanks lot

@unclesuss
Copy link

unclesuss commented Oct 20, 2017

I've had to modify the script so that it would cat files in proper numerical order 1,2,3,4 etc rather than 1,10,11,12,2,3,4 etc

# we need to combine all these elements
#do("cat \"" + path + "\"/* > \"" + m2s(path) + "\"")
do("find \"" + path + "\" -name \"*\" | sort -V | xargs cat - > \"" + m2s(path) + "\"")

This throws an error on the first line passed to cat, however it properly puts the files back together.

HOW TO: download all your files from your cloud, download this script and change the directories in the script to match your setup: FROM = '/media/New Volume/dejadup-bakup' TO_TMP = '/home/johndoe/tmp', and run the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment