21 lines
658 B
Bash
Executable File
21 lines
658 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# TARGET: Backup-Ziel
|
|
# IGNORE: Liste zu ignorierender Datenbanken (durch | getrennt)
|
|
IGNORE="mysql|information_schema|performance_schema|test"
|
|
PASSWORD="$(cat /etc/nixos/secrets/mysql-password)"
|
|
|
|
set -eu -o pipefail
|
|
|
|
export PATH="/usr/bin/:$PATH"
|
|
|
|
DBS="$(lxc-attach -n mysql -- mysql --host="mysql" --user="root" --password="$PASSWORD" -Bse 'show databases' | grep -Ev $IGNORE)"
|
|
|
|
rm -f *.sql.bz2
|
|
|
|
for DB in $DBS; do
|
|
lxc-attach -n mysql -- mysqldump --host="localhost" --user="root" --password="$PASSWORD" --skip-extended-insert --skip-comments "$DB" | bzip2 -c > "$DB.sql.bz2"
|
|
done
|
|
|
|
echo "$0 - Backup erfolgreich durchgefuehrt"
|
|
exit 0
|