diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2010-12-08 21:38:29 -0600 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2010-12-08 21:38:29 -0600 |
commit | dfcabfcbfc6970c526c80e6f688744966e532c66 (patch) | |
tree | 7994cc2d40fcb4bbc4e3c3a508d8f4c26a13ce30 /src/lib/Server/Admin/Backup.py | |
parent | 19dd6674fe58f3f83a5fa85d2f8ebacf2bfd5e13 (diff) | |
parent | d08c7ba3ca269639edd8e7696558c74bc06fb487 (diff) | |
download | bcfg2-dfcabfcbfc6970c526c80e6f688744966e532c66.tar.gz bcfg2-dfcabfcbfc6970c526c80e6f688744966e532c66.tar.bz2 bcfg2-dfcabfcbfc6970c526c80e6f688744966e532c66.zip |
Merge branch 'master' of git.mcs.anl.gov:bcfg2
Diffstat (limited to 'src/lib/Server/Admin/Backup.py')
-rw-r--r-- | src/lib/Server/Admin/Backup.py | 32 |
1 files changed, 32 insertions, 0 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) |