fleet/tools/backup_db
Scott Gress f5f2a16867
Clear db before restoring from backup (#26928)
For #26478 

## Details

This PR updates the db snapshot script to have it add a `drop database
if exists` line to the top. This means that snapshots will start from a
clean state, so that they won't get out of sync with migrations.

## Testing

I tested this by:

1. starting with an up-to-date database, restoring an old snapshot while
on the main code branch, then trying `fleet prepare db`.
2. This failed because the migrations it tried to run were creating
tables that already existed in the database.
3. I made a new copy of this snapshot by dropping my db and doing
`create database fleet`, restoring the snapshot and snapshotting again.
4. On the main branch, I reset my db using `make db-reset` and then
restore my new snapshot
5. Finally, did `fleet prepare db` and this time it worked since the new
snapshot dropped the database before restoring.
2025-03-10 10:01:52 -05:00
..
backup.sh Clear db before restoring from backup (#26928) 2025-03-10 10:01:52 -05:00
README.md Updated testing.md (#6583) 2022-08-01 19:06:30 -05:00
restore.sh Add Fleet dev snapshot tool (#25909) 2025-02-05 09:52:10 -06:00
restore_e2e_software_test.sh MySQL 8.0 Migration (#20225) 2024-07-22 16:27:36 -04:00

These scripts are for backing up and restore the Docker development MySQL database.

Usage is documented here.