Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to restore backups #5

Open
alfrepo opened this issue Oct 8, 2017 · 6 comments
Open

How to restore backups #5

alfrepo opened this issue Oct 8, 2017 · 6 comments
Labels

Comments

@alfrepo
Copy link

alfrepo commented Oct 8, 2017

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

@Athoir
Copy link

Athoir commented Nov 3, 2017

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

@abdulwahid24
Copy link

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

@Athoir
Copy link

Athoir commented Aug 10, 2018

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.

@kumy
Copy link

kumy commented May 2, 2019

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

@mdzddl
Copy link

mdzddl commented Oct 29, 2019

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

@gustavomcarmo
Copy link

gustavomcarmo commented Jan 26, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants