From d9e7368059c90f97af7f50af1772a1ff4741769f Mon Sep 17 00:00:00 2001 From: Pablo Costa Date: Tue, 20 Aug 2024 19:41:32 -0300 Subject: [PATCH] Remove Docker completely and unnecessary env variables --- .github/workflows/db-backup-private.yml | 3 --- .github/workflows/db-backup-public-wip.yml | 5 ++--- .github/workflows/db-backup-public.yml | 1 - db-backup/Dockerfile | 25 ---------------------- db-backup/README.md | 11 ---------- db-backup/bin/backup.sh | 4 +++- db-backup/bin/command_exec.sh | 10 --------- db-backup/bin/entrypoint.sh | 19 ---------------- db-backup/bin/prune.sh | 2 +- 9 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 db-backup/Dockerfile delete mode 100755 db-backup/bin/command_exec.sh delete mode 100755 db-backup/bin/entrypoint.sh diff --git a/.github/workflows/db-backup-private.yml b/.github/workflows/db-backup-private.yml index 6c47d05389..ed7c0f297d 100644 --- a/.github/workflows/db-backup-private.yml +++ b/.github/workflows/db-backup-private.yml @@ -45,10 +45,7 @@ jobs: -e CLOUDFLARE_R2_WRITE_ACCESS_KEY_ID="${{ secrets.CLOUDFLARE_R2_WRITE_ACCESS_KEY_ID }}" \ -e CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY="${{ secrets.CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY }}" \ -e CLOUDFLARE_R2_BUCKET_NAME="${{ vars.CLOUDFLARE_R2_BUCKET_NAME }}" \ - -e BACKUPFILE_PREFIX="backup" \ -e MONGODB_URI="${{ secrets.MONGODB_CONNECTION_STRING }}" \ - -e MONGODB_DBNAME="aiidprod" \ - -e MONGODB_DBNAME_TRANSLATIONS="translations" \ -v ~:/mab \ aiid-docker-backup:latest diff --git a/.github/workflows/db-backup-public-wip.yml b/.github/workflows/db-backup-public-wip.yml index 4439e3e656..d2eb4f0721 100644 --- a/.github/workflows/db-backup-public-wip.yml +++ b/.github/workflows/db-backup-public-wip.yml @@ -47,6 +47,8 @@ jobs: - name: Generate public backup run: | ./bin/backup.sh + ./bin/prune.sh + ./bin/list.sh working-directory: db-backup env: IS_PUBLIC_BACKUP: true @@ -54,7 +56,4 @@ jobs: CLOUDFLARE_R2_WRITE_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_WRITE_ACCESS_KEY_ID }} CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY }} CLOUDFLARE_R2_BUCKET_NAME: ${{ vars.CLOUDFLARE_R2_BUCKET_NAME }} - BACKUPFILE_PREFIX: backup MONGODB_URI: ${{ secrets.MONGODB_CONNECTION_STRING }} - MONGODB_DBNAME: aiidprod - MONGODB_DBNAME_TRANSLATIONS: translations diff --git a/.github/workflows/db-backup-public.yml b/.github/workflows/db-backup-public.yml index a80fd0b5f4..ebd241f7f3 100644 --- a/.github/workflows/db-backup-public.yml +++ b/.github/workflows/db-backup-public.yml @@ -45,7 +45,6 @@ jobs: -e CLOUDFLARE_R2_WRITE_ACCESS_KEY_ID="${{ secrets.CLOUDFLARE_R2_WRITE_ACCESS_KEY_ID }}" \ -e CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY="${{ secrets.CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY }}" \ -e CLOUDFLARE_R2_BUCKET_NAME="${{ vars.CLOUDFLARE_R2_BUCKET_NAME }}" \ - -e BACKUPFILE_PREFIX="backup" \ -e MONGODB_URI="${{ secrets.MONGODB_CONNECTION_STRING }}" \ -e MONGODB_DBNAME="aiidprod" \ -e MONGODB_DBNAME_TRANSLATIONS="translations" \ diff --git a/db-backup/Dockerfile b/db-backup/Dockerfile deleted file mode 100644 index 5c34f7d800..0000000000 --- a/db-backup/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM node:17-alpine - -LABEL maintainer="Sean McGregor " - -RUN apk add --no-cache \ - coreutils \ - bash \ - tzdata \ - py3-pip \ - mongodb-tools \ - curl \ - npm - -# install awscli -RUN pip install awscli - -# install boto3 -RUN pip install boto3 - -ENV AWS_DEFAULT_REGION=ap-northeast-1 - -COPY docker-db-backup/bin /docker-db-backup/opt/bin -WORKDIR /docker-db-backup/opt/bin -ENTRYPOINT ["/docker-db-backup/opt/bin/entrypoint.sh"] -CMD ["backup", "prune", "list"] diff --git a/db-backup/README.md b/db-backup/README.md index 87af7e4f88..2d4fa01324 100644 --- a/db-backup/README.md +++ b/db-backup/README.md @@ -2,13 +2,6 @@ This is a quick port of the forked project to support JSON and CSV backups of th The complete state of the database will be backed up on a weekly basis in both JSON and CSV form. The backups can be downloaded from [here](https://incidentdatabase.ai/research/snapshots/). -What is mongodb-awesome-backup? -------------------------------- - -mongodb-awesome-backup is the collection of scripts which backup MongoDB databases to Amazon S3. -You can set a custom S3 endpoint to use S3 based services like DigitalOcean Spaces instead of Amazon S3. - - Requirements ------------ @@ -25,9 +18,7 @@ docker run --rm \ -e CLOUDFLARE_R2_WRITE_SECRET_ACCESS_KEY= \ -e CLOUDFLARE_R2_PUBLIC_BUCKET= \ -e CLOUDFLARE_R2_BUCKET_NAME= \ - [ -e BACKUPFILE_PREFIX= \ ] - [ -e MONGODB_DBNAME= \ ] [ -v ~:/mab \ ] weseek/mongodb-awesome-backup ``` @@ -54,8 +45,6 @@ Environment variables | Variable | Description | Default | | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| BACKUPFILE_PREFIX | Prefix of Backup Filename | "backup" | | MONGODB_URI | Target MongoDB URI (ex. `mongodb://mongodb?replicaSet=rs0`). If set, the other `MONGODB_*` variables will be ignored. | - | -| MONGODB_DBNAME | Target DB name | - | | CRONMODE | If set "true", this container is executed in cron mode. In cron mode, the script will be executed with the specified arguments and at the time specified by CRON_EXPRESSION. | "false" | | CRON_EXPRESSION | Cron expression (ex. "CRON_EXPRESSION=0 4 * * *" if you want to run at 4:00 every day) | - | diff --git a/db-backup/bin/backup.sh b/db-backup/bin/backup.sh index a6c454a28b..0e8a318adb 100755 --- a/db-backup/bin/backup.sh +++ b/db-backup/bin/backup.sh @@ -4,9 +4,11 @@ echo "Starting backup.sh script execution..." # settings IS_PUBLIC_BACKUP=${IS_PUBLIC_BACKUP:-false} -BACKUPFILE_PREFIX=${BACKUPFILE_PREFIX:-backup} +BACKUPFILE_PREFIX="backup" CRONMODE=${CRONMODE:-false} CLOUDFLARE_R2_ACCOUNT_ID=${CLOUDFLARE_R2_ACCOUNT_ID} +MONGODB_DBNAME="aiidprod" +MONGODB_DBNAME_TRANSLATIONS="translations" # start script CWD=`/usr/bin/dirname $0` diff --git a/db-backup/bin/command_exec.sh b/db-backup/bin/command_exec.sh deleted file mode 100755 index 0f991b00c2..0000000000 --- a/db-backup/bin/command_exec.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -e - -# start script -CWD=`/usr/bin/dirname $0` -cd $CWD - -for arg in $@; do - ./${arg}.sh -done - diff --git a/db-backup/bin/entrypoint.sh b/db-backup/bin/entrypoint.sh deleted file mode 100755 index f412ad363c..0000000000 --- a/db-backup/bin/entrypoint.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -e - -./boto.sh - -# start script -CRONMODE=${CRONMODE:-false} -if $CRONMODE ; then - if [ -z "${CRON_EXPRESSION}" ]; then - echo 'ERROR: The environment variable CRON_EXPRESSION must be specified in cron mode.' - exit 255; - fi - echo "${CRON_EXPRESSION} /opt/bin/command_exec.sh $@" > /var/spool/cron/crontabs/root - echo "=== started in cron mode `/bin/date "+%Y/%m/%d %H:%M:%S"` ===" - crontab -l - exec crond -f -d 8 -else - exec ./command_exec.sh $@ -fi - diff --git a/db-backup/bin/prune.sh b/db-backup/bin/prune.sh index f0cd2f961d..c03ab4ad1a 100755 --- a/db-backup/bin/prune.sh +++ b/db-backup/bin/prune.sh @@ -3,7 +3,7 @@ echo "Starting prune.sh execution..." # settings -BACKUPFILE_PREFIX=${BACKUPFILE_PREFIX:-backup} +BACKUPFILE_PREFIX="backup" DELETE_DEVIDE=${DELETE_DEVIDE:-3} DELETE_TARGET_DAYS_LEFT=${DELETE_TARGET_DAYS_LEFT:-4}