10 #dump -0 / -f dump.img && dd if=/dev/zero of=filesystem.img bs=2M count=1000 && losetup /dev/loop0 filesystem.img && mkdir filesystem && mke2fs -j /dev/loop0 && mount -t ext3 /dev/loop0 -o loop filesystem && cd filesystem && restore -r -f ../dump.img && cd ../ && umount filesystem && losetup -d /dev/loop0
20 tmpdir
= tempfile
.mkdtemp()
24 tmpfile
= tempfile
.mkstemp()
28 current
= os
.stat(ent
).st_size
31 def mkempty(bs
, count
):
32 image
= tempfile
.mkstemp()
33 args
= ("/bin/dd", "if=/dev/zero", "of=%s"%image
, "bs=%s"%bs
, "count=%s"%count
)
38 args
= ("/sbin/dump", "-0", ent
, "-f", file)
50 args
= ("/bin/df", "-lh")
51 data
= execute(args
, needdata
=True)
52 lines
= data
.split('\n')
55 if re
.search(r
"/dev/", line
) and not re
.search(r
"tmpfs", line
):
56 ent
= re
.search(r
"/dev/[-0-9A-Za-z]+", line
)
57 ents
.append(ent
.group())
63 def execute(args
, needdata
=False):
65 rc
= subprocess
.call(args
)
67 rc
= subprocess
.Popen(args
, stdout
=subprocess
.PIPE
).communicate()[0]
77 dumpfile
= mktmpfile()
79 dumpfiles
.append(dumpfile
)
82 for dumpfile
in dumpfiles
:
83 tsize
= size(dumpfile
) + tsize
86 count
= (tsize
/ 2048)
88 target
= mkempty(bs
, count
)
98 if __name__
== "__main__":