616b20f285
- init-r2-repository.sh: inicializa repositorio Kopia en R2 - run-backup.sh: ejecuta backup de rutas definidas en backup-paths.txt - pre-backup-dumps.sh: vuelca bases de datos (Postgres, MariaDB) antes del backup - kopia-common.sh: funciones compartidas de autenticación y configuración - restore-smoke-test.sh: test de restauración para verificar integridad - backup-paths.txt / excludes.txt: rutas y exclusiones del backup - systemd/: unidades kopia-server, kopia-docker-backup (service + timer) - traefik-kopia.yml: exposición del servidor Kopia vía Traefik - env.example: plantilla de variables (credenciales R2, contraseña repo) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
1.4 KiB
Bash
Executable File
59 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
ENV_FILE="${KOPIA_ENV_FILE:-/opt/kopia/kopia.env}"
|
|
|
|
if [[ -f "$ENV_FILE" ]]; then
|
|
# shellcheck disable=SC1090
|
|
source "$ENV_FILE"
|
|
fi
|
|
|
|
KOPIA_CONFIG_FILE="${KOPIA_CONFIG_FILE:-/opt/kopia/repository.config}"
|
|
KOPIA_CACHE_DIRECTORY="${KOPIA_CACHE_DIRECTORY:-/opt/kopia/cache}"
|
|
KOPIA_LOG_DIR="${KOPIA_LOG_DIR:-/opt/kopia/logs}"
|
|
BACKUP_STAGING_DIR="${BACKUP_STAGING_DIR:-/opt/kopia/staging}"
|
|
BACKUP_PATHS_FILE="${BACKUP_PATHS_FILE:-$SCRIPT_DIR/backup-paths.txt}"
|
|
KOPIA_EXCLUDES_FILE="${KOPIA_EXCLUDES_FILE:-$SCRIPT_DIR/excludes.txt}"
|
|
|
|
export KOPIA_PASSWORD
|
|
export KOPIA_CACHE_DIRECTORY
|
|
|
|
require_cmd() {
|
|
command -v "$1" >/dev/null 2>&1 || {
|
|
echo "Missing required command: $1" >&2
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
require_env() {
|
|
local name="$1"
|
|
if [[ -z "${!name:-}" ]]; then
|
|
echo "Missing required environment variable: $name" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
require_real_env() {
|
|
local name="$1"
|
|
require_env "$name"
|
|
case "${!name}" in
|
|
change-me|change-me.*|*.change-me|*change-me*)
|
|
echo "Environment variable $name still contains a placeholder value" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
kopia_cmd() {
|
|
kopia --config-file="$KOPIA_CONFIG_FILE" "$@"
|
|
}
|
|
|
|
log() {
|
|
printf '[%s] %s\n' "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" "$*"
|
|
}
|
|
|
|
ensure_runtime_dirs() {
|
|
mkdir -p "$KOPIA_CACHE_DIRECTORY" "$KOPIA_LOG_DIR" "$BACKUP_STAGING_DIR"
|
|
}
|