diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2010-12-07 20:31:20 -0600 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-12-07 20:31:20 -0600 |
commit | 9f55492d9213861c75496e6c493ad90bb5c23872 (patch) | |
tree | 000a97facdc3229fed4f6849aae8574e134f92ef /src/lib/Server/Admin/Backup.py | |
parent | cbc2d9dde1fbd89727d64e2544b88e433edde919 (diff) | |
parent | c418a6bac2bda07aed96fecd2001334a67a39a38 (diff) | |
download | bcfg2-9f55492d9213861c75496e6c493ad90bb5c23872.tar.gz bcfg2-9f55492d9213861c75496e6c493ad90bb5c23872.tar.bz2 bcfg2-9f55492d9213861c75496e6c493ad90bb5c23872.zip |
Merge branch 'master' into docs
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) |