From 232159984cea9a99bc797992b02aea75965b8f39 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 12 Feb 2026 17:01:32 +0100 Subject: [PATCH] init --- .gitignore | 1 + README.md | 14 ++++++++++++++ backup.sh | 33 +++++++++++++++++++++++++++++++++ backups/.gitignore | 2 ++ compose.yml | 34 ++++++++++++++++++++++++++++++++++ db/.gitignore | 2 ++ db_import/.gitignore | 2 ++ example.env | 4 ++++ static/.gitignore | 2 ++ uploads.ini | 5 +++++ wp/.gitignore | 2 ++ 11 files changed, 101 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 backup.sh create mode 100644 backups/.gitignore create mode 100644 compose.yml create mode 100644 db/.gitignore create mode 100644 db_import/.gitignore create mode 100644 example.env create mode 100644 static/.gitignore create mode 100644 uploads.ini create mode 100644 wp/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..325fa75 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Crispi Docker template + + +# Einrichten +``` +echo "MYSQL_ROOT_PASSWORD=$( openssl rand -hex 16 )" > .env +MYSQL_DATABASE=wordpress >> .env +MYSQL_USER=wordpress >> .env +echo "MYSQL_PASSWORD=$( openssl rand -hex 16 )" >> .env +``` + +## Cron + +Backup script in Cron einbinden nicht vergessen \ No newline at end of file diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..9692d1c --- /dev/null +++ b/backup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# stop on error +set -e + +DATE=$(date +"%Y-%m-%d") +BACKUP_NAME="${DATE}.tar.gz" + +# dir of this script that will also work when called from elsewhere +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$DIR" || exit 1 + +# load .env variables +if [ -f "$DIR/.env" ]; then + export $(grep -v '^#' "$DIR/.env" | xargs) +fi + +# --- PREPARE --- +mkdir -p "${DIR}/backups" + +echo "Creating DB dump..." +docker compose exec db mariadb-dump --no-tablespaces -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" > "db_dump_${DATE}.sql" + +echo "Creating tar.gz archive..." +tar -czf "${DIR}/backups/${BACKUP_NAME}" --exclude='db' --exclude='.git' --exclude='static' --exclude='backups' --exclude='db_import' "." "db_dump_${DATE}.sql" + +echo "Cleaning up temp SQL dump..." +rm "db_dump_${DATE}.sql" + +echo "Cleaning up local backups older than 7 days..." +find "${DIR}/backups" -name "*.tar.gz" -type f -mtime +7 -delete + +echo "✅ Backup complete: ${DIR}/backups/${BACKUP_NAME}" \ No newline at end of file diff --git a/backups/.gitignore b/backups/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/backups/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..af4869a --- /dev/null +++ b/compose.yml @@ -0,0 +1,34 @@ +services: + db: + image: mariadb:12-noble + command: '--default-authentication-plugin=mysql_native_password' + volumes: + - ./db:/var/lib/mysql + - ./db_import:/docker-entrypoint-initdb.d + restart: unless-stopped + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_USER=${MYSQL_USER} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} + wordpress: + image: wordpress:latest + volumes: + - ./wp:/var/www/html + - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini + - ./static:/export + ports: + - 8080:80 + restart: unless-stopped + environment: + - WORDPRESS_DB_HOST=db + - WORDPRESS_DB_USER=${MYSQL_USER} + - WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD} + - WORDPRESS_DB_NAME=${MYSQL_DATABASE} + static: + image: caddy:latest + restart: unless-stopped + volumes: + - ./static:/usr/share/caddy + ports: + - 8081:80 \ No newline at end of file diff --git a/db/.gitignore b/db/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/db/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/db_import/.gitignore b/db_import/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/db_import/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/example.env b/example.env new file mode 100644 index 0000000..0794838 --- /dev/null +++ b/example.env @@ -0,0 +1,4 @@ +MYSQL_ROOT_PASSWORD=$( openssl rand -hex 16 ) +MYSQL_DATABASE=wordpress +MYSQL_USER=wordpress +MYSQL_PASSWORD=$( openssl rand -hex 16 ) \ No newline at end of file diff --git a/static/.gitignore b/static/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/static/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/uploads.ini b/uploads.ini new file mode 100644 index 0000000..bea123f --- /dev/null +++ b/uploads.ini @@ -0,0 +1,5 @@ +file_uploads = On +memory_limit = 500M +upload_max_filesize = 500M +post_max_size = 500M +max_execution_time = 600 \ No newline at end of file diff --git a/wp/.gitignore b/wp/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/wp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file