projects
/
sitarba.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e56611c
)
write log file and print tar's stderr afterwards
author
Stefan Huber <shuber2@gmx.at>
Mon, 14 May 2012 18:43:01 +0000
(20:43 +0200)
committer
Stefan Huber <shuber2@gmx.at>
Mon, 14 May 2012 18:43:01 +0000
(20:43 +0200)
TODO.txt
patch
|
blob
|
history
shbackup
patch
|
blob
|
history
diff --git
a/TODO.txt
b/TODO.txt
index 2488c323811b33148025d4ca557b3ac21bda9517..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
(file)
--- a/
TODO.txt
+++ b/
TODO.txt
@@
-1,4
+0,0
@@
-- print size in list
-- remember tar commands
-- ask to proceed when making backup
-- print and log exit code and stderr of tar afterwards
diff --git
a/shbackup
b/shbackup
index 17bd3318208b8ce01e6363c68a628e15a80a55a7..239dfa3520faefef2acfb55904621f3eb32ebbe9 100755
(executable)
--- a/
shbackup
+++ b/
shbackup
@@
-249,7
+249,7
@@
class BackupManager:
- 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)
"""Create an archive for given fileset at given target directory."""
print("Running file set: " + fileset.name)
@@
-266,11
+266,15
@@
class BackupManager:
tarargs = [tarpath] + taropts + ["-f", fsfn] + fileset.dirs
#print("tarargs: ", tarargs)
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:
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):
def backup(self, epoch=None, mode=None):
@@
-328,9
+332,15
@@
class BackupManager:
os.mkdir( targetdir )
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:
# 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) )
# Rename backup directory to final name
os.rename( targetdir, os.path.join(basedir, dirname) )
@@
-342,6
+352,7
@@
class BackupManager:
f.close()
f.close()
+
def prune(self):
"""Prune old backup files"""
def prune(self):
"""Prune old backup files"""