From c3351b557d069e6a2e01a3e63af77d524d060da5 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 9 Sep 2020 10:33:51 +0100 Subject: [PATCH] add export-wp-content-db.sh --- tools/wordpress/README.md | 3 +++ tools/wordpress/export-wp-content-db.sh | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tools/wordpress/README.md create mode 100755 tools/wordpress/export-wp-content-db.sh diff --git a/tools/wordpress/README.md b/tools/wordpress/README.md new file mode 100644 index 0000000..6a978a4 --- /dev/null +++ b/tools/wordpress/README.md @@ -0,0 +1,3 @@ +Exports a local WordPress installation's database and +`wp-content/` files to a remote installation. + diff --git a/tools/wordpress/export-wp-content-db.sh b/tools/wordpress/export-wp-content-db.sh new file mode 100755 index 0000000..8a0a354 --- /dev/null +++ b/tools/wordpress/export-wp-content-db.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +remote_domain='some.cloudwaysapps.com' +remote_ssh='user@some.cloudwaysapps.com' +remote_wp_path='/home/some.cloudwaysapps.com/aabbccddee/public_html' + +local_domain='example.local' +local_wp_path='/var/www/html/wordpress' + +rsync -azP wp-content/ "$remote_ssh:$remote_wp_path/wp-content" --delete-before + +echo "DB size before:" +wp db size --ssh="$remote_ssh$remote_wp_path" +wp db export --path="$local_wp_path" --add-drop-table - | wp db import --ssh="$remote_ssh$remote_wp_path" - +echo "DB size after:" +wp db size --ssh="$remote_ssh$remote_wp_path" + +wp search-replace "$local_domain" "$remote_domain" \ + --ssh="$remote_ssh$remote_wp_path" \ + --skip-columns=guid