From 88d2314a8c471c093f924697829390453020d576 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 9 Sep 2020 11:50:37 +0100 Subject: [PATCH] wip --- tools/wordpress/export-wp-content-db.sh | 18 +++++++++++----- tools/wordpress/import-wp-content-db.sh | 28 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100755 tools/wordpress/import-wp-content-db.sh diff --git a/tools/wordpress/export-wp-content-db.sh b/tools/wordpress/export-wp-content-db.sh index 8a0a354..e196b70 100755 --- a/tools/wordpress/export-wp-content-db.sh +++ b/tools/wordpress/export-wp-content-db.sh @@ -1,13 +1,15 @@ #!/bin/sh -remote_domain='some.cloudwaysapps.com' -remote_ssh='user@some.cloudwaysapps.com' -remote_wp_path='/home/some.cloudwaysapps.com/aabbccddee/public_html' +remote_protocol='https' +remote_domain='wordpress-453075-1468300.cloudwaysapps.com' +remote_ssh='test123@wordpress-453075-1468300.cloudwaysapps.com' +remote_wp_path='/home/453075.cloudwaysapps.com/mhhusspndh/public_html' -local_domain='example.local' +local_protocol='http' +local_domain='thecampsitebible.home' local_wp_path='/var/www/html/wordpress' -rsync -azP wp-content/ "$remote_ssh:$remote_wp_path/wp-content" --delete-before +rsync -azP "$local_wp_path/wp-content/" "$remote_ssh:$remote_wp_path/wp-content" --delete-before echo "DB size before:" wp db size --ssh="$remote_ssh$remote_wp_path" @@ -15,6 +17,12 @@ wp db export --path="$local_wp_path" --add-drop-table - | wp db import --ssh="$r echo "DB size after:" wp db size --ssh="$remote_ssh$remote_wp_path" +wp search-replace "$local_protocol://$local_domain" "$remote_protocol://$remote_domain" \ + --ssh="$remote_ssh$remote_wp_path" \ + --skip-columns=guid + --quiet + wp search-replace "$local_domain" "$remote_domain" \ --ssh="$remote_ssh$remote_wp_path" \ --skip-columns=guid + --quiet diff --git a/tools/wordpress/import-wp-content-db.sh b/tools/wordpress/import-wp-content-db.sh new file mode 100755 index 0000000..ad8e42d --- /dev/null +++ b/tools/wordpress/import-wp-content-db.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +remote_protocol='https' +remote_domain='wordpress-453075-1468300.cloudwaysapps.com' +remote_ssh='test123@wordpress-453075-1468300.cloudwaysapps.com' +remote_wp_path='/home/453075.cloudwaysapps.com/mhhusspndh/public_html' + +local_protocol='http' +local_domain='thecampsitebible.home' +local_wp_path='/var/www/html/wordpress' + +rsync -azP "$remote_ssh:$remote_wp_path/wp-content/" "$local_wp_path/wp-content" --delete-before + +echo "DB size before:" +wp db size --path="$local_wp_path" +wp db export --ssh="$remote_ssh$remote_wp_path" --add-drop-table - | wp db import --path="$local_wp_path" - +echo "DB size after:" +wp db size --path="$local_wp_path" + +wp search-replace "$remote_protocol://$remote_domain" "$local_protocol://$local_domain" \ + --path="$local_wp_path" \ + --skip-columns=guid \ + --quiet + +wp search-replace "$remote_domain" "$local_domain" \ + --path="$local_wp_path" \ + --skip-columns=guid \ + --quiet