some final cleanup

This commit is contained in:
brent s 2019-06-05 23:56:01 -04:00
parent dbc4d6c4b1
commit caedb86aa5
2 changed files with 10 additions and 11 deletions

View File

@ -42,7 +42,7 @@ loglvls = {'critical': logging.CRITICAL,
'debug': logging.DEBUG} 'debug': logging.DEBUG}


### DEFAULT NAMESPACE ### ### DEFAULT NAMESPACE ###
dflt_ns = 'http://git.square-r00t.net/OpTools/tree/storage/backups/borg/' dflt_ns = 'http://git.square-r00t.net/BorgExtend/tree/storage/backups/borg/'




### THE GUTS ### ### THE GUTS ###
@ -255,11 +255,11 @@ class Backup(object):
_loc_env['BORG_PASSPHRASE'] = repo['password'] _loc_env['BORG_PASSPHRASE'] = repo['password']
self.logger.info('[{0}]: BEGIN BACKUP: {1}'.format(server, repo['name'])) self.logger.info('[{0}]: BEGIN BACKUP: {1}'.format(server, repo['name']))
if 'prep' in repo: if 'prep' in repo:
tmpdir = os.path.abspath(os.path.expanduser('~/.cache/.optools_backup')) tmpdir = os.path.abspath(os.path.expanduser('~/.cache/.borgextend'))
os.makedirs(tmpdir, exist_ok = True) os.makedirs(tmpdir, exist_ok = True)
os.chmod(tmpdir, mode = 0o0700) os.chmod(tmpdir, mode = 0o0700)
for idx, prep in enumerate(repo['prep']): for idx, prep in enumerate(repo['prep']):
exec_tmp = tempfile.mkstemp(prefix = '_optools.backup.', exec_tmp = tempfile.mkstemp(prefix = '_borgextend.',
suffix = '._tmpexc', suffix = '._tmpexc',
text = True, text = True,
dir = tmpdir)[1] dir = tmpdir)[1]
@ -284,13 +284,13 @@ class Backup(object):
self.logger.debug('Initializing plugin: {0}'.format(plugin)) self.logger.debug('Initializing plugin: {0}'.format(plugin))
if repo['plugins'][plugin]['path']: if repo['plugins'][plugin]['path']:
sys.path.insert(1, os.path.abspath(os.path.expanduser(repo['plugins'][plugin]['path']))) sys.path.insert(1, os.path.abspath(os.path.expanduser(repo['plugins'][plugin]['path'])))
optools_tmpmod = importlib.import_module(plugin, package = None) borgextend_tmpmod = importlib.import_module(plugin, package = None)
if not repo['plugins'][plugin]['params']: if not repo['plugins'][plugin]['params']:
optools_tmpmod.Backup() borgextend_tmpmod.Backup()
else: else:
optools_tmpmod.Backup(**repo['plugins'][plugin]['params']) borgextend_tmpmod.Backup(**repo['plugins'][plugin]['params'])
del(sys.modules[plugin]) del(sys.modules[plugin])
del(optools_tmpmod) del(borgextend_tmpmod)
sys.path = _orig_path sys.path = _orig_path
self.logger.debug('Finished plugin: {0}'.format(plugin)) self.logger.debug('Finished plugin: {0}'.format(plugin))
# This is where we actually do the thing. # This is where we actually do the thing.
@ -598,7 +598,7 @@ def parseArgs():
_cfgfile = os.path.abspath( _cfgfile = os.path.abspath(
os.path.join(os.path.expanduser('~'), os.path.join(os.path.expanduser('~'),
'.config', '.config',
'optools', 'borgextend',
'backup.xml')) 'backup.xml'))
_defloglvl = 'info' _defloglvl = 'info'
###### ######
@ -778,8 +778,7 @@ def convertConf(cfgfile):
namespaces = {None: dflt_ns, namespaces = {None: dflt_ns,
'xsi': 'http://www.w3.org/2001/XMLSchema-instance'} 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
xsi = {('{http://www.w3.org/2001/' xsi = {('{http://www.w3.org/2001/'
'XMLSchema-instance}schemaLocation'): ('http://git.square-r00t.net/OpTools/plain/' 'XMLSchema-instance}schemaLocation'): ('http://git.square-r00t.net/BorgExtend/plain/config.xsd')}
'storage/backups/borg/config.xsd')}
genname = 'LXML (http://lxml.de/)' genname = 'LXML (http://lxml.de/)'
root = etree.Element('borg', nsmap = namespaces, attrib = xsi) root = etree.Element('borg', nsmap = namespaces, attrib = xsi)
root.append(etree.Comment(('Generated by {0} on {1} from {2} via {3}').format(sys.argv[0], root.append(etree.Comment(('Generated by {0} on {1} from {2} via {3}').format(sys.argv[0],

View File

@ -18,7 +18,7 @@ except ImportError:
import subprocess import subprocess
has_yum = False has_yum = False


# See <optools>:/storage/backups/borg/tools/restore_yum_pkgs.py to use the XML file this generates. # See <borgextend>:/tools/restore_yum_pkgs.py to use the XML file this generates.




# Detect RH version. # Detect RH version.