From ab6141d578a8e196af1f24453c50ad0664fc9d5c Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <frank@sauerburger.com> Date: Mon, 8 Mar 2021 15:47:08 +0100 Subject: [PATCH] Factor out backup repo init step --- backup/Dockerfile | 1 + backup/entrypoint.sh | 9 +++++++-- backup/init_repo.sh | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100755 backup/init_repo.sh diff --git a/backup/Dockerfile b/backup/Dockerfile index 4adec44..481aeaa 100644 --- a/backup/Dockerfile +++ b/backup/Dockerfile @@ -5,5 +5,6 @@ RUN yum install -y cronie epel-release openssh-clients postgresql12 RUN yum install -y borgbackup ADD entrypoint.sh /usr/local/bin/entrypoint.sh ADD do_backup.sh /usr/local/bin/do_backup.sh +ADD init_repo.sh /usr/local/bin/init_repo.sh ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["tail", "-f", "/var/log/borg"] diff --git a/backup/entrypoint.sh b/backup/entrypoint.sh index a238ba5..38d1a71 100755 --- a/backup/entrypoint.sh +++ b/backup/entrypoint.sh @@ -19,8 +19,13 @@ echo "${SSH_ID}" | sed -e 's/\\n/\n/g' > /etc/borg/id_rsa chmod 400 /etc/borg/id_rsa if ! borg info &> /dev/null; then - echo "Repository not ready. Initializing repo." - borg init -e repokey + echo "Repository not ready. Please run:" + echo " docker-compose exec backup /usr/local/bin/init_repo.sh" + + while ! borg info &> /dev/null; do + sleep 10; + done + echo " ... ready" fi diff --git a/backup/init_repo.sh b/backup/init_repo.sh new file mode 100755 index 0000000..ff2d540 --- /dev/null +++ b/backup/init_repo.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +borg init -e repokey + -- GitLab