From 8d2fd9d9b7cddec968b6cb4d6f155d034dc76dcb Mon Sep 17 00:00:00 2001 From: bmen Date: Sun, 20 Sep 2020 11:23:27 +0200 Subject: [PATCH] Initial commit --- backup.sh | 17 +++++++++++++ docker-compose.yml | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 backup.sh create mode 100644 docker-compose.yml diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..0f6eb23 --- /dev/null +++ b/backup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +#Löscht alle "*.tar.gz" und "*.sql" Dateien die älter als 14 Tage sind: +find -P "/mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/CodiMD/" -maxdepth 1 -type f \( -name '*.tar.gz' \) -ctime +14 -exec rm {} \; +find -P "/mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/CodiMD/" -maxdepth 1 -type f \( -name '*.sql' \) -ctime +14 -exec rm {} \; + +#Zur Sicherheit noch einen SQL-Dump der Datenbank +docker exec -i codimd-db pg_dump codimd -U codimd > /mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/CodiMD/codimd-`date '+%Y%m%d%H%M'`.sql + +#Die Docker Container stoppen und die Datenverzeichnisse komprimieren und wegkopieren +cd /root/deployments/codimd/ +docker-compose down +cd /opt/appdata/ +tar cvf /mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/CodiMD/codimd-`date '+%Y%m%d%H%M'`.tar.gz codimd/ + +#Nextcloud Datenbank über die Dateiänderung Bescheid geben +docker exec --user www-data nextcloud php occ files:scan -p bmen/files/Server/Hetzner-Cloud-CX21/CodiMD/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d2ea8f6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,63 @@ +version: '3' + +networks: + webproxy: + external: true + + backend-codimd: + external: true + +services: + database: + # Don't upgrade PostgreSQL by simply changing the version number + # You need to migrate the Database to the new PostgreSQL version + image: postgres:9.6-alpine + container_name: codimd-db + #mem_limit: 256mb # version 2 only + #memswap_limit: 512mb # version 2 only + #read_only: true # not supported in swarm mode please enable along with tmpfs + #tmpfs: + # - /run/postgresql:size=512K + # - /tmp:size=256K + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + volumes: + - /opt/appdata/codimd/db:/var/lib/postgresql/data + networks: + - backend-codimd + restart: always + + app: + image: quay.io/codimd/server:1.6.0 + container_name: codimd-app + #mem_limit: 256mb # version 2 only + #memswap_limit: 512mb # version 2 only + #read_only: true # not supported in swarm mode, enable along with tmpfs + #tmpfs: + # - /tmp:size=512K + # - /codimd/tmp:size=1M + # # Make sure you remove this when you use filesystem as upload type + # - /codimd/public/uploads:size=10M + environment: + # DB_URL is formatted like: ://:@:/ + # Other examples are: + # - mysql://hackmd:hackmdpass@database:3306/hackmd + # - sqlite:///data/sqlite.db (NOT RECOMMENDED) + # - For details see the official sequelize docs: http://docs.sequelizejs.com/en/v3/ + - CMD_DB_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_DB}:5432/hackmd + ports: + # Ports that are published to the outside. + # The latter port is the port inside the container. It should always stay on 3000 + # If you only specify a port it'll published on all interfaces. If you want to use a + # local reverse proxy, you may want to listen on 127.0.0.1. + # Example: + # - "127.0.0.1:3000:3000" + # - "3000:3000" + networks: + - webproxy + - backend-codimd + restart: always + depends_on: + - database \ No newline at end of file