Skip to content

Instantly share code, notes, and snippets.

@daogurtsov
Created May 25, 2012 21:02
Show Gist options
  • Select an option

  • Save daogurtsov/2790528 to your computer and use it in GitHub Desktop.

Select an option

Save daogurtsov/2790528 to your computer and use it in GitHub Desktop.
database coping for multiple wordpress installations
#!/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
@daogurtsov
Copy link
Copy Markdown
Author

before use prepare wordpress db, substitute site.domain into url spaces like: htttp://site.domain

@daogurtsov
Copy link
Copy Markdown
Author

fine only with fresh wp installations, doesn't treat serialization issues

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