summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2010-12-07 20:31:20 -0600
committerSol Jerome <sol.jerome@gmail.com>2010-12-07 20:31:20 -0600
commit9f55492d9213861c75496e6c493ad90bb5c23872 (patch)
tree000a97facdc3229fed4f6849aae8574e134f92ef
parentcbc2d9dde1fbd89727d64e2544b88e433edde919 (diff)
parentc418a6bac2bda07aed96fecd2001334a67a39a38 (diff)
downloadbcfg2-9f55492d9213861c75496e6c493ad90bb5c23872.tar.gz
bcfg2-9f55492d9213861c75496e6c493ad90bb5c23872.tar.bz2
bcfg2-9f55492d9213861c75496e6c493ad90bb5c23872.zip
Merge branch 'master' into docs
-rw-r--r--src/lib/Server/Admin/Backup.py32
-rw-r--r--src/lib/Server/Admin/__init__.py2
-rwxr-xr-xsrc/sbin/bcfg2-info2
3 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/Server/Admin/Backup.py b/src/lib/Server/Admin/Backup.py
new file mode 100644
index 000000000..27a7fd8c8
--- /dev/null
+++ b/src/lib/Server/Admin/Backup.py
@@ -0,0 +1,32 @@
+import os
+import sys
+import time
+import tarfile
+import Bcfg2.Server.Admin
+import Bcfg2.Options
+
+class Backup(Bcfg2.Server.Admin.MetadataCore):
+ __shorthelp__ = "Make a backup of the Bcfg2 repository."
+ __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin backup")
+ #"\n\nbcfg2-admin backup restore")
+ __usage__ = ("bcfg2-admin backup")
+
+ def __init__(self, configfile):
+ Bcfg2.Server.Admin.MetadataCore.__init__(self, configfile,
+ self.__usage__)
+
+ def __call__(self, args):
+ Bcfg2.Server.Admin.MetadataCore.__call__(self, args)
+ # Get Bcfg2 repo directory
+ opts = {'repo': Bcfg2.Options.SERVER_REPOSITORY}
+ setup = Bcfg2.Options.OptionParser(opts)
+ setup.parse(sys.argv[1:])
+ self.datastore = setup['repo']
+ timestamp = time.strftime('%Y%m%d%H%M%S')
+ format = 'gz'
+ mode = 'w:' + format
+ filename = timestamp + '.tar' + '.' + format
+ out = tarfile.open(self.datastore + '/' + filename, mode=mode)
+ out.add(self.datastore, os.path.basename(self.datastore))
+ out.close()
+ print "Archive %s was stored under %s" % (filename, self.datastore)
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index 3a088b2fb..bb5c41895 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -2,7 +2,7 @@ __revision__ = '$Revision$'
__all__ = ['Mode', 'Client', 'Compare', 'Init', 'Minestruct', 'Perf',
'Pull', 'Query', 'Reports', 'Snapshots', 'Tidy', 'Viz',
- 'Xcmd', 'Group']
+ 'Xcmd', 'Group', 'Backup']
import ConfigParser
import logging
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index 497c39174..f379a51bb 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -238,7 +238,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
return
# handle <Path type='file'> entries
- for configfile in [cfile for cfile in client_config.findall(".//Path[@type = 'file']")]:
+ for configfile in [cfile for cfile in client_config.xpath(".//Path[@type = 'file']")]:
try:
write_config_file(odir, configfile)
except FileNotBuilt, ex: