docker-openldap-backup icon indicating copy to clipboard operation
docker-openldap-backup copied to clipboard

How to restore backups

Open alfrepo opened this issue 8 years ago • 6 comments
trafficstars

It is not described - how to restore the backups from the data found in my volume

alfrepo avatar Oct 08 '17 12:10 alfrepo

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 avatar Nov 03 '17 15:11 Athoir

@Athoir Any idea to add the restore operation on container starting point?

abdulwahid24 avatar Aug 06 '18 20:08 abdulwahid24

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.

Athoir avatar Aug 10 '18 19:08 Athoir

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

kumy avatar May 02 '19 14:05 kumy

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

mdzddl avatar Oct 29 '19 14:10 mdzddl

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"]

gustavomcarmo avatar Jan 26 '21 19:01 gustavomcarmo