- def backupFileSet(self, fileset, targetdir, since=None):
+ def backupFileSet(self, fileset, targetdir, log, since=None):
"""Create an archive for given fileset at given target directory."""
print("Running file set: " + fileset.name)
tarargs = [tarpath] + taropts + ["-f", fsfn] + fileset.dirs
#print("tarargs: ", tarargs)
- tarp = subprocess.Popen( tarargs )
+ print("tar call: " + " ".join(tarargs), file=log)
+ tarp = subprocess.Popen( tarargs, stderr=subprocess.PIPE )
rett = tarp.wait()
if rett != 0:
- print(tarpath + " returned with exit status " + str(rett) + ":")
+ sys.stderr.write( tarp.stderr.read() )
+ msg = tarpath + " returned with exit status " + str(rett) + "."
+ print(msg)
+ print(msg, log)
def backup(self, epoch=None, mode=None):
os.mkdir( targetdir )
+ log = open(os.path.join(targetdir, "log.log"), 'w')
+ print("Started: " + now.ctime(), file=log)
+
# Backup all file sets
for s in self.conf.sets:
- self.backupFileSet(s, targetdir, since)
+ self.backupFileSet(s, targetdir, log, since)
+
+ print("Stopped: " + datetime.datetime.now().ctime(), file=log)
+ log.close()
# Rename backup directory to final name
os.rename( targetdir, os.path.join(basedir, dirname) )
f.close()
+
def prune(self):
"""Prune old backup files"""