Restore Rows From a Backup¶
Prepare¶
Locate and prepare your backup - e.g: decrypt / decompress / etc...
Load the Backup¶
Load the backup into a docker container:
docker run \ -it \ --rm \ --name db-restore \ -v "$(readlink -f my-db-backup.sql):/docker-entrypoint-initdb.d/my-db-backup.sql:ro" \ -e MYSQL_RANDOM_ROOT_PASSWORD=true \ mysql/mysql-server:latest
The container will create a password for the root
account - keep it handy.
Once it gets to a steady state, use ^P ^Q to detach and leave it running.
Inspect the Backup¶
Inspect your backup using the MySQL CLI:
docker exec -it db-restore mysql -u root -p
Dump the Rows¶
Extract the rows in a way that allows you to paste them into a MySQL CLI:
docker exec \ -it \ db-restore \ mysqldump \ -u root \ -p \ --no-create-db \ --no-create-info \ "${DATABASE}" \ "${TABLE}" \ --where="${CONDITION}"
Tidy Up¶
Shutdown the container
docker rm -f db-restore