From 2eaaf1f9365581f8b8acbf18e75d8d65292d4d66 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Sun, 5 May 2024 22:38:14 +0200 Subject: [PATCH] Split volumes and add backup (WIP) Signed-off-by: Bensuperpc --- Makefile | 13 ++++++----- docker-compose.backup.yml | 25 +++++++++++++++++++++ docker-compose.caddy.yml | 5 +++++ docker-compose.gitea.yml | 8 +++++++ docker-compose.jellyfin.yml | 8 +++++++ docker-compose.qbittorrent.yml | 6 +++++ docker-compose.volumes.yml | 24 -------------------- docker-compose.wordpress.yml | 40 +++++++++++++++++++--------------- env/backup.env | 4 ++++ 9 files changed, 87 insertions(+), 46 deletions(-) create mode 100644 docker-compose.backup.yml create mode 100644 env/backup.env diff --git a/Makefile b/Makefile index 25fd60d..33e7338 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ DOCKER := docker -PROFILES := webserver wordpress adminer uptime-kuma portainer qbittorrent gitea jellyfin watchtower +PROFILES := webserver wordpress adminer uptime-kuma portainer qbittorrent gitea jellyfin watchtower backup PROFILE_CMD := $(addprefix --profile ,$(PROFILES)) COMPOSE_FILES := $(shell find docker-compose*.yml | sed -e 's/^/--file /') @@ -56,11 +56,14 @@ state: docker compose $(COMPOSE_FILES) ps docker compose $(COMPOSE_FILES) top -.PHONY: update -update: +.PHONY: update-docker +update-docker: docker compose $(COMPOSE_FILES) $(PROFILE_CMD) pull - git submodule update --init --recursive --remote - git pull --recurse-submodules --all --progress + +.PHONY: update +update: update-docker +# git submodule update --init --recursive --remote +# git pull --recurse-submodules --all --progress .PHONY: clean clean: diff --git a/docker-compose.backup.yml b/docker-compose.backup.yml new file mode 100644 index 0000000..064491c --- /dev/null +++ b/docker-compose.backup.yml @@ -0,0 +1,25 @@ +version: '3.9' + +services: + # Backup + backup: + image: offen/docker-volume-backup:latest + container_name: backup + profiles: + - backup + restart: on-failure + env_file: + - env/backup.env + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - caddy_data:/backup/caddy_data:ro + - caddy_config:/backup/caddy_config:ro + - backup:/archive + networks: + - infra-network + security_opt: + - no-new-privileges:true + +volumes: + backup: + name: backup \ No newline at end of file diff --git a/docker-compose.caddy.yml b/docker-compose.caddy.yml index 5510505..27f281d 100644 --- a/docker-compose.caddy.yml +++ b/docker-compose.caddy.yml @@ -30,3 +30,8 @@ services: # - SETUID # - NET_BIND_SERVICE +volumes: + caddy_data: + name: caddy_data + caddy_config: + name: caddy_config diff --git a/docker-compose.gitea.yml b/docker-compose.gitea.yml index 39c4406..a59a28f 100644 --- a/docker-compose.gitea.yml +++ b/docker-compose.gitea.yml @@ -41,3 +41,11 @@ services: - infra-network security_opt: - no-new-privileges:true + +volumes: + gitea_data: + name: gitea_data + gitea_config: + name: gitea_config + gitea_db: + name: gitea_db diff --git a/docker-compose.jellyfin.yml b/docker-compose.jellyfin.yml index ccae034..dbe6e97 100644 --- a/docker-compose.jellyfin.yml +++ b/docker-compose.jellyfin.yml @@ -18,3 +18,11 @@ services: - infra-network security_opt: - no-new-privileges:true + +volumes: + jellyfin_config: + name: jellyfin_config + jellyfin_data: + name: jellyfin_data + jellyfin_cache: + name: jellyfin_cache \ No newline at end of file diff --git a/docker-compose.qbittorrent.yml b/docker-compose.qbittorrent.yml index f5c6c49..52c9d97 100644 --- a/docker-compose.qbittorrent.yml +++ b/docker-compose.qbittorrent.yml @@ -19,3 +19,9 @@ services: - infra-network security_opt: - no-new-privileges:true + +volumes: + qbittorrent_config: + name: qbittorrent_config + qbittorrent_data: + name: qbittorrent_data \ No newline at end of file diff --git a/docker-compose.volumes.yml b/docker-compose.volumes.yml index c214453..148375a 100644 --- a/docker-compose.volumes.yml +++ b/docker-compose.volumes.yml @@ -1,29 +1,5 @@ version: '3.9' volumes: - database: - name: database - wordpress: - name: wordpress - caddy_data: - name: caddy_data - caddy_config: - name: caddy_config - qbittorrent_config: - name: qbittorrent_config - qbittorrent_data: - name: qbittorrent_data uptimekuma_data: name: uptimekuma_data - gitea_data: - name: gitea_data - gitea_config: - name: gitea_config - gitea_db: - name: gitea_db - jellyfin_config: - name: jellyfin_config - jellyfin_data: - name: jellyfin_data - jellyfin_cache: - name: jellyfin_cache diff --git a/docker-compose.wordpress.yml b/docker-compose.wordpress.yml index da5c826..18f2051 100644 --- a/docker-compose.wordpress.yml +++ b/docker-compose.wordpress.yml @@ -21,23 +21,6 @@ services: security_opt: - no-new-privileges:true - # Adminer - adminer: - image: adminer:latest - container_name: adminer - profiles: - - adminer - restart: on-failure - env_file: - - env/adminer.env - depends_on: - - wordpress_db - - caddy - networks: - - infra-network - security_opt: - - no-new-privileges:true - # Database wordpress wordpress_db: image: mariadb:latest @@ -57,3 +40,26 @@ services: - infra-network security_opt: - no-new-privileges:true + + # Adminer + adminer: + image: adminer:latest + container_name: adminer + profiles: + - adminer + restart: on-failure + env_file: + - env/adminer.env + depends_on: + - wordpress_db + - caddy + networks: + - infra-network + security_opt: + - no-new-privileges:true + +volumes: + database: + name: database + wordpress: + name: wordpress \ No newline at end of file diff --git a/env/backup.env b/env/backup.env new file mode 100644 index 0000000..985ec6d --- /dev/null +++ b/env/backup.env @@ -0,0 +1,4 @@ +BACKUP_COMPRESSION="zst" +BACKUP_CRON_EXPRESSION="0 2 * * *" +# BACKUP_RETENTION_DAYS: '7' +# BACKUP_FILENAME="backup-%Y-%m-%dT%H-%M-%S.{{ .Extension }}" \ No newline at end of file