Compare commits

..

5 Commits
main ... main-2

Author SHA1 Message Date
f
20c3e6d5d3 chore: publish 1.1.0+0.258.11 release
All checks were successful
continuous-integration/drone/tag Build is passing
2025-01-02 17:00:10 -03:00
f
b471841243 Merge branch 'backups' 2025-01-02 16:57:41 -03:00
f
955c3b2497 fix: abra.sh 2025-01-02 16:57:28 -03:00
f
79266d8929 fix: upgrade to 0.258.11 2025-01-02 16:51:53 -03:00
f
c52e9c6744 feat: enable backup-bot-two 2025-01-02 16:48:09 -03:00
6 changed files with 55 additions and 4 deletions

View File

@ -34,7 +34,7 @@ steps:
from_secret: drone_abra-bot_token from_secret: drone_abra-bot_token
fork: true fork: true
repositories: repositories:
- toolshed/auto-recipes-catalogue-json - coop-cloud/auto-recipes-catalogue-json
trigger: trigger:
event: tag event: tag

View File

@ -9,3 +9,4 @@ LETS_ENCRYPT_ENV=production
SECRET_DB_PASSWORD_VERSION=v1 SECRET_DB_PASSWORD_VERSION=v1
SECRET_NC_DB_URL_VERSION=v1 SECRET_NC_DB_URL_VERSION=v1
ENABLE_BACKUPS=true

View File

@ -8,7 +8,7 @@
* **Status**: 0 * **Status**: 0
* **Image**: [`nocodb`](https://hub.docker.com/r/nocodb), 4, upstream * **Image**: [`nocodb`](https://hub.docker.com/r/nocodb), 4, upstream
* **Healthcheck**: No * **Healthcheck**: No
* **Backups**: No * **Backups**: Yes
* **Email**: No * **Email**: No
* **Tests**: No * **Tests**: No
* **SSO**: No * **SSO**: No

1
abra.sh Normal file
View File

@ -0,0 +1 @@
export PG_BACKUP_VERSION=v1

View File

@ -3,7 +3,7 @@ version: "3.8"
services: services:
app: app:
image: nocodb/nocodb:0.263.6 image: nocodb/nocodb:0.258.11
secrets: secrets:
- nc_db_url - nc_db_url
networks: networks:
@ -28,7 +28,8 @@ services:
#- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" #- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true" #- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" #- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
- "coop-cloud.${STACK_NAME}.version=1.1.5+0.263.6" - "coop-cloud.${STACK_NAME}.version=1.1.0+0.258.11"
- "backupbot.backup=${ENABLE_BACKUPS:-true}"
db: db:
image: postgres:13.2-alpine image: postgres:13.2-alpine
@ -47,6 +48,16 @@ services:
interval: 10s interval: 10s
timeout: 2s timeout: 2s
retries: 10 retries: 10
deploy:
labels:
backupbot.backup: "${ENABLE_BACKUPS:-true}"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.postgres.path: "backup.sql"
backupbot.restore.post-hook: '/pg_backup.sh restore'
configs:
- source: pg_backup
target: /pg_backup.sh
mode: 0555
volumes: volumes:
data: data:
@ -65,3 +76,7 @@ secrets:
nc_db_url: nc_db_url:
external: true external: true
name: ${STACK_NAME}_nc_db_url_${SECRET_NC_DB_URL_VERSION} name: ${STACK_NAME}_nc_db_url_${SECRET_NC_DB_URL_VERSION}
configs:
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: pg_backup.sh

34
pg_backup.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
set -e
BACKUP_FILE='/var/lib/postgresql/data/backup.sql'
function backup {
export PGPASSWORD=$(cat /run/secrets/db_password)
pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} > $BACKUP_FILE
}
function restore {
cd /var/lib/postgresql/data/
restore_config(){
# Restore allowed connections
cat pg_hba.conf.bak > pg_hba.conf
su postgres -c 'pg_ctl reload'
}
# Don't allow any other connections than local
cp pg_hba.conf pg_hba.conf.bak
echo "local all all trust" > pg_hba.conf
su postgres -c 'pg_ctl reload'
trap restore_config EXIT INT TERM
# Recreate Database
psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);"
createdb -U ${POSTGRES_USER} ${POSTGRES_DB}
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE
trap - EXIT INT TERM
restore_config
}
$@