Created
June 8, 2019 07:20
-
-
Save jan-koch/d15ac627d29882f15100bf50900a7baa to your computer and use it in GitHub Desktop.
Bash script to export a database from a WordPress container and perform a search/replace using the UNIX command "sed". Script is based on https://hub.docker.com/r/jankoch/wordpress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
CONTAINER=$1 | |
SEARCH=$2 | |
REPLACE=$3 | |
# Dump the file | |
DUMP=$(docker exec $CONTAINER wp db export --add-drop-table --porcelain) | |
echo "Dump completed. Filename: $DUMP" | |
# Replace in file | |
sed -i -e "s/$SEARCH/$REPLACE/g" $DUMP | |
echo "Search and replace completed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment