Restore Rows From a Backup


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" \

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}" \

Tidy Up

Shutdown the container

docker rm -f db-restore