Commit 722b5abc authored by Sriram Karra's avatar Sriram Karra

Cleanup old BBDB backup files based on config.json parameter

config.json file format ver 3 introduces a paramter caled backup_hold_period
which deafults to 7 days.
parent 14a05653
##
## Created : Tue Apr 10 15:55:20 IST 2012
## Last Modified : Thu Jun 14 19:41:10 IST 2012
## Last Modified : Thu Jun 14 22:15:40 IST 2012
##
## Copyright (C) 2012 Sriram Karra <karra.etc@gmail.com>
##
......@@ -123,6 +123,7 @@ def setup_logging (config):
utils.del_files_older_than(logdir, period)
logging.info('Deleting log files older than %d days, if any...done',
period)
def setup_parser ():
p = argparse.ArgumentParser(description='ASynK: PIM Awesome Sync by Karra')
p.add_argument('--dry-run', action='store_true',
......
##
## Created : Sat Apr 07 18:52:19 IST 2012
## Last Modified : Thu May 17 08:44:09 IST 2012
## Last Modified : Thu Jun 14 22:21:23 IST 2012
##
## Copyright (C) 2012 by Sriram Karra <karra.etc@gmail.com>
##
......@@ -515,9 +515,16 @@ class BBPIMDB(PIMDB):
bdir = utils.abs_pathname(conf, conf.get_backup_dir())
if not os.path.exists(bdir):
logging.info('Creating backup directory at: %s', bdir)
logging.info('Creating BBDB backup directory at: %s', bdir)
os.mkdir(bdir)
period = conf.get_backup_hold_period()
logging.info('Deleting BBDB backup files older than %d days, '
'if any...', period)
utils.del_files_older_than(bdir, period)
logging.info('Deleting BBDB backup files older than %d days, '
'if any...done', period)
stamp = string.replace(str(datetime.datetime.now()), ' ', '.')
stamp = string.replace(stamp, ':', '-')
backup_name = os.path.join(bdir, 'bbdb_backup.' + pname + '.' + stamp)
......
##
## Created : Tue Jul 19 13:54:53 IST 2011
## Last Modified : Thu Jun 14 19:45:21 IST 2012
## Last Modified : Thu Jun 14 22:33:59 IST 2012
##
## Copyright (C) 2011, 2012 Sriram Karra <karra.etc@gmail.com>
##
......@@ -190,7 +190,12 @@ class Config:
return self._get_prop('config', 'backup_dir')
def get_backup_hold_period (self):
return self._get_prop('config', 'backup_hold_period')
try:
return self._get_prop('config', 'backup_hold_period')
except KeyError, e:
## Possibly due to a older version of the config.json. Silently
## return a default value
return 7
def get_log_dir (self):
return self._get_prop('config', 'log_dir')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment