Created
May 25, 2012 21:02
-
-
Save daogurtsov/2790528 to your computer and use it in GitHub Desktop.
database coping for multiple wordpress installations
This file contains hidden or 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/sh | |
| dbPath=wpdb.sql | |
| fDomainsPath=domains.txt | |
| logFile=logdb.txt | |
| dirName=dbes | |
| #END DECLARATION | |
| if [ -f "$fDomainsPath" -a -f "$dbPath" ]; then | |
| if [ ! -d $dirName ]; then | |
| mkdir "$dirName" | |
| else | |
| counter=$(ls "$dirName" | wc -l) | |
| if [ "$counter" -gt 0 ]; then | |
| rm "$dirName"/* | |
| fi | |
| fi | |
| # | |
| if [ -f "$logFile" ]; then | |
| rm "$logFile" | |
| fi | |
| # | |
| touch "$logFile" | |
| while read line | |
| do | |
| db=$(echo $line | awk '{print $1}') | |
| echo "$db" | |
| cp "$dbPath" "$dirName/$db" | |
| sed -e "s/site.domain/$db/ig" "$dirName/$db" > /tmp/tempfile.tmp | |
| mv /tmp/tempfile.tmp "$dirName/$db" | |
| echo "$db">>"$logFile" | |
| done < "$fDomainsPath" | |
| # | |
| counter=`wc -l "$logFile"` | |
| echo "========================" | |
| echo "$counter dbes processed" | |
| else | |
| echo "Check path to db - $dbPath and path to domains list - $fDomainsPath" | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fine only with fresh wp installations, doesn't treat serialization issues