Changed roles to new docker backup procedure

This commit is contained in:
Kevin Veen-Birkenbach 2023-12-26 03:13:16 +01:00
parent c2fe8a95c0
commit 15bf140065
35 changed files with 215 additions and 228 deletions

View File

@ -34,10 +34,15 @@
notify: restart backup-docker-to-local.timer
when: run_once_backup_docker_to_local is not defined
- name: create {{backup_docker_to_local_folder}}databases.csv
copy:
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{backup_docker_to_local_folder}}databases.csv"
dest: "{{backup_docker_to_local_folder}}databases.csv"
- name: seed database values
command:
cmd: "python database_entry_seeder.py databases.csv {{database_instance}} {{database_host}} {{database_databasename}} {{database_username}} {{database_password}}"
chdir: "{{backup_docker_to_local_folder}}"
- name: Set file permissions for databases.csv to be readable, writable, and executable by root only
ansible.builtin.file:
path: "{{ backup_docker_to_local_folder }}databases.csv"
mode: '0700'
owner: root
group: root
when: run_once_backup_docker_to_local is not defined

View File

@ -1,9 +1,9 @@
# These could be changed
MYSQL_DATABASE=akaunting
MYSQL_USER=admin
MYSQL_DATABASE={{database_databasename}}
MYSQL_USER={{database_username}}
# This should definitely be changed to something long and random
MYSQL_PASSWORD={{akaunting_database_password}}
MYSQL_PASSWORD={{database_password}}
# You should probably leave this
MYSQL_ROOT_PASSWORD={{akaunting_database_password}}
MYSQL_ROOT_PASSWORD={{database_password}}

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}akaunting/"
database_instance: "akaunting"
database_host: "akaunting-db"
database_databasename: "{{database_instance}}"
database_username: "admin"
database_password: "{{akaunting_database_password}}"

View File

@ -24,24 +24,9 @@ services:
volumes:
- .:/usr/share/nginx/html
- .:/var/www
database:
logging:
driver: journald
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "attendize"
MYSQL_USER: "attendize"
MYSQL_PASSWORD: "{{attendize_database_password}}"
MYSQL_ROOT_PASSWORD: "{{attendize_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=attendize --password={{attendize_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
{% include 'templates/docker-mariadb-service.yml.j2' %}
maildev:
image: maildev/maildev
ports:

View File

@ -1,3 +1,8 @@
---
docker_compose_instance_directory: "{{path_docker_compose_instances}}attendize/"
mail_interface_domain: "mail.{{domain}}"
database_instance: "attendize"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{attendize_database_password}}"

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}bigbluebutton/"
database_instance: "bigbluebutton"
database_host: "postgres"
database_databasename: "greenlight-v3"
database_username: "postgres"
database_password: ""

View File

@ -10,10 +10,10 @@ services:
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=mysql
- DB_HOST=database:3306
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD={{gitea_database_password}}
- DB_HOST={{database_host}}:3306
- DB_NAME={{database_databasename}}
- DB_USER={{database_username}}
- DB_PASSWD={{database_password}}
- SSH_PORT={{ssh_port}}
- SSH_LISTEN_PORT=22
- DOMAIN={{domain}}
@ -31,24 +31,7 @@ services:
- /etc/localtime:/etc/localtime:ro
depends_on:
- database
database:
logging:
driver: journald
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "gitea"
MYSQL_USER: "gitea"
MYSQL_PASSWORD: "{{gitea_database_password}}"
MYSQL_ROOT_PASSWORD: "{{gitea_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=gitea --password={{gitea_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
{% include 'templates/docker-mariadb-service.yml.j2' %}
volumes:
database:
data:

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}gitea/"
database_instance: "gitea"
database_host: "{{database_instance}}"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{gitea_database_password}}"

View File

@ -6,10 +6,10 @@ services:
logging:
driver: journald
environment:
JOOMLA_DB_HOST: "database:3306"
JOOMLA_DB_USER: "joomla"
JOOMLA_DB_PASSWORD: "{{joomla_database_password}}"
JOOMLA_DB_NAME: "joomla"
JOOMLA_DB_HOST: "{{database_host}}:3306"
JOOMLA_DB_USER: "{{database_username}}"
JOOMLA_DB_PASSWORD: "{{database_password}}"
JOOMLA_DB_NAME: "{{database_databasename}}"
restart: always
links:
- database
@ -17,19 +17,9 @@ services:
- data:/var/www/html
ports:
- "127.0.0.1:{{http_port}}:80"
database:
image: mariadb
logging:
driver: journald
environment:
MYSQL_DATABASE: "joomla"
MYSQL_USER: "joomla"
MYSQL_PASSWORD: "{{joomla_database_password}}"
MYSQL_ROOT_PASSWORD: "{{joomla_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
restart: always
{% include 'templates/docker-mariadb-service.yml.j2' %}
volumes:
database:
data:

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}joomla/"
database_instance: "joomla"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{joomla_database_password}}"

View File

@ -1,6 +1,29 @@
version: "3.7"
x-application-defaults: &application-defaults
services:
database:
image: postgres:13-alpine
ports:
- "9432:5432"
networks:
- listmonk
environment:
- POSTGRES_PASSWORD={{database_password}}
- POSTGRES_USER={{database_username}}
- POSTGRES_DB={{database_databasename}}
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U {{database_username}}"]
interval: 10s
timeout: 5s
retries: 6
container_name: database
volumes:
- type: volume
source: listmonk-data
target: /var/lib/postgresql/data
application:
restart: unless-stopped
image: listmonk/listmonk:latest
ports:
@ -9,35 +32,6 @@ x-application-defaults: &application-defaults
- listmonk
environment:
- TZ=Etc/UTC
x-database-defaults: &database-defaults
image: postgres:13-alpine
ports:
- "9432:5432"
networks:
- listmonk
environment:
- POSTGRES_PASSWORD={{listmonk_database_password}}
- POSTGRES_USER=listmonk
- POSTGRES_DB=listmonk
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U listmonk"]
interval: 10s
timeout: 5s
retries: 6
services:
database:
<<: *database-defaults
container_name: database
volumes:
- type: volume
source: listmonk-data
target: /var/lib/postgresql/data
application:
<<: *application-defaults
container_name: listmonk_application
depends_on:
- database

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}listmonk/"
database_instance: "listmonk"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{listmonk_database_password}}"

View File

@ -21,24 +21,7 @@ services:
dns:
- 192.168.203.254
database:
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "mailu"
MYSQL_USER: "mailu"
MYSQL_PASSWORD: "{{mailu_database_password}}"
MYSQL_ROOT_PASSWORD: "{{mailu_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=mailu --password={{mailu_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
logging:
driver: journald
{% include 'templates/docker-mariadb-service.yml.j2' %}
depends_on:
- resolver
dns:

View File

@ -140,15 +140,15 @@ LOG_LEVEL=WARNING
# Database settings
###################################
DB_FLAVOR=mysql
DB_USER=mailu
DB_PW={{mailu_database_password}}
DB_HOST=database:3306
DB_NAME=mailu
DB_USER={{database_username}}
DB_PW={{database_password}}
DB_HOST={{database_host}}:3306
DB_NAME={{database_databasename}}
ROUNDCUBE_DB_FLAVOR=mysql
ROUNDCUBE_DB_USER=mailu
ROUNDCUBE_DB_PW={{mailu_database_password}}
ROUNDCUBE_DB_NAME=mailu
ROUNDCUBE_DB_HOST=database:3306
ROUNDCUBE_DB_USER={{database_username}}
ROUNDCUBE_DB_PW={{database_password}}
ROUNDCUBE_DB_NAME={{database_databasename}}
ROUNDCUBE_DB_HOST={{database_host}}:3306
API_TOKEN={{mailu_api_token}}

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}mailu/"
database_instance: "mailu"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{mailu_database_password}}"

View File

@ -5,11 +5,11 @@ SECRET_KEY_BASE={{mastodon_secret_key_base}}
OTP_SECRET={{mastodon_otp_secret}}
VAPID_PRIVATE_KEY={{mastodon_vapid_private_key}}
VAPID_PUBLIC_KEY={{mastodon_vapid_public_key}}
DB_HOST=database
DB_HOST={{database_host}}
DB_PORT=5432
DB_NAME=postgres
DB_USER=postgres
DB_PASS=
DB_NAME={{database_databasename}}
DB_USER={{database_username}}
DB_PASS={{database_password}}
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}mastodon/"
database_instance: "mastodon"
database_host: "database"
database_databasename: "postgres" # todo: Change this to standart name scheme for future setups
database_username: "postgres" # todo: Change this to standart name scheme for future setups
database_password: "" # todo: Change this to standart name scheme for future setups

View File

@ -9,35 +9,20 @@ services:
ports:
- "127.0.0.1:{{http_port}}:80"
environment:
MATOMO_DATABASE_HOST: "database:3306"
MATOMO_DATABASE_HOST: "{{database_host}}:3306"
MATOMO_DATABASE_ADAPTER: "mysql"
MATOMO_DATABASE_USERNAME: "matomo"
MATOMO_DATABASE_PASSWORD: "{{matomo_database_password}}"
MATOMO_DATABASE_DBNAME: "matomo"
MATOMO_DATABASE_USERNAME: "{{database_username}}"
MATOMO_DATABASE_PASSWORD: "{{database_password}}"
MATOMO_DATABASE_DBNAME: "{{database_databasename}}"
links:
- database
depends_on:
- database
volumes:
- data:/var/www/html
database:
logging:
driver: journald
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "matomo"
MYSQL_USER: "matomo"
MYSQL_PASSWORD: "{{matomo_database_password}}"
MYSQL_ROOT_PASSWORD: "{{matomo_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=matomo --password={{matomo_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
{% include 'templates/docker-mariadb-service.yml.j2' %}
volumes:
database:
data:

View File

@ -1,2 +1,7 @@
---
docker_compose_instance_directory: "{{path_docker_compose_instances}}matomo/"
database_instance: "matomo"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{matomo_database_password}}"

View File

@ -26,12 +26,12 @@ services:
volumes:
- database:/var/lib/postgresql/data
environment:
- POSTGRES_DB=matrix
- POSTGRES_USER=matrix
- POSTGRES_PASSWORD={{matrix_database_password}}
- POSTGRES_DB={{database_databasename}}
- POSTGRES_USER={{database_username}}
- POSTGRES_PASSWORD={{database_password}}
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
healthcheck:
test: ["CMD-SHELL", "pg_isready -U matrix"]
test: ["CMD-SHELL", "pg_isready -U {{database_username}}"]
interval: 10s
timeout: 5s
retries: 6

View File

@ -1,2 +1,7 @@
---
docker_compose_instance_directory: "{{path_docker_compose_instances}}matrix/"
database_instance: "matrix"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{matrix_database_password}}"

View File

@ -25,24 +25,9 @@ services:
volumes:
- "{{docker_compose_instance_confd_directory}}:{{target_mount_conf_d_directory}}:ro"
- "data:/var/www/html:ro"
database:
logging:
driver: journald
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "mybb"
MYSQL_USER: "mybb"
MYSQL_PASSWORD: "{{mybb_database_password}}"
MYSQL_ROOT_PASSWORD: "{{mybb_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=mybb --password={{mybb_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
{% include 'templates/docker-mariadb-service.yml.j2' %}
volumes:
database:
data:

View File

@ -4,3 +4,8 @@ docker_compose_instance_confd_directory: "{{docker_compose_instance_directory}}c
docker_compose_instance_confd_defaultconf_file: "{{docker_compose_instance_confd_directory}}default.conf"
target_mount_conf_d_directory: "{{nginx_servers_directory}}"
source_domain: "mybb.{{top_domain}}"
database_instance: "mybb"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{mybb_database_password}}"

View File

@ -11,26 +11,26 @@ services:
volumes:
- data:/var/www/html
environment:
MYSQL_DATABASE: "nextcloud"
MYSQL_USER: "nextcloud"
MYSQL_PASSWORD: "{{nextcloud_database_password}}"
MYSQL_HOST: database:3306
MYSQL_DATABASE: "{{database_databasename}}"
MYSQL_USER: "{{database_username}}"
MYSQL_PASSWORD: "{{database_password}}"
MYSQL_HOST: {{database_host}}:3306
database:
logging:
driver: journald
image: mariadb:10.5
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW"
environment:
MYSQL_DATABASE: "nextcloud"
MYSQL_USER: "nextcloud"
MYSQL_PASSWORD: "{{nextcloud_database_password}}"
MYSQL_ROOT_PASSWORD: "{{nextcloud_database_password}}"
MYSQL_DATABASE: "{{database_databasename}}"
MYSQL_USER: "{{database_username}}"
MYSQL_PASSWORD: "{{database_password}}"
MYSQL_ROOT_PASSWORD: "{{database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
restart: always
healthcheck:
test: "/usr/bin/mariadb --user=nextcloud --password={{nextcloud_database_password}} --execute \"SHOW DATABASES;\""
test: "/usr/bin/mariadb --user={{database_username}} --password={{database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5

View File

@ -1,2 +1,7 @@
---
docker_compose_instance_directory: "{{path_docker_compose_instances}}nextcloud/"
database_instance: "nextcloud"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{nextcloud_database_password}}"

View File

