Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@blu-IT
Copy link

blu-IT commented Jul 19, 2022

Since you take a mysql dump, automatically the .sql file will appear in your host folder. Tell me what you think?

@ambrosiora

Thanks! I already solved its (inside my script) this way:

docker cp <container_id>:/file/path/within/container /host/path/target

@behai-nguyen
Copy link

behai-nguyen commented Aug 7, 2022

Very sweet. Thank you very much.

@echanobe
Copy link

echanobe commented Aug 14, 2022

Thank you!

@Tipset
Copy link

Tipset commented Aug 17, 2022

This helped a bunch, thank you!

@hkanizawa
Copy link

hkanizawa commented Aug 24, 2022

Thanks

@tomaszroot
Copy link

tomaszroot commented Aug 31, 2022

:-*

@botosdavid
Copy link

botosdavid commented Sep 19, 2022

thank you so much!

@dorimusz
Copy link

dorimusz commented Sep 19, 2022

Thanks a lot!

@ttcosta11
Copy link

ttcosta11 commented Sep 26, 2022

Thank you!

@tgiovanella87
Copy link

tgiovanella87 commented Oct 12, 2022

Great! Thanks!

@paulovnas
Copy link

paulovnas commented Nov 4, 2022

Very nice... Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment