-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestorehelp
More file actions
executable file
·48 lines (36 loc) · 1.05 KB
/
restorehelp
File metadata and controls
executable file
·48 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
# Gianmarco Brocchi
'''
Script that help to restore files
from a Deja-dup backup by hand.
Use ./restorehelp multivolume_snapshot_path
It merges the file in multivolume_snapshot.
'''
import os, sys
#from subprocess import call
from glob import iglob
import shutil
try:
rootdir = sys.argv[1]
except:
print "Insert the multivolume_snapshot's path"
sys.exit()
for root, subFolders, files in os.walk(rootdir):
for filename in files:
if filename == "1":
filePath = os.path.join(root)
folder = os.path.basename(filePath)
# outfile = filePath.replace('multivol_','',1)
outfile = filePath + "/" + folder
print outfile
# Implement "cat * > folder"
# call(["cat " + all_file + ">" + outfile], shell=True)
# Check if file exists
if ( os.path.exists(outfile) == False ):
destination = open(outfile, 'wb')
for filename in iglob(os.path.join(filePath, '*')):
shutil.copyfileobj(open(filename, 'rb'), destination)
destination.close()
print "Creo file: %s" % folder
else:
print "File %s exists" % folder