templates/wordpress/backup.sh
2026-11-28 15:28:02 +02:00

11 lines
586 B
Shell
Executable file

#!/bin/sh
# Saves the database and wp-content into backups/ next to this file.
# Usage, on the server: sh backup.sh
# Copy the backups to another place too (your computer or another server).
set -eu
cd "$(dirname "$0")"
stamp=$(date +%Y%m%d-%H%M%S)
mkdir -p backups
docker compose exec -T db sh -c 'exec mariadb-dump -uroot -p"$MARIADB_ROOT_PASSWORD" --single-transaction wordpress' | gzip > "backups/db-$stamp.sql.gz"
docker compose exec -T wordpress tar czf - -C /var/www/html wp-content > "backups/files-$stamp.tar.gz"
ls -lh "backups/db-$stamp.sql.gz" "backups/files-$stamp.tar.gz"