Skip to content

Commit

Permalink
fix: backup-ldap - making sure we use the same timestamp (#33)
Browse files Browse the repository at this point in the history
* fix: backup-ldap - making sure we use the same timestamp

ldapsearch can take several seconds depending on the size of the LDAP
tree. Making sure we use the same timestamps across ldapsearch commands.

* variable naming: TSTP => timestamp

---------

Co-authored-by: Emilien Devos <[email protected]>
  • Loading branch information
pmauduit and edevosc2c authored Jan 23, 2025
1 parent 87f85d3 commit 3ef459c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions georchestra-backup-ldap/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ spec:
command: ["/bin/bash", "-c"]
args:
- |
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.usersRdn }},{{ $ldapTargetConfiguration.baseDn }}" > /backup/ldap-$(date +"%s").ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.pendingusersRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-$(date +"%s").ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.orgsRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-$(date +"%s").ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.pendingorgsRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-$(date +"%s").ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.rolesRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-$(date +"%s").ldif;
timestamp=$(date +"%s") ;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.usersRdn }},{{ $ldapTargetConfiguration.baseDn }}" > /backup/ldap-${timestamp}.ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.pendingusersRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-${timestamp}.ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.orgsRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-${timestamp}.ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.pendingorgsRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-${timestamp}.ldif;
/usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "{{ $ldapTargetConfiguration.adminDn }}" -w {{ $ldapTargetConfiguration.secret }} -b "{{ $ldapTargetConfiguration.rolesRdn }},{{ $ldapTargetConfiguration.baseDn }}" >> /backup/ldap-${timestamp}.ldif;
find /backup -name '*.ldif' -mtime +{{.Values.configuration.backupRetentionDays}} -delete ;
{{- with $job.resources }}
resources:
Expand Down

0 comments on commit 3ef459c

Please sign in to comment.