Skip to content

Instantly share code, notes, and snippets.

@hwmrocker
Created November 14, 2011 22:33
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()
@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