add export-wp-content-db.sh

This commit is contained in:
Ray Elliott 2020-09-09 10:33:51 +01:00
parent c107c755fc
commit c3351b557d
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,3 @@
Exports a local WordPress installation's database and
`wp-content/` files to a remote installation.

View File

@ -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