From 02a885fb693767423f0a061254619e3953a36806 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Wed, 16 Mar 2022 12:24:10 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20pass=20all-tables-with-prefix=20(pr?= =?UTF-8?q?ops=20@joshuafredrickson)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- README.md | 6 ++++++ sync-kinsta.sh | 12 ++++++------ sync.sh | 12 ++++++------ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d32426..76557ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### 1.2.0: March 16th, 2022 -* Add `--no-db` and `--no-assets` flags +* Add support for optionally skipping the database or assets with new flags: `--no-db` and `--no-assets` * Pass `--default-character-set=utf8mb4` to `wp db export` +* Pass `--all-tables-with-prefix` to `wp search-replace`, props @joshuafredrickson ### 1.1.0: February 21st, 2019 * Support for local development without a VM (Valet, etc). by passing `--local` at the end of the arguments diff --git a/README.md b/README.md index fe3e608..dd83911 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,12 @@ $ ./sync.sh production staging $ ./sync.sh staging production ``` +### Skipping database or assets during sync + +The `--skip-db` flag can be passed at the end of the arguments to skip syncing the database. + +The `--skip-assets` flag can be passed at the end of the arguments to skip syncing assets. + ### Local development without VM (Valet, etc.) The `--local` flag can be passed at the end of the arguments to skip using WP-CLI aliases for development. This means that you can use the sync script on a local development setup such as Valet. diff --git a/sync-kinsta.sh b/sync-kinsta.sh index fcb0bd3..7a4a12c 100755 --- a/sync-kinsta.sh +++ b/sync-kinsta.sh @@ -137,17 +137,17 @@ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then wp db export --default-character-set=utf8mb4 && wp db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp db import - && - wp search-replace "$FROMSITE" "$TOSITE" + wp search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix elif [[ "$LOCAL" = true && $FROM == "development" ]]; then wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix else wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix fi if [ "$NO_DB" = false ] @@ -157,17 +157,17 @@ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then wp db export --default-character-set=utf8mb4 && wp db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp db import - && - wp search-replace "$FROMSITE" "$TOSITE" + wp search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix elif [[ "$LOCAL" = true && $FROM == "development" ]]; then wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix else wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix fi fi diff --git a/sync.sh b/sync.sh index 7956d80..816fb57 100755 --- a/sync.sh +++ b/sync.sh @@ -134,17 +134,17 @@ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then wp db export --default-character-set=utf8mb4 && wp db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp db import - && - wp search-replace "$FROMSITE" "$TOSITE" + wp search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix elif [[ "$LOCAL" = true && $FROM == "development" ]]; then wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix else wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix fi if [ "$NO_DB" = false ] @@ -154,17 +154,17 @@ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then wp db export --default-character-set=utf8mb4 && wp db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp db import - && - wp search-replace "$FROMSITE" "$TOSITE" + wp search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix elif [[ "$LOCAL" = true && $FROM == "development" ]]; then wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix else wp "@$TO" db export --default-character-set=utf8mb4 && wp "@$TO" db reset --yes && wp "@$FROM" db export --default-character-set=utf8mb4 - | wp "@$TO" db import - && - wp "@$TO" search-replace "$FROMSITE" "$TOSITE" + wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --all-tables-with-prefix fi fi