docker-openldap-backup
docker-openldap-backup copied to clipboard
How to restore backups
It is not described - how to restore the backups from the data found in my volume
After some research i found that there is a script called "slapd-restore-data" in the /sbin directory of the image. To restore your data you have to run this script with the file you want to restore as an argument.
Example:
> /sbin/slapd-restore-data 20171101T040001-data.gz
for a backup done the 11/01/17 at 4am
@Athoir Any idea to add the restore operation on container starting point?
I haven't worked on this one for a while but adding an CMD command similar to /sbin/slapd-restore-data /path/to/backup/RegexToLatest-data.gz should work.
You will have to test a few things:
- does it interfere with the normal start of the container (potential conflict with the entrypoint)
- What to do if there is no backup
- How much does it delay the start of the container (important if you need availability)
- probably more I have overlooked
Another option would be to take a look at the /container/tool/run script Osixia use to launch their stuff.
Here is how I do:
$ docker exec -it openldap bash
# sv stop /container/run/process/slapd
# rm -r /etc/ldap/slapd.d/*
# slapd-restore-config 20190502T082301-config
# sv stop /container/run/process/slapd
# rm /var/lib/ldap/*
# slapd-restore-data 20190502T080901-data
i am so careless PAYING ATTENTION: osixia/openldap-backup is docker which can be openldap and openlap-backup function; osixia/openldap can only be openldap below is my docker-compose,it work well
docker-compose
version: '2'
services:
phpldapadmin:
: osixia/phpldapadmin
environment:
PHPLDAPADMIN_LDAP_HOSTS: openldap
PHPLDAPADMIN_HTTPS: "false"
links:
- openldap
ports:
- 8080:80
restart: always
openldap:
: osixia/openldap-backup:1.3.0
environment:
LDAP_BACKUP_CONFIG_CRON_EXP: "*/5 * * * *"
LDAP_BACKUP_DATA_CRON_EXP: "*/5 * * * *"
LDAP_ORGANISATION: "socket"
LDAP_DOMAIN: socket.com
LDAP_ADMIN_PASSWORD: passwd
volumes:
- ./data/backup:/data/backup
- ./data/slapd/database:/var/lib/ldap
- ./data/slapd/config:/etc/ldap/slapd.d
restart: always
ports:
- 389:389
- 689:689
when you want to restore data,please do below, this method from @kumy
do in docker-openldap-backup docker
$ docker exec -it docker-openldap-backup bash
#sv stop /container/run/process/slapd
#rm -r /etc/ldap/slapd.d/*
#slapd-restore-config 20190502T082301-config
#sv stop /container/run/process/slapd
#rm /var/lib/ldap/*
#slapd-restore-data 20190502T080901-data
Thanks to @Athoir's comment I finally managed to restore a backup file on startup by extending the image like the following:
FROM osixia/openldap-backup:1.4.0
COPY custom-backup.sh /container/service/slapd-backup/assets/tool/slapd-backup
COPY custom-restore.sh .
CMD ["-c", "./custom-restore.sh", "process"]