hitting memory issues on the dump box; need to sync then compress on remote
This commit is contained in:
parent
3909b0c783
commit
4cf5a6393a
@ -16,6 +16,7 @@
|
|||||||
# SKSUSER ALL = NOPASSWD: SKSCMDS
|
# SKSUSER ALL = NOPASSWD: SKSCMDS
|
||||||
|
|
||||||
|
|
||||||
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import getpass
|
import getpass
|
||||||
import os
|
import os
|
||||||
@ -26,6 +27,10 @@ from grp import getgrnam
|
|||||||
NOW = datetime.datetime.utcnow()
|
NOW = datetime.datetime.utcnow()
|
||||||
NOWstr = NOW.strftime('%Y-%m-%d')
|
NOWstr = NOW.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
# - use a config file system
|
||||||
|
# - cleanup/rotation should be optional
|
||||||
|
|
||||||
sks = {
|
sks = {
|
||||||
# chowning - MAKE SURE THIS IS THE USER SKS RUNS AS.
|
# chowning - MAKE SURE THIS IS THE USER SKS RUNS AS.
|
||||||
'user': 'sks',
|
'user': 'sks',
|
||||||
@ -173,14 +178,38 @@ def syncDB():
|
|||||||
subprocess.run(cmd, stdout = f, stderr = f)
|
subprocess.run(cmd, stdout = f, stderr = f)
|
||||||
return()
|
return()
|
||||||
|
|
||||||
|
def parseArgs():
|
||||||
|
args = argparse.ArgumentParser(description = 'sksdump - a tool for dumping the SKS Database',
|
||||||
|
epilog = 'brent s. || 2017 || https://square-r00t.net')
|
||||||
|
args.add_argument('-d',
|
||||||
|
'--no-dump',
|
||||||
|
dest = 'nodump',
|
||||||
|
action = 'store_true',
|
||||||
|
help = 'Don\'t dump the SKS DB (default is to dump)')
|
||||||
|
args.add_argument('-c',
|
||||||
|
'--no-compress',
|
||||||
|
dest = 'nocompress',
|
||||||
|
action = 'store_true',
|
||||||
|
help = 'Don\'t compress the DB dumps (default is to compress)')
|
||||||
|
args.add_argument('-s',
|
||||||
|
'--no-sync',
|
||||||
|
dest = 'nosync',
|
||||||
|
action = 'store_true',
|
||||||
|
help = 'Don\'t sync the dumps to the remote server.')
|
||||||
|
return(args)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
args = vars(parseArgs().parse_args())
|
||||||
if getpass.getuser() not in ('root', sks['user']):
|
if getpass.getuser() not in ('root', sks['user']):
|
||||||
exit('ERROR: You must be root or {0}!'.format(sks['user']))
|
exit('ERROR: You must be root or {0}!'.format(sks['user']))
|
||||||
with open(sks['logfile'], 'a') as f:
|
with open(sks['logfile'], 'a') as f:
|
||||||
f.write('===== {0} STARTING ====='.format(str(datetime.datetime.utcnow())))
|
f.write('===== {0} STARTING ====='.format(str(datetime.datetime.utcnow())))
|
||||||
dumpDB()
|
if not args['nodump']:
|
||||||
compressDB()
|
dumpDB()
|
||||||
syncDB()
|
if not args['nocompress']:
|
||||||
|
compressDB()
|
||||||
|
if not args['nosync']:
|
||||||
|
syncDB()
|
||||||
with open(sks['logfile'], 'a') as f:
|
with open(sks['logfile'], 'a') as f:
|
||||||
f.write('===== {0} DONE ====='.format(str(datetime.datetime.utcnow())))
|
f.write('===== {0} DONE ====='.format(str(datetime.datetime.utcnow())))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user