mirror of
https://github.com/acedanger/docker.git
synced 2025-12-05 22:50:17 -08:00
Merge branch 'master' of github.com:acedanger/docker
This commit is contained in:
@@ -16,7 +16,8 @@ ptrwd.com {
|
||||
}
|
||||
}
|
||||
# this is the the wiki
|
||||
reverse_proxy ts-racknerd.whale-woodpecker.ts.net:8300
|
||||
# 100.108.70.63 is ts-racknerd
|
||||
reverse_proxy 100.108.70.63:8300
|
||||
}
|
||||
|
||||
wiki.ptrwd.com {
|
||||
@@ -34,7 +35,8 @@ wiki.ptrwd.com {
|
||||
|
||||
# Proxy all other requests to the wiki
|
||||
route {
|
||||
reverse_proxy ts-racknerd.whale-woodpecker.ts.net:8300
|
||||
# 100.108.70.63 is ts-racknerd
|
||||
reverse_proxy 100.108.70.63:8300
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +82,8 @@ sonarr.home.ptrwd.com {
|
||||
# Allow connections only from private ranges and home IP
|
||||
@allowAccess client_ip 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 162.203.102.154/32
|
||||
handle @allowAccess {
|
||||
reverse_proxy ts-io.whale-woodpecker.ts.net:8989
|
||||
# 100.114.112.100 is ts-io
|
||||
reverse_proxy 100.114.112.100:8989
|
||||
}
|
||||
handle {
|
||||
respond 403
|
||||
@@ -97,7 +100,8 @@ radarr.home.ptrwd.com {
|
||||
# Allow connections only from private ranges and home IP
|
||||
@allowAccess client_ip 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 162.203.102.154/32
|
||||
handle @allowAccess {
|
||||
reverse_proxy ts-io.whale-woodpecker.ts.net:7878
|
||||
# 100.114.112.100 is ts-io
|
||||
reverse_proxy 100.114.112.100:7878
|
||||
}
|
||||
handle {
|
||||
respond 403
|
||||
@@ -114,7 +118,8 @@ io.home.ptrwd.com {
|
||||
# Allow connections only from private ranges and home IP
|
||||
@allowAccess client_ip 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 162.203.102.154/32
|
||||
handle @allowAccess {
|
||||
reverse_proxy ts-io.whale-woodpecker.ts.net:5001
|
||||
# 100.114.112.100 is ts-io
|
||||
reverse_proxy 100.114.112.100:5001
|
||||
}
|
||||
handle {
|
||||
respond 403
|
||||
@@ -131,7 +136,6 @@ europa.home.ptrwd.com {
|
||||
# Allow connections only from private ranges and home IP
|
||||
@allowAccess client_ip 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 162.203.102.154/32
|
||||
handle @allowAccess {
|
||||
# reverse_proxy ts-europa.whale-woodpecker.ts.net:5001
|
||||
reverse_proxy host.docker.internal:5001
|
||||
}
|
||||
handle {
|
||||
@@ -149,7 +153,8 @@ racknerd.home.ptrwd.com {
|
||||
# Allow connections only from private ranges and home IP
|
||||
@allowAccess client_ip 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 162.203.102.154/32
|
||||
handle @allowAccess {
|
||||
reverse_proxy ts-racknerd.whale-woodpecker.ts.net:5001
|
||||
# 100.108.70.63 is ts-racknerd
|
||||
reverse_proxy 100.108.70.63:5001
|
||||
}
|
||||
handle {
|
||||
respond 403
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
|
||||
HOARDER_VERSION=release
|
||||
# openssl rand -base64 18
|
||||
NEXTAUTH_SECRET=
|
||||
OPENAI_API_KEY=
|
||||
NEXTAUTH_URL=
|
||||
MEILI_MASTER_KEY=
|
||||
MEILI_MASTER_KEY=
|
||||
# bottom 3 assume we're using Google Gemini
|
||||
OPENAI_API_KEY=
|
||||
OPENAI_BASE_URL=https://generativelanguage.googleapis.com/v1beta
|
||||
INFERENCE_TEXT_MODEL=gemini-2.0-flash
|
||||
INFERENCE_IMAGE_MODEL=gemini-2.0-flash
|
||||
|
||||
@@ -14,6 +14,9 @@ services:
|
||||
OPENAI_API_KEY: ${OPENAI_API_KEY}
|
||||
NEXTAUTH_URL: ${NEXTAUTH_URL}
|
||||
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY}
|
||||
OPENAI_BASE_URL: ${OPENAI_BASE_URL}
|
||||
INFERENCE_TEXT_MODEL: ${INFERENCE_TEXT_MODEL}
|
||||
INFERENCE_IMAGE_MODEL: ${INFERENCE_IMAGE_MODEL}
|
||||
DATA_DIR: /data
|
||||
labels:
|
||||
- diun.enable=true
|
||||
|
||||
147
immich/backup_immich_db.sh
Executable file
147
immich/backup_immich_db.sh
Executable file
@@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Immich Postgres Database Backup Script
|
||||
# This script creates a # Check if the Postgres container exists and is running
|
||||
echo "Checking postgres container status..."
|
||||
if ! docker ps -q --filter "name=immich_postgres" | grep -q .; then
|
||||
echo "Error: immich_postgres container is not running. Cannot proceed with backup."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Taking database backup using pg_dumpall as recommended by Immich documentation..."
|
||||
# Use pg_dumpall with recommended flags: --clean and --if-exists
|
||||
docker exec -t immich_postgres pg_dumpall \
|
||||
--clean \
|
||||
--if-exists \
|
||||
--username="${DB_USERNAME}" \
|
||||
> "${BACKUP_PATH}" 2>/tmp/pg_dumpall_error.log
|
||||
|
||||
# Check if the dump was successful the Immich Postgres database
|
||||
# Based on recommendations from https://immich.app/docs/administration/backup-and-restore/
|
||||
|
||||
# Set up error handling
|
||||
set -e
|
||||
|
||||
# Function to ensure server is unpaused even if script fails
|
||||
cleanup() {
|
||||
local exit_code=$?
|
||||
echo "Running cleanup..."
|
||||
|
||||
# Check if immich_server is paused and unpause it if needed
|
||||
if [ "${IMMICH_SERVER_RUNNING:-true}" = true ] && docker inspect --format='{{.State.Status}}' immich_server 2>/dev/null | grep -q "paused"; then
|
||||
echo "Unpausing immich_server container during cleanup..."
|
||||
docker unpause immich_server 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo "Script failed with exit code $exit_code"
|
||||
fi
|
||||
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
# Set up trap to call cleanup function on script exit (normal or error)
|
||||
trap cleanup EXIT SIGINT SIGTERM
|
||||
|
||||
# Load environment variables from the .env file
|
||||
ENV_FILE="$(dirname "$0")/.env"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
echo "Loading environment variables from $ENV_FILE"
|
||||
source "$ENV_FILE"
|
||||
else
|
||||
echo "Error: .env file not found in $(dirname "$0")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify required environment variables are set
|
||||
if [ -z "$DB_USERNAME" ] || [ -z "$DB_DATABASE_NAME" ]; then
|
||||
echo "Error: Required environment variables (DB_USERNAME, DB_DATABASE_NAME) not found in .env file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize container status variables
|
||||
IMMICH_SERVER_RUNNING=true
|
||||
|
||||
# Create backup directory if it doesn't exist
|
||||
BACKUP_DIR="$(dirname "$0")/database_backups"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Generate timestamp for the backup filename
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
BACKUP_FILENAME="immich_db_backup_${TIMESTAMP}.sql"
|
||||
BACKUP_PATH="${BACKUP_DIR}/${BACKUP_FILENAME}"
|
||||
|
||||
echo "Starting backup of Immich Postgres database..."
|
||||
echo "Using database settings from .env file:"
|
||||
echo " - Database: ${DB_DATABASE_NAME}"
|
||||
echo " - Username: ${DB_USERNAME}"
|
||||
echo " - Container: immich_postgres"
|
||||
|
||||
# Check if the Immich server container exists and is running
|
||||
echo "Checking immich_server container status..."
|
||||
if docker ps -q --filter "name=immich_server" | grep -q .; then
|
||||
echo "Pausing immich_server container to minimize database writes..."
|
||||
if ! docker pause immich_server; then
|
||||
echo "Failed to pause immich_server container."
|
||||
# Continue with backup instead of exiting
|
||||
fi
|
||||
else
|
||||
echo "Note: immich_server container not found or not running. Continuing with backup anyway."
|
||||
# Set a flag so we don't try to unpause it later
|
||||
IMMICH_SERVER_RUNNING=false
|
||||
fi
|
||||
|
||||
echo "Taking database backup using pg_dumpall as recommended by Immich documentation..."
|
||||
# Use pg_dumpall with recommended flags: --clean and --if-exists
|
||||
docker exec -t immich_postgres pg_dumpall \
|
||||
--clean \
|
||||
--if-exists \
|
||||
--username="${DB_USERNAME}" \
|
||||
> "${BACKUP_PATH}"
|
||||
|
||||
# Check if the dump was successful
|
||||
if [ $? -ne 0 ] || [ ! -s "${BACKUP_PATH}" ]; then
|
||||
echo "Error: Database backup failed or created an empty file."
|
||||
if [ -f "/tmp/pg_dumpall_error.log" ]; then
|
||||
echo "Error details:"
|
||||
cat /tmp/pg_dumpall_error.log
|
||||
rm /tmp/pg_dumpall_error.log
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up error log if it exists
|
||||
rm -f /tmp/pg_dumpall_error.log
|
||||
|
||||
# Compress the backup file
|
||||
echo "Compressing backup file..."
|
||||
if ! gzip -f "${BACKUP_PATH}"; then
|
||||
echo "Warning: Failed to compress backup file."
|
||||
fi
|
||||
|
||||
# Resume the Immich server only if it was running and we paused it
|
||||
if [ "${IMMICH_SERVER_RUNNING:-true}" = true ]; then
|
||||
echo "Resuming immich_server container..."
|
||||
if ! docker unpause immich_server 2>/dev/null; then
|
||||
echo "Note: No need to unpause immich_server container."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Backup completed successfully!"
|
||||
echo "Backup saved to: ${BACKUP_PATH}.gz"
|
||||
|
||||
# Optional: List backups and show total size
|
||||
echo -e "\nBackup information:"
|
||||
find "${BACKUP_DIR}" -name "*.gz" | wc -l | xargs echo "Total number of backups:"
|
||||
du -sh "${BACKUP_DIR}" | cut -f1 | xargs echo "Total backup size:"
|
||||
|
||||
# Optional: Check if backup file is smaller than expected (potential warning)
|
||||
BACKUP_SIZE=$(du -k "${BACKUP_PATH}.gz" | cut -f1)
|
||||
if [ ${BACKUP_SIZE} -lt 100 ]; then
|
||||
echo "Warning: Backup file is smaller than expected (${BACKUP_SIZE}KB). Please verify its integrity."
|
||||
fi
|
||||
|
||||
# Optional: Remove backups older than 30 days
|
||||
# find "${BACKUP_DIR}" -name "immich_db_backup_*.sql.gz" -mtime +30 -delete
|
||||
|
||||
echo -e "\nTo restore this backup, follow the instructions at: https://immich.app/docs/administration/backup-and-restore/"
|
||||
@@ -51,28 +51,17 @@ services:
|
||||
restart: always
|
||||
database:
|
||||
container_name: immich_postgres
|
||||
image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
|
||||
image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0
|
||||
environment:
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
POSTGRES_USER: ${DB_USERNAME}
|
||||
POSTGRES_DB: ${DB_DATABASE_NAME}
|
||||
POSTGRES_INITDB_ARGS: --data-checksums
|
||||
# Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs
|
||||
DB_STORAGE_TYPE: 'HDD'
|
||||
volumes:
|
||||
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
|
||||
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: pg_isready --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" ||
|
||||
exit 1; Chksum="$$(psql --dbname="$${POSTGRES_DB}"
|
||||
--username="$${POSTGRES_USER}" --tuples-only --no-align
|
||||
--command='SELECT COALESCE(SUM(checksum_failures), 0) FROM
|
||||
pg_stat_database')"; echo "checksum failure count is $$Chksum"; [
|
||||
"$$Chksum" = '0' ] || exit 1
|
||||
interval: 5m
|
||||
start_interval: 30s
|
||||
start_period: 5m
|
||||
command: postgres -c shared_preload_libraries=vectors.so -c
|
||||
'search_path="$$user", public, vectors' -c logging_collector=on -c
|
||||
max_wal_size=2GB -c shared_buffers=512MB -c wal_compression=on
|
||||
restart: always
|
||||
volumes:
|
||||
model-cache: null
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
services:
|
||||
memos:
|
||||
image: ghcr.io/usememos/memos:latest
|
||||
container_name: memos
|
||||
volumes:
|
||||
- memos:/var/opt/memos
|
||||
ports:
|
||||
- 5230:5230
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
- diun.enable=true
|
||||
volumes:
|
||||
memos: null
|
||||
networks: {}
|
||||
Reference in New Issue
Block a user