From 434bd5f277177f87b8e19f99d711963c09de87d0 Mon Sep 17 00:00:00 2001 From: bmen Date: Tue, 1 Oct 2019 22:05:49 +0200 Subject: [PATCH] Initial commit --- backup.sh | 22 ++++++++++++++++++++++ docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 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..eac695e --- /dev/null +++ b/backup.sh @@ -0,0 +1,22 @@ +#!/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/Gitea/" -maxdepth 1 -type f \( -name '*.tar.gz' \) -ctime +14 -exec rm {} \; +find -P "/mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/Gitea/" -maxdepth 1 -type f \( -name '*.sql' \) -ctime +14 -exec rm {} \; + +#Zur Sicherheit noch einen SQL-Dump der Datenbank +docker exec -i bmen-gitea-db -ugitea -pgitea gitea > /mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/Gitea/gitea-`date '+%Y%m%d%H%M'`.sql + +#Die Docker Container stoppen und die Datenverzeichnisse komprimieren und wegkopieren +cd /root/deployments/gitea/ +docker-compose stop +cd /opt/appdata/ +tar cvf /mnt/storage-bx20/data-nextcloud/bmen/files/Server/Hetzner-Cloud-CX21/Gitea/gitea-`date '+%Y%m%d%H%M'`.tar.gz nextcloud/ + +#Docker Container aktualisieren und starten +cd /root/deployments/gitea/ +docker-compose pull +docker-compose start + +#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/Gitea/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5c77d36 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: "2" + +services: + server: + image: gitea/gitea:latest + environment: + - USER_UID=1000 + - USER_GID=1000 + - DB_TYPE=mysql + - DB_HOST=db:3306 + - DB_NAME=gitea + - DB_USER=gitea + - DB_PASSWD=gitea + restart: always + volumes: + - /opt/appdata/gitea/data:/data + ports: + - "3000:3000" + - "222:22" + container_name: bmen-gitea + depends_on: + - db + + db: + image: mysql:5.7 + restart: always + environment: + - MYSQL_ROOT_PASSWORD=gitea + - MYSQL_USER=gitea + - MYSQL_PASSWORD=gitea + - MYSQL_DATABASE=gitea + container_name: bmen-gitea-db + volumes: + - /opt/appdata/gitea/mysql:/var/lib/mysql