From 4d7df3a39e05e965a386a34cbb2620f478002be5 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 29 Mar 2021 22:55:10 +0200 Subject: [PATCH] added init script --- .gitignore | 3 ++- Dockerfile | 1 + docker-compose.yml | 3 ++- init.sh | 13 +++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 init.sh diff --git a/.gitignore b/.gitignore index 17d4aa6..218cbb3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ !docker-compose.yml !entrypoint.sh !README.md -!.drone.yml \ No newline at end of file +!.drone.yml +!init.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 131601c..5a2c1fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ RUN apk add --no-cache mysql-client restic rclone RUN mkdir /app && mkdir /config COPY entrypoint.sh /app/entrypoint.sh +COPY init.sh /app/init.sh WORKDIR /config diff --git a/docker-compose.yml b/docker-compose.yml index 5174348..aeb94ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,9 @@ version: "3" services: backup: build: . + # entrypoint: /app/init.sh environment: - - RCLONE_REMOTE=gdrive:/backup + - RCLONE_REMOTE=gdrive:/backupTest - RCLONE_CONFIG=/config/rclone.conf - RESTIC_PASSWORD=repopw volumes: diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..0b0f2c8 --- /dev/null +++ b/init.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +[ -z "${RCLONE_REMOTE}" ] && echo "\$RCLONE_REMOTE is not set" && exit 1 +[ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1 +[ -z "${RESTIC_PASSWORD}" ] && echo "\$RESTIC_PASSWORD is not set" && exit 1 + +echo "Init new repo" + +restic -r "rclone:$RCLONE_REMOTE" init + +echo "Created new repo at $RCLONE_REMOTE"