├── .gitignore ├── image ├── service │ └── slapd-backup │ │ ├── assets │ │ ├── tool │ │ │ ├── slapd-backup-data │ │ │ ├── slapd-backup-config │ │ │ ├── slapd-restore-data │ │ │ ├── slapd-restore-config │ │ │ ├── slapd-restore │ │ │ └── slapd-backup │ │ └── cronjobs │ │ └── startup.sh ├── environment │ └── default.yaml └── Dockerfile ├── test ├── test.bats └── test_helper.bash ├── Makefile ├── LICENSE ├── .travis.yml ├── CHANGELOG.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /.twgit_features_subject 2 | /.twgit 3 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/tool/slapd-backup-data: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | /sbin/slapd-backup 1 data 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/tool/slapd-backup-config: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | /sbin/slapd-backup 0 config 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /test/test.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | load test_helper 3 | 4 | @test "image build" { 5 | 6 | run build_image 7 | [ "$status" -eq 0 ] 8 | 9 | } 10 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/tool/slapd-restore-data: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Usage: /sbin/slapd-restore-data file [gunzipFile] 4 | file=$1 5 | 6 | /sbin/slapd-restore 1 $file 7 | 8 | exit 0 9 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/tool/slapd-restore-config: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Usage: /sbin/slapd-restore-config file [gunzipFile] 4 | file=$1 5 | 6 | /sbin/slapd-restore 0 $file 7 | 8 | exit 0 9 | -------------------------------------------------------------------------------- /image/environment/default.yaml: -------------------------------------------------------------------------------- 1 | # Backup config and data every day at 4:00am 2 | LDAP_BACKUP_CONFIG_CRON_EXP: 0 4 * * * 3 | LDAP_BACKUP_DATA_CRON_EXP: 0 4 * * * 4 | 5 | # Delete backups that are over 15 days 6 | LDAP_BACKUP_TTL: 15 7 | 8 | # Upload backups to S3 9 | UPLOAD_TO_S3: false 10 | S3_PATH: bucket/key-folder 11 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/cronjobs: -------------------------------------------------------------------------------- 1 | # Backup OpenLDAP config 2 | {{ LDAP_BACKUP_CONFIG_CRON_EXP }} root /sbin/slapd-backup-config 2>&1 | /usr/bin/logger -t cron_backup_config 3 | 4 | # Backup OpenLDAP data 5 | {{ LDAP_BACKUP_DATA_CRON_EXP }} root /sbin/slapd-backup-data 2>&1 | /usr/bin/logger -t cron_backup_data 6 | # empty line 7 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/tool/slapd-restore: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Usage: /sbin/slapd-restore dbnum file 4 | dbnum=$1 5 | file=$2 6 | 7 | backupPath="/data/backup" 8 | file="$backupPath/$file" 9 | 10 | TEMP_FILE=$(mktemp) 11 | gunzip -c $file > $TEMP_FILE 12 | chown openldap:openldap $TEMP_FILE 13 | 14 | # stop slapd 15 | sv stop /container/run/process/slapd 16 | 17 | /sbin/setuser openldap slapadd -c -F /etc/ldap/slapd.d -n $dbnum -l $TEMP_FILE 18 | 19 | # restart slapd 20 | sv start /container/run/process/slapd 21 | 22 | rm $TEMP_FILE 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME = osixia/openldap-backup 2 | VERSION = 1.5.0 3 | 4 | .PHONY: build build-nocache test tag-latest push push-latest release git-tag-version 5 | 6 | build: 7 | docker build -t $(NAME):$(VERSION) --rm image 8 | 9 | build-nocache: 10 | docker build -t $(NAME):$(VERSION) --no-cache --rm image 11 | 12 | test: 13 | env NAME=$(NAME) VERSION=$(VERSION) bats test/test.bats 14 | 15 | tag: 16 | docker tag $(NAME):$(VERSION) $(NAME):$(VERSION) 17 | 18 | tag-latest: 19 | docker tag $(NAME):$(VERSION) $(NAME):latest 20 | 21 | push: 22 | docker push $(NAME):$(VERSION) 23 | 24 | push-latest: 25 | docker push $(NAME):latest 26 | 27 | release: build test tag-latest push push-latest 28 | 29 | git-tag-version: release 30 | git tag -a v$(VERSION) -m "v$(VERSION)" 31 | git push origin v$(VERSION) 32 | -------------------------------------------------------------------------------- /image/service/slapd-backup/assets/tool/slapd-backup: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Usage: /sbin/slapd-backup dbnum filename 4 | dbnum=$1 5 | filename=$2 6 | 7 | backupPath="/data/backup" 8 | 9 | source /container/run/environment.sh 10 | 11 | # delete backups that are over $LDAP_BACKUP_TTL days 12 | find $backupPath -type f -mtime +$LDAP_BACKUP_TTL -exec rm {} \; 13 | 14 | # Date format for the dump file name 15 | dateFileFormat="+%Y%m%dT%H%M%S" 16 | backupFilePath="$backupPath/$(date "$dateFileFormat")-$filename.gz" 17 | 18 | /usr/sbin/slapcat -F /etc/ldap/slapd.d -n $dbnum | gzip > $backupFilePath 19 | chmod 600 $backupFilePath 20 | 21 | if [[ "$UPLOAD_TO_S3" == "true" ]]; then 22 | # Upload backup to S3. The backupFilePath is the config backup file path 23 | aws s3 cp $backupFilePath s3://${S3_PATH}/ 24 | echo "Upload successful" 25 | fi 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /image/service/slapd-backup/startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # set -x (bash debug) if log level is trace 4 | # https://github.com/osixia/docker-light-baseimage/blob/master/image/tool/log-helper 5 | log-helper level eq trace && set -x 6 | 7 | # add image tools to path 8 | ln -sf ${CONTAINER_SERVICE_DIR}/slapd-backup/assets/tool/* /sbin/ 9 | 10 | # add cron jobs 11 | ln -sf ${CONTAINER_SERVICE_DIR}/slapd-backup/assets/cronjobs /etc/cron.d/slapd-backup 12 | chmod 600 ${CONTAINER_SERVICE_DIR}/slapd-backup/assets/cronjobs 13 | 14 | FIRST_START_DONE="${CONTAINER_STATE_DIR}/docker-openldap-backup-first-start-done" 15 | # container first start 16 | if [ ! -e "$FIRST_START_DONE" ]; then 17 | 18 | # adapt cronjobs file 19 | sed -i "s|{{ LDAP_BACKUP_CONFIG_CRON_EXP }}|${LDAP_BACKUP_CONFIG_CRON_EXP}|g" ${CONTAINER_SERVICE_DIR}/slapd-backup/assets/cronjobs 20 | sed -i "s|{{ LDAP_BACKUP_DATA_CRON_EXP }}|${LDAP_BACKUP_DATA_CRON_EXP}|g" ${CONTAINER_SERVICE_DIR}/slapd-backup/assets/cronjobs 21 | 22 | touch $FIRST_START_DONE 23 | fi 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM osixia/openldap:1.5.0 2 | 3 | # Install cron from baseimage and remove .cfss and slapd services inherited from openldap image 4 | # remove also previous default environment files, they are not needed. 5 | # sources: https://github.com/osixia/docker-light-baseimage/blob/master/image/tool/add-service-available 6 | #  https://github.com/osixia/docker-light-baseimage/blob/master/image/service-available/:cron/download.sh 7 | RUN apt-get -y update \ 8 | && /container/tool/add-multiple-process-stack \ 9 | && apt-get install -y awscli \ 10 | && apt-get clean \ 11 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 12 | 13 | # Add service directory to /container/service 14 | ADD service /container/service 15 | 16 | # Use baseimage install-service script 17 | # https://github.com/osixia/docker-light-baseimage/blob/master/image/tool/install-service 18 | RUN /container/tool/install-service 19 | 20 | # Add default env variables 21 | ADD environment /container/environment/98-default 22 | 23 | # Set backup data in a data volume 24 | VOLUME ["/data/backup"] 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | IMAGE_NAME="$NAME:$VERSION" 3 | } 4 | 5 | # function relative to the current container / image 6 | build_image() { 7 | #disable outputs 8 | docker build -t $IMAGE_NAME $BATS_TEST_DIRNAME/../image &> /dev/null 9 | } 10 | 11 | run_image() { 12 | CONTAINER_ID=$(docker run $@ -d $IMAGE_NAME) 13 | CONTAINER_IP=$(get_container_ip_by_cid $CONTAINER_ID) 14 | } 15 | 16 | start_container() { 17 | start_containers_by_cid $CONTAINER_ID 18 | } 19 | 20 | stop_container() { 21 | stop_containers_by_cid $CONTAINER_ID 22 | } 23 | 24 | remove_container() { 25 | remove_containers_by_cid $CONTAINER_ID 26 | } 27 | 28 | clear_container() { 29 | stop_containers_by_cid $CONTAINER_ID 30 | remove_containers_by_cid $CONTAINER_ID 31 | } 32 | 33 | wait_process() { 34 | wait_process_by_cid $CONTAINER_ID $@ 35 | } 36 | 37 | # generic functions 38 | get_container_ip_by_cid() { 39 | local IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $1) 40 | echo "$IP" 41 | } 42 | 43 | start_containers_by_cid() { 44 | for cid in "$@" 45 | do 46 | #disable outputs 47 | docker start $cid &> /dev/null 48 | done 49 | } 50 | 51 | stop_containers_by_cid() { 52 | for cid in "$@" 53 | do 54 | #disable outputs 55 | docker stop $cid &> /dev/null 56 | done 57 | } 58 | 59 | remove_containers_by_cid() { 60 | for cid in "$@" 61 | do 62 | #disable outputs 63 | docker rm $cid &> /dev/null 64 | done 65 | } 66 | 67 | clear_containers_by_cid() { 68 | stop_containers_by_cid $@ 69 | remove_containers_by_cid $@ 70 | } 71 | 72 | wait_process_by_cid() { 73 | cid=$1 74 | docker exec $cid /container/tool/wait-process ${@:2} 75 | } 76 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | 3 | services: 4 | - docker 5 | env: 6 | global: 7 | - NAME="osixia/openldap-backup" 8 | - VERSION="${TRAVIS_BRANCH}-dev" 9 | matrix: 10 | - TARGET_ARCH=amd64 QEMU_ARCH=x86_64 11 | - TARGET_ARCH=arm32v7 QEMU_ARCH=arm 12 | - TARGET_ARCH=arm64v8 QEMU_ARCH=aarch64 13 | 14 | addons: 15 | apt: 16 | # The docker manifest command was added in docker-ee version 18.x 17 | # So update our current installation and we also have to enable the experimental features. 18 | sources: 19 | - sourceline: "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 20 | key_url: "https://download.docker.com/linux/ubuntu/gpg" 21 | packages: 22 | - docker-ce 23 | 24 | before_install: 25 | - docker --version 26 | - mkdir $HOME/.docker 27 | - 'echo "{" > $HOME/.docker/config.json' 28 | - 'echo " \"experimental\": \"enabled\"" >> $HOME/.docker/config.json' 29 | - 'echo "}" >> $HOME/.docker/config.json' 30 | - sudo service docker restart 31 | # To have `DOCKER_USER` and `DOCKER_PASS` 32 | # use `travis env set`. 33 | - echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin 34 | 35 | install: 36 | # For cross buidling our images 37 | # This is necessary because travis-ci.org has only x86_64 machines. 38 | # If travis-ci.org gets native arm builds, probably this step is not 39 | # necessary any more. 40 | - docker run --rm --privileged multiarch/qemu-user-static:register --reset 41 | # Bats is necessary for the UT 42 | - curl -o bats.tar.gz -SL https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz 43 | - mkdir bats-core && tar -xf bats.tar.gz -C bats-core --strip-components=1 44 | - cd bats-core/ 45 | - sudo ./install.sh /usr/local 46 | - cd .. 47 | 48 | before_script: 49 | # Set baseimage. 50 | - sed -i -e "s/FROM \(.*\)/FROM \1-${TARGET_ARCH}/g" image/Dockerfile; 51 | - cat image/Dockerfile; 52 | # If this is a tag then change the VERSION variable to only have the 53 | # tag name and not also the commit hash. 54 | - if [ -n "$TRAVIS_TAG" ]; then 55 | VERSION=$(echo "${TRAVIS_TAG}" | sed -e 's/\(.*\)[-v]\(.*\)/\1\2/g'); 56 | fi 57 | - if [ "${TRAVIS_BRANCH}" == 'master' ]; then 58 | VERSION="stable"; 59 | fi 60 | # replace / with - in version 61 | - VERSION=$(echo "${VERSION}" | sed 's|/|-|g'); 62 | 63 | script: 64 | - make build-nocache NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH} 65 | # Run the test and if the test fails mark the build as failed. 66 | - make test NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH} 67 | 68 | before_deploy: 69 | - docker run -d --name test_image ${NAME}:${VERSION}-${TARGET_ARCH} sleep 10 70 | - sleep 5 71 | - sudo docker ps | grep -q test_image 72 | - make tag NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH} 73 | 74 | deploy: 75 | provider: script 76 | on: 77 | all_branches: true 78 | script: make push NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH} 79 | 80 | jobs: 81 | include: 82 | - stage: Manifest creation 83 | install: skip 84 | script: skip 85 | after_deploy: 86 | - echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin 87 | - docker manifest create ${NAME}:${VERSION} ${NAME}:${VERSION}-amd64 ${NAME}:${VERSION}-arm32v7 ${NAME}:${VERSION}-arm64v8; 88 | docker manifest annotate ${NAME}:${VERSION} ${NAME}:${VERSION}-amd64 --os linux --arch amd64; 89 | docker manifest annotate ${NAME}:${VERSION} ${NAME}:${VERSION}-arm32v7 --os linux --arch arm --variant v7; 90 | docker manifest annotate ${NAME}:${VERSION} ${NAME}:${VERSION}-arm64v8 --os linux --arch arm64 --variant v8; 91 | 92 | # The latest tag is coming from the master branch of the repo 93 | - if [ "${TRAVIS_BRANCH}" == 'master' ]; then 94 | docker manifest create ${NAME}:latest ${NAME}:${VERSION}-amd64 ${NAME}:${VERSION}-arm32v7 ${NAME}:${VERSION}-arm64v8; 95 | docker manifest annotate ${NAME}:latest ${NAME}:${VERSION}-amd64 --os linux --arch amd64; 96 | docker manifest annotate ${NAME}:latest ${NAME}:${VERSION}-arm32v7 --os linux --arch arm --variant v7; 97 | docker manifest annotate ${NAME}:latest ${NAME}:${VERSION}-arm64v8 --os linux --arch arm64 --variant v8; 98 | fi 99 | 100 | - docker manifest push ${NAME}:${VERSION}; 101 | if [ "${TRAVIS_BRANCH}" == 'master' ]; then 102 | docker manifest push ${NAME}:latest; 103 | fi 104 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5 | and this project follows [osixia/openldap](https://github.com/osixia/docker-openldap-backup) versioning. 6 | 7 | ## [1.5.0] - 2021-02-19 8 | ### Changed 9 | - Upgrade baseimage to openldap:1.5.0 10 | 11 | ## [1.4.0] - 2020-06-15 12 | ### Changed 13 | - Upgrade baseimage to openldap:1.4.0 14 | - Cron scripts now use logger cmd 15 | 16 | ## [1.3.0] - 2019-09-29 17 | ## Added 18 | - Multiarch support 19 | 20 | ### Changed 21 | - Upgrade baseimage to openldap:1.3.0 22 | 23 | ## [1.2.5] - 2019-08-16 24 | ### Changed 25 | - Upgrade baseimage to openldap:1.2.5 26 | 27 | ## [1.2.4] - 2019-03-14 28 | ### Changed 29 | - Upgrade baseimage to openldap:1.2.4 30 | 31 | ## [1.2.3] - 2019-01-21 32 | ### Added 33 | - Option to upload backups to S3 #7 34 | 35 | ### Changed 36 | - Upgrade baseimage to openldap:1.2.3 37 | 38 | ## [1.2.2] - 2018-09-04 39 | ### Changed 40 | - Upgrade baseimage to openldap:1.2.2 41 | 42 | ## [1.2.1] - 2018-05-14 43 | ### Changed 44 | - Upgrade baseimage to openldap:1.2.1 45 | 46 | ## [1.2.0] - 2018-03-05 47 | ### Changed 48 | - Upgrade baseimage to openldap:1.2.0 49 | 50 | ## [1.1.11] - 2017-12-21 51 | ### Changed 52 | - Upgrade baseimage to openldap:1.1.11 53 | 54 | ## [1.1.10] - 2017-12-12 55 | ### Changed 56 | - Upgrade baseimage to openldap:1.1.10 57 | 58 | ## [1.1.9] - 2017-07-19 59 | ### Changed 60 | - Upgrade baseimage to openldap:1.1.9 61 | 62 | ## [1.1.8] - 2017-02-16 63 | ### Changed 64 | - Upgrade baseimage to openldap:1.1.8 65 | 66 | ## [1.1.7] - 2016-11-09 67 | ### Changed 68 | - Upgrade baseimage to openldap:1.1.7 69 | - chmod 600 on backups 70 | 71 | ## [1.1.6] - 2016-09-02 72 | ### Changed 73 | - Now a mutliple process image based on osixia/openldap with slapd 74 | - Restore tools updated 75 | 76 | ## Versions before following the osixia/openldap versioning 77 | 78 | ## [0.1.11] - 2016-09-02 79 | ### Changed 80 | - Upgrade baseimage to openldap:1.1.6 81 | 82 | ## [0.1.10] - 2016-08-02 83 | ### Changed 84 | - Upgrade baseimage to openldap:1.1.5 85 | 86 | ## [0.1.9] - 2016-07-26 87 | ### Changed 88 | - Upgrade baseimage to openldap:1.1.4 89 | 90 | ## [0.1.8] - 2016-02-20 91 | ### Changed 92 | - Upgrade baseimage to openldap:1.1.1 93 | 94 | ## [0.1.7] - 2016-01-25 95 | ### Added 96 | - Makefile with build no cache 97 | 98 | ### Changed 99 | - Upgrade baseimage to openldap:1.1.0 100 | 101 | ## [0.1.6] - 2015-11-20 102 | ### Changed 103 | - Upgrade baseimage to openldap:1.0.7 104 | 105 | ## [0.1.5] - 2015-11-20 106 | ### Changed 107 | - Upgrade baseimage to openldap:1.0.6 108 | 109 | ## [0.1.4] - 2015-11-19 110 | ### Changed 111 | - Upgrade baseimage to openldap:1.0.5 112 | 113 | ## [0.1.3] - 2015-11-06 114 | ### Changed 115 | - Upgrade baseimage to openldap:1.0.4 116 | 117 | ## [0.1.2] - 2015-10-26 118 | ### Changed 119 | - Upgrade baseimage to openldap:1.0.3 120 | 121 | ## [0.1.1] - 2015-08-18 122 | ### Changed 123 | - Upgrade baseimage to openldap:1.0.1 124 | - Rename environment variables 125 | 126 | ## 0.1.0 - 2015-07-24 127 | Initial release 128 | 129 | [1.5.0]: https://github.com/osixia/docker-openldap-backup/compare/v1.4.0...v1.5.0 130 | [1.4.0]: https://github.com/osixia/docker-openldap-backup/compare/v1.3.0...v1.4.0 131 | [1.3.0]: https://github.com/osixia/docker-openldap-backup/compare/v1.2.5...v1.3.0 132 | [1.2.5]: https://github.com/osixia/docker-openldap-backup/compare/v1.2.4...v1.2.5 133 | [1.2.4]: https://github.com/osixia/docker-openldap-backup/compare/v1.2.3...v1.2.4 134 | [1.2.3]: https://github.com/osixia/docker-openldap-backup/compare/v1.2.2...v1.2.3 135 | [1.2.2]: https://github.com/osixia/docker-openldap-backup/compare/v1.2.1...v1.2.2 136 | [1.2.1]: https://github.com/osixia/docker-openldap-backup/compare/v1.2.0...v1.2.1 137 | [1.2.0]: https://github.com/osixia/docker-openldap-backup/compare/v1.1.11...v1.2.0 138 | [1.1.11]: https://github.com/osixia/docker-openldap-backup/compare/v1.1.10...v1.1.11 139 | [1.1.10]: https://github.com/osixia/docker-openldap-backup/compare/v1.1.9...v1.1.10 140 | [1.1.9]: https://github.com/osixia/docker-openldap-backup/compare/v1.1.8...v1.1.9 141 | [1.1.8]: https://github.com/osixia/docker-openldap-backup/compare/v1.1.7...v1.1.8 142 | [1.1.7]: https://github.com/osixia/docker-openldap-backup/compare/v1.1.6...v1.1.7 143 | [1.1.6]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.11...v1.1.6 144 | [0.1.11]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.10...v0.1.11 145 | [0.1.10]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.9...v0.1.10 146 | [0.1.9]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.8...v0.1.9 147 | [0.1.8]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.7...v0.1.8 148 | [0.1.7]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.6...v0.1.7 149 | [0.1.6]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.5...v0.1.6 150 | [0.1.5]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.4...v0.1.5 151 | [0.1.4]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.3...v0.1.4 152 | [0.1.3]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.2...v0.1.3 153 | [0.1.2]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.1...v0.1.2 154 | [0.1.1]: https://github.com/osixia/docker-openldap-backup/compare/v0.1.0...v0.1.1 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # osixia/openldap-backup 2 | 3 | [![Docker Pulls](https://img.shields.io/docker/pulls/osixia/openldap-backup.svg)][hub] 4 | [![Docker Stars](https://img.shields.io/docker/stars/osixia/openldap-backup.svg)][hub] 5 | [![](https://images.microbadger.com/badges/image/osixia/openldap-backup.svg)](http://microbadger.com/images/osixia/openldap-backup "Get your own image badge on microbadger.com") 6 | 7 | [hub]: https://hub.docker.com/r/osixia/openldap-backup/ 8 | 9 | Latest release: 1.5.0 - [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/openldap-backup/)  10 | 11 | **A docker image to run OpenLDAP, and make periodic backups.** 12 | 13 | - [osixia/openldap-backup](#osixiaopenldap-backup) 14 | - [Contributing](#contributing) 15 | - [Quick start](#quick-start) 16 | - [Backup directory and data persistence](#backup-directory-and-data-persistence) 17 | - [Debug](#debug) 18 | - [Environment Variables](#environment-variables) 19 | - [Set your own environment variables](#set-your-own-environment-variables) 20 | - [Use command line argument](#use-command-line-argument) 21 | - [Link environment file](#link-environment-file) 22 | - [Make your own image or extend this image](#make-your-own-image-or-extend-this-image) 23 | - [Advanced User Guide](#advanced-user-guide) 24 | - [Extend osixia/openldap-backup:1.5.0 image](#extend-osixiaopenldap-backup150-image) 25 | - [Make your own openldap-backup image](#make-your-own-openldap-backup-image) 26 | - [Tests](#tests) 27 | - [Kubernetes](#kubernetes) 28 | - [Under the hood: osixia/openldap](#under-the-hood-osixiaopenldap) 29 | - [Security](#security) 30 | - [Changelog](#changelog) 31 | 32 | ## Contributing 33 | 34 | If you find this image useful here's how you can help: 35 | 36 | - Send a pull request with your kickass new features and bug fixes 37 | - Help new users with [issues](https://github.com/osixia/docker-openldap-backup/issues) they may encounter 38 | - Support the development of this image and star this repo ! 39 | 40 | ## Quick start 41 | 42 | This image is based on osixia/openldap please refer to: 43 | [https://github.com/osixia/docker-openldap](https://github.com/osixia/docker-openldap)  44 | 45 | Here just the backup extension will be described. 46 | 47 | ### Backup directory and data persistence 48 | 49 | Backups are created in the directory `/data/backup` that should be mapped has volume so your ldap files are saved outside the container. 50 | 51 | docker run --env LDAP_BACKUP_CONFIG_CRON_EXP="0 5 * * *" \ 52 | --volume /data/openldap/backup:/data/backup \ 53 | --detach osixia/openldap-backup:1.5.0 54 | 55 | 56 | For more information about docker data volume, please refer to : 57 | 58 | > [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/) 59 | 60 | ### Debug 61 | 62 | The container default log level is **info**. 63 | Available levels are: `none`, `error`, `warning`, `info`, `debug` and `trace`. 64 | 65 | Example command to run the container in `debug` mode: 66 | 67 | docker run --detach osixia/openldap-backup:1.5.0 --loglevel debug 68 | 69 | See all command line options: 70 | 71 | docker run osixia/openldap-backup:1.5.0 --help 72 | 73 | 74 | ## Environment Variables 75 | 76 | Environment variables defaults are set in **image/environment/default.yaml**. 77 | 78 | See how to [set your own environment variables](#set-your-own-environment-variables) 79 | 80 | - **LDAP_BACKUP_CONFIG_CRON_EXP**: Cron expression to schedule OpenLDAP config backup. Defaults to `0 4 * * *`. Every days at 4am. 81 | 82 | - **LDAP_BACKUP_DATA_CRON_EXP**: Cron expression to schedule OpenLDAP data backup. Defaults to `0 4 * * *`. Every days at 4am. 83 | 84 | - **LDAP_BACKUP_TTL**: Backup TTL in days. Defaults to `15`. 85 | 86 | 87 | ### Set your own environment variables 88 | 89 | #### Use command line argument 90 | Environment variables can be set by adding the --env argument in the command line, for example: 91 | 92 | docker run --env LDAP_BACKUP_CONFIG_CRON_EXP="0 5 * * *" \ 93 | --detach osixia/openldap-backup:1.5.0 94 | 95 | 96 | #### Link environment file 97 | 98 | For example if your environment file is in : /data/ldap/environment/my-env.yaml 99 | 100 | docker run --volume /data/ldap/environment/my-env.yaml:/container/environment/01-custom/env.yaml \ 101 | --detach osixia/openldap-backup:1.5.0 102 | 103 | Take care to link your environment file to `/container/environment/XX-somedir` (with XX < 99 so they will be processed before default environment files) and not directly to `/container/environment` because this directory contains predefined baseimage environment files to fix container environment (INITRD, LANG, LANGUAGE and LC_CTYPE). 104 | 105 | #### Make your own image or extend this image 106 | 107 | This is the best solution if you have a private registry. Please refer to the [Advanced User Guide](#advanced-user-guide) just below. 108 | 109 | ## Advanced User Guide 110 | 111 | ### Extend osixia/openldap-backup:1.5.0 image 112 | 113 | If you need to add your custom environment files you can extends this image. 114 | 115 | Dockerfile example: 116 | 117 | FROM osixia/openldap-backup:1.5.0 118 | MAINTAINER Your Name 119 | 120 | ADD environment /container/environment/01-custom 121 | 122 | 123 | ### Make your own openldap-backup image 124 | 125 | Clone this project: 126 | 127 | git clone https://github.com/osixia/docker-openldap-backup 128 | cd docker-openldap-backup 129 | 130 | Adapt Makefile, set your image NAME and VERSION, for example: 131 | 132 | NAME = osixia/openldap-backup 133 | VERSION = 1.1.9 134 | 135 | become: 136 | NAME = cool-guy/openldap-backup 137 | VERSION = 0.1.0 138 | 139 | Add environment files... 140 | 141 | Build your image: 142 | 143 | make build 144 | 145 | Run your image: 146 | 147 | docker run --detach cool-guy/openldap-backup:0.1.0 148 | 149 | ### Tests 150 | 151 | We use **Bats** (Bash Automated Testing System) to test this image: 152 | 153 | > [https://github.com/sstephenson/bats](https://github.com/sstephenson/bats) 154 | 155 | Install Bats, and in this project directory run: 156 | 157 | make test 158 | 159 | ### Kubernetes 160 | 161 | Kubernetes is an open source system for managing containerized applications across multiple hosts, providing basic mechanisms for deployment, maintenance, and scaling of applications. 162 | 163 | More information: 164 | - http://kubernetes.io 165 | - https://github.com/kubernetes/kubernetes 166 | 167 | osixia-openldap-backup kubernetes examples are available in [osixia/docker-openldap](https://github.com/osixia/docker-openldap/tree/stable/example/kubernetes/simple). 168 | 169 | ### Under the hood: osixia/openldap 170 | 171 | This image is based on osixia/openldap. 172 | More info: https://github.com/osixia/docker-openldap 173 | 174 | ## Security 175 | If you discover a security vulnerability within this docker image, please send an email to the Osixia! team at security@osixia.net. For minor vulnerabilities feel free to add an issue here on github. 176 | 177 | Please include as many details as possible. 178 | 179 | ## Changelog 180 | 181 | Please refer to: [CHANGELOG.md](CHANGELOG.md) 182 | --------------------------------------------------------------------------------