Compare commits
No commits in common. "fad8de9d4ecd5b5b6234c813c5502ca6b96e9b31" and "e15ab61d298e64daeda2867ee6d92bf7f3e58948" have entirely different histories.
fad8de9d4e
...
e15ab61d29
20
pull-from.sh
20
pull-from.sh
|
@ -1,23 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
_target="$1"
|
|
||||||
|
|
||||||
if ! [ "$_target" = local ] && ! [ "$_target" = remote ] ; then
|
|
||||||
echo "Error: must specify 'local' or 'remote' target"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Loading $_target configuration"
|
|
||||||
|
|
||||||
# source our config files
|
|
||||||
for _file in ./config/$_target/* ; do
|
|
||||||
[ -e "$_file" ] || continue
|
|
||||||
. "$_file"
|
|
||||||
done
|
|
||||||
|
|
||||||
# check we have ssh access
|
|
||||||
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
|
|
||||||
|
|
||||||
if [ -n "$wp_user" ] ; then
|
|
||||||
. ./scripts/export-wp.sh
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,29 +1,75 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Exporting from $url .."
|
. ./config
|
||||||
|
|
||||||
_timestamp="$(date +%s)"
|
if [ "$1" = 'local' ] ; then
|
||||||
_db_filename="wordpress-$_timestamp.db"
|
src_url="$local_url";
|
||||||
_archive_filename="wordpress-$_timestamp.tar.gz"
|
dest_url="$remote_url";
|
||||||
_local_dest_dir="./data/$_target"
|
src_ssh="$local_ssh"
|
||||||
|
dest_ssh="$remote_ssh"
|
||||||
|
elif [ "$1" = 'remote' ] ; then
|
||||||
|
src_url="$remote_url";
|
||||||
|
dest_url="$local_url";
|
||||||
|
src_ssh="$remote_ssh"
|
||||||
|
dest_ssh="$local_ssh"
|
||||||
|
else
|
||||||
|
echo "error: must specify local or remote"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
ssh -T $ssh << EOSSH
|
db_file="$wp_path/data.sql"
|
||||||
cd "$wp_path"
|
tar_file="/tmp/wordpress.tar.gz"
|
||||||
|
|
||||||
|
############## source
|
||||||
|
|
||||||
|
ssh -T $src_ssh << EOSSH
|
||||||
wp db export \
|
wp db export \
|
||||||
--path="$wp_path" \
|
--path="$wp_path" \
|
||||||
--dbuser="$wp_db_user" \
|
--dbuser="$wp_db_user" \
|
||||||
--dbpass="$wp_db_pass" \
|
--dbpass="$wp_db_pass" \
|
||||||
--add-drop-table \
|
--add-drop-table \
|
||||||
--allow-root \
|
--allow-root \
|
||||||
"/tmp/$_db_filename"
|
"$db_file"
|
||||||
tar czf "/tmp/$_archive_filename" "$wp_path"
|
tar czf "$tar_file" "$wp_path"
|
||||||
EOSSH
|
EOSSH
|
||||||
|
|
||||||
scp "$ssh:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
|
scp "$src_ssh:$tar_file" "$tar_file"
|
||||||
scp "$ssh:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
|
|
||||||
|
|
||||||
exit
|
ssh -T $src_ssh << EOSSH
|
||||||
ssh -T $ssh << EOSSH
|
rm "$db_file"
|
||||||
rm "/tmp/$_db_filename"
|
rm "$tar_file"
|
||||||
rm "/tmp/$_archive_filename"
|
|
||||||
EOSSH
|
EOSSH
|
||||||
|
|
||||||
|
############## destination
|
||||||
|
|
||||||
|
scp "$tar_file" "$dest_ssh:$tar_file"
|
||||||
|
|
||||||
|
ssh -T $dest_ssh << EOSSH
|
||||||
|
rm -Rf "$wp_path"
|
||||||
|
cd /
|
||||||
|
tar xzf "$tar_file"
|
||||||
|
|
||||||
|
wp db import \
|
||||||
|
--path="$wp_path" \
|
||||||
|
--dbuser="$wp_db_user" \
|
||||||
|
--dbpass="$wp_db_pass" \
|
||||||
|
--allow-root \
|
||||||
|
"$db_file"
|
||||||
|
rm "$db_file"
|
||||||
|
rm "$tar_file"
|
||||||
|
wp search-replace \
|
||||||
|
--path="$wp_path" \
|
||||||
|
--allow-root \
|
||||||
|
--skip-columns=guid \
|
||||||
|
"$src_url" \
|
||||||
|
"$dest_url"
|
||||||
|
wp option update home \
|
||||||
|
--path="$wp_path" \
|
||||||
|
--allow-root
|
||||||
|
wp option update home \
|
||||||
|
--path="$wp_path" \
|
||||||
|
--allow-root
|
||||||
|
EOSSH
|
||||||
|
|
||||||
|
|
||||||
|
mv "$tar_file" ./wordpress-"$(date +%s)".tar.gz
|
||||||
|
|
Loading…
Reference in New Issue