Skip to content

Instantly share code, notes, and snippets.

@felipefernandes
Created August 10, 2017 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipefernandes/30ad618f29bf62d75e3b6a7124c548c8 to your computer and use it in GitHub Desktop.
Save felipefernandes/30ad618f29bf62d75e3b6a7124c548c8 to your computer and use it in GitHub Desktop.
Docker Database Dump Import Shell Script
#!/bin/bash
#
# version 1.0
# Docker WP Dump Loader
#
echo "Starting up..."
echo ""
#
echo "What's the docker mysql container name?"
read containerName
if [ "$containerName" == "" ]; then
echo "Sorry, you need to inform the Container name!"
exit
else
echo "Database dump filename?"
read dumpfile
if [ "$containerName" == "" ]; then
echo "Sorry, you need to inform the Container name!"
exit
else
echo ""
echo "Loads saved database dump ($dumpfile) into MySQL container ($containerName)"
echo "------------------------------------------------------"
echo ""
# Loads and imports a local dump file inside the mysql container
docker exec -i $containerName mysql wordpress -uroot -pwp < $dumpfile 2>/dev/null
echo ""
echo "High Five!!!"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment