diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2011-03-06 12:04:33 -0600 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2011-03-06 12:04:33 -0600 |
commit | 1d17b980a15a2fd138ad746d51e148befa26faa0 (patch) | |
tree | 3fe15a14f1be49fe4aef8ebc9b6b38f49461c214 /src/lib | |
parent | f26780538a46beac2655230a93bd2134af7fc5bc (diff) | |
download | bcfg2-1d17b980a15a2fd138ad746d51e148befa26faa0.tar.gz bcfg2-1d17b980a15a2fd138ad746d51e148befa26faa0.tar.bz2 bcfg2-1d17b980a15a2fd138ad746d51e148befa26faa0.zip |
Better handling of backup files in paranoid mode (Patch from mkd ticket #995)
1. Client removes only one excess backup copy at every configfile
change, even if there are more backup copies eligible for deletion.
Moreover, lowering the max_copies parameter could cause client to never
remove any excess files from there.
2. Space character in backup file names is mildly annoying -
datetime.isoformat() will put a 'T' there instead.
3. More robust handling of 'paranoid' attribute values from info.xml
(paranoid='True' should also be allowed - currently only paranoid='true'
works as expected).
A simple patch (attached) addresses all these issues.
/mkd
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Client/Tools/POSIX.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py index c883fc17a..bcb9f48b3 100644 --- a/src/lib/Client/Tools/POSIX.py +++ b/src/lib/Client/Tools/POSIX.py @@ -542,7 +542,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False # If we get here, then the parent directory should exist - if (entry.get("paranoid", False) == 'true') and \ + if (entry.get("paranoid", False) in ['true', 'True']) and \ self.setup.get("paranoid", False) and not \ (entry.get('current_exists', 'true') == 'false'): bkupnam = entry.get('name').replace('/', '_') @@ -550,7 +550,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): bkuplist = [f for f in os.listdir(self.ppath) if f.startswith(bkupnam)] bkuplist.sort() - if len(bkuplist) == int(self.max_copies): + while len(bkuplist) >= int(self.max_copies): # remove the oldest backup available oldest = bkuplist.pop(0) self.logger.info("Removing %s" % oldest) @@ -563,7 +563,8 @@ class POSIX(Bcfg2.Client.Tools.Tool): try: # backup existing file shutil.copy(entry.get('name'), - "%s/%s_%s" % (self.ppath, bkupnam, datetime.now())) + "%s/%s_%s" % (self.ppath, bkupnam, + datetime.isoformat(datetime.now()))) self.logger.info("Backup of %s saved to %s" % (entry.get('name'), self.ppath)) except IOError, e: |