[bin] backup.py: remove Data.fs.old before packing the ZODB to avoid disk space problems; [checkldap] added a param to define the scope of the LDAP query (base, onelevel or subtree); [shared] xml_parser: convert nbsp entity to the equivalent utf-8 char.
This commit is contained in:
parent
528cca9aa0
commit
1be7d9f0ab
8 changed files with 83 additions and 22 deletions
|
@ -61,6 +61,21 @@ class ZodbBackuper:
|
|||
fileName = self.storageLocation + fileSuffix
|
||||
os.system('chown %s %s' % (self.zopeUser, fileName))
|
||||
|
||||
def removeDataFsOld(self):
|
||||
'''Removes the file Data.fs.old if it exists.
|
||||
|
||||
In the process of packing the ZODB, an additional file Data.fs.pack
|
||||
is created, and renamed to Data.fs once finished. It means that, when
|
||||
we pack the ZODB, 3 copies of the DB can be present at the same time:
|
||||
Data.fs, Data.fs.old and Data.fs.pack. We prefer to remove the
|
||||
Data.fs.old copy to avoid missing disk space if the DB is big.
|
||||
'''
|
||||
old = self.storageLocation + '.old'
|
||||
if os.path.exists(old):
|
||||
self.log('Removing %s...' % old)
|
||||
os.remove(old)
|
||||
self.log('Done.')
|
||||
|
||||
folderCreateError = 'Could not create backup folder. Backup of log ' \
|
||||
'files will not take place. %s'
|
||||
def backupLogs(self):
|
||||
|
@ -190,6 +205,8 @@ class ZodbBackuper:
|
|||
self.executeCommand('%s stop' % self.zopectl)
|
||||
# If we are on the "full backup day", let's pack the ZODB first
|
||||
if time.asctime().startswith(self.options.dayFullBackup):
|
||||
# As a preamble to packing the ZODB, remove Data.fs.old if present.
|
||||
self.removeDataFsOld()
|
||||
w('> Day is "%s", packing the ZODB...' % self.options.dayFullBackup)
|
||||
self.packZodb()
|
||||
w('> Make a backup of log files...')
|
||||
|
|
|
@ -12,18 +12,22 @@ class LdapTester:
|
|||
attrs is a comma-separated list of attrs we will retrieve in the LDAP,
|
||||
ie "uid,login"
|
||||
filter is the query filter, ie "(&(attr1=Geez*)(status=OK))"
|
||||
scope is the scope of the search, and can be:
|
||||
BASE To search the object itself on base
|
||||
ONELEVEL To search base's immediate children
|
||||
SUBTREE To search base and all its descendants
|
||||
'''
|
||||
def __init__(self):
|
||||
# Get params from shell args.
|
||||
if len(sys.argv) != 7:
|
||||
if len(sys.argv) != 8:
|
||||
print(LdapTester.__doc__)
|
||||
sys.exit(0)
|
||||
s = self
|
||||
s.uri, s.login, s.password, s.base, s.attrs, s.filter = sys.argv[1:]
|
||||
s.uri,s.login,s.password,s.base,s.attrs,s.filter,s.scope = sys.argv[1:]
|
||||
self.attrs = self.attrs.split(',')
|
||||
self.tentatives = 5
|
||||
self.timeout = 5
|
||||
self.attrList = ['cfwbV2cn', 'logindisabled']
|
||||
self.attrList = ['cn']
|
||||
self.ssl = False
|
||||
|
||||
def test(self):
|
||||
|
@ -38,8 +42,9 @@ class LdapTester:
|
|||
for i in range(self.tentatives):
|
||||
try:
|
||||
print('Done. Performing a simple query on %s...'% self.base)
|
||||
res = server.search_st(
|
||||
self.base, ldap.SCOPE_ONELEVEL, filterstr=self.filter,
|
||||
res = server.search_st(self.base,
|
||||
getattr(ldap, 'SCOPE_%s' % self.scope),
|
||||
filterstr=self.filter,
|
||||
attrlist=self.attrs, timeout=5)
|
||||
print('Got %d entries' % len(res))
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue