fleet/tools/backup_db/backup.sh
Dante Catalfamo 8dd5df1d06
Add script that backs up and restores DB when switching branches (#31197)
If this script is added as the `post-checkout` git hook, if the branch
you're switching to has different migrations from the one you're coming
from, it will automatically dump the current db, and restore the dump
from the last time you visited this branch. If no dump exists, it just
leaves the DB as-is
2025-08-06 13:34:51 -04:00

4 lines
285 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
BACKUP_NAME="${1:-backup.sql.gz}"
docker run --rm --network fleet_default ${FLEET_MYSQL_IMAGE:-mysql:8.0.36} bash -c "mysqldump -hmysql -uroot -ptoor --default-character-set=utf8mb4 --add-drop-database --databases fleet | gzip -" > "$BACKUP_NAME"