@ -12,8 +12,8 @@ OPENPROJECT_HOST__NAME={{domain}}
PORT=127.0.0.1:{{http_port}}
OPENPROJECT_RAILS__RELATIVE__URL__ROOT=
IMAP_ENABLED=false
POSTGRES_PASSWORD="{{ openproject_database_password }}"
DATABASE_URL="postgres://postgres:{{ openproject_database_password }}@db/openproject?pool=20&encoding=unicode&reconnect=true"
POSTGRES_PASSWORD="{{ database_password }}"
DATABASE_URL="postgres://{{ database_username }}:{{ database_password }}@{{database_host}}/{{database_databasename}}?pool=20&encoding=unicode&reconnect=true"
RAILS_MIN_THREADS=4
RAILS_MAX_THREADS=16

View File

@ -2,3 +2,8 @@ repository_directory: "{{ path_docker_compose_instances }}openproject/"
docker_compose_instance_directory: "{{repository_directory}}compose/"
docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml"
docker_compose_backup_path: "/tmp/openproject-docker-compose-backup.yml"
database_instance: "openproject"
database_host: "db"
database_databasename: "{{database_instance}}"
database_username: "postgres"
database_password: "{{openproject_database_password}}"

View File

@ -1,11 +1,11 @@
# Database / Postgres service configuration
POSTGRES_USER=peertube
POSTGRES_USER={{database_username}}
POSTGRES_PASSWORD={{peertube_database_password}}
POSTGRES_DB=peertube
PEERTUBE_DB_USERNAME=peertube
POSTGRES_DB={{database_databasename}}
PEERTUBE_DB_USERNAME={{database_username}}
PEERTUBE_DB_PASSWORD={{peertube_database_password}}
PEERTUBE_DB_SSL=false
PEERTUBE_DB_HOSTNAME=database
PEERTUBE_DB_HOSTNAME={{database_host}}
# PeerTube server configuration
PEERTUBE_WEBSERVER_HOSTNAME={{domain}}

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}peertube/"
database_instance: "peertube"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{peertube_database_password}}"

View File

@ -38,20 +38,9 @@ services:
interval: 60s
timeout: 5s
retries: 1
database:
logging:
driver: journald
image: mariadb
restart: always
env_file:
- ./env
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=pixelfed --password={{pixelfed_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
{% include 'templates/docker-mariadb-service.yml.j2' %}
redis:
image: redis:alpine
restart: always

View File

@ -1,2 +1,7 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}pixelfed/"
nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size 512M;"
database_instance: "pixelfed"
database_host: "{{database_instance}}"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{pixelfed_database_password}}"

View File

@ -11,34 +11,19 @@ services:
ports:
- "127.0.0.1:{{http_port}}:80"
environment:
WORDPRESS_DB_HOST: database:3306
WORDPRESS_DB_USER: "wordpress"
WORDPRESS_DB_PASSWORD: "{{wordpress_database_password}}"
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_HOST: "{{database_host}}:3306"
WORDPRESS_DB_USER: "{{database_username}}"
WORDPRESS_DB_PASSWORD: "{{database_password}}"
WORDPRESS_DB_NAME: "{{database_databasename}}"
links:
- database
volumes:
- data:/var/www/html
depends_on:
- database
database:
logging:
driver: journald
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "wordpress"
MYSQL_USER: "wordpress"
MYSQL_PASSWORD: "{{wordpress_database_password}}"
MYSQL_ROOT_PASSWORD: "{{wordpress_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user=wordpress --password={{wordpress_database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
{% include 'templates/docker-mariadb-service.yml.j2' %}
volumes:
database:
data:

View File

@ -1,2 +1,7 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}wordpress/"
wordpress_max_upload_size: "64M"
database_instance: "wordpress"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{wordpress_database_password}}"

View File

@ -1 +1,6 @@
docker_compose_instance_directory: "{{path_docker_compose_instances}}yourls/"
database_instance: "yourls"
database_host: "database"
database_databasename: "{{database_instance}}"
database_username: "{{database_instance}}"
database_password: "{{yourls_database_password}}"

View File

@ -0,0 +1,18 @@
database:
logging:
driver: journald
image: mariadb
restart: always
environment:
MYSQL_DATABASE: "{{database_databasename}}"
MYSQL_USER: "{{database_username}}"
MYSQL_PASSWORD: "{{database_password}}"
MYSQL_ROOT_PASSWORD: "{{database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql
healthcheck:
test: "/usr/bin/mariadb --user={{database_username}} --password={{database_password}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5