diff --git a/config/remote/cloudways b/config/remote/cloudways index c16651d..d597903 100644 --- a/config/remote/cloudways +++ b/config/remote/cloudways @@ -4,5 +4,8 @@ cloudways_user='cloudways@rayelliott.dev' cloudways_url='https://wordpress-453075-1468300.cloudwaysapps.com' + +cloudways_ssh='test123@wordpress-453075-1468300.cloudwaysapps.com' + cloudways_db_name='mhhusspndh' cloudways_db_user='mhhusspndh' diff --git a/export-to-remote.sh b/export-to-remote.sh deleted file mode 100755 index e69de29..0000000 diff --git a/import-from-remote.sh b/import-from-remote.sh deleted file mode 100755 index e69de29..0000000 diff --git a/pull-from.sh b/pull-from.sh new file mode 100755 index 0000000..829303e --- /dev/null +++ b/pull-from.sh @@ -0,0 +1,3 @@ +#!/bin/sh + + diff --git a/push-to.sh b/push-to.sh new file mode 100755 index 0000000..829303e --- /dev/null +++ b/push-to.sh @@ -0,0 +1,3 @@ +#!/bin/sh + + diff --git a/scripts/export-wp.sh b/scripts/export-wp.sh new file mode 100755 index 0000000..dc74d41 --- /dev/null +++ b/scripts/export-wp.sh @@ -0,0 +1,75 @@ +#!/bin/sh + +. ./config + +if [ "$1" = 'local' ] ; then + src_url="$local_url"; + dest_url="$remote_url"; + 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 + +db_file="$wp_path/data.sql" +tar_file="/tmp/wordpress.tar.gz" + +############## source + +ssh -T $src_ssh << EOSSH +wp db export \ + --path="$wp_path" \ + --dbuser="$wp_db_user" \ + --dbpass="$wp_db_pass" \ + --add-drop-table \ + --allow-root \ + "$db_file" +tar czf "$tar_file" "$wp_path" +EOSSH + +scp "$src_ssh:$tar_file" "$tar_file" + +ssh -T $src_ssh << EOSSH +rm "$db_file" +rm "$tar_file" +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 diff --git a/scripts/import-wp.sh b/scripts/import-wp.sh new file mode 100755 index 0000000..829303e --- /dev/null +++ b/scripts/import-wp.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +