trellis-sync icon indicating copy to clipboard operation
trellis-sync copied to clipboard

"The source and destination cannot both be remote."

Open strarsis opened this issue 8 years ago • 5 comments
trafficstars

Transferring the database dump and replacements work well, but transferring the uploads/ folder between the two servers results in this error message:

[...]
Success: Made 16 replacements.
The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1279) [Receiver=3.1.1]

strarsis avatar Jun 13 '17 13:06 strarsis

What option did you choose assuming you are using synch all? Could be that staging to production has to particular error. Or that the local directory always needs to be the local box.. And in that case we may have to change the questions/options for uploads.

jasperf avatar Jun 13 '17 13:06 jasperf

Currently using the non-global script (but same code):

./wp-cli-transfer.sh production staging
#!/bin/bash

DEVDIR="web/app/uploads/"
DEVSITE="http://dev:8085"

PRODDIR="web@production:/srv/www/example.com/shared/uploads/"
PRODSITE="https://www.example.com"

STAGDIR="web@staging:/srv/www/example.com/shared/uploads/"
STAGSITE="http://staging.example.com"

FROM=$1
TO=$2

case "$1-$2" in
  development-production) DIR="up";  FROMSITE=$DEVSITE;  FROMDIR=$DEVDIR;  TOSITE=$PRODSITE; TODIR=$PRODDIR; ;;
  development-staging)    DIR="up";   FROMSITE=$DEVSITE;  FROMDIR=$DEVDIR;  TOSITE=$STAGSITE; TODIR=$STAGDIR; ;;
  production-development) DIR="down"; FROMSITE=$PRODSITE; FROMDIR=$PRODDIR; TOSITE=$DEVSITE;  TODIR=$DEVDIR; ;;
  production-staging)     DIR="horizontally"; FROMSITE=$PRODSITE; FROMDIR=$PRODDIR; TOSITE=$STAGSITE; TODIR=$STA$
  staging-development)    DIR="down"; FROMSITE=$STAGSITE; FROMDIR=$STAGDIR; TOSITE=$DEVSITE;  TODIR=$DEVDIR; ;;
  *) echo "usage: $0 development production | development staging | production development | production staging $
esac

read -r -p "Would you really like to reset the $TO database and sync $DIR from $FROM? [y/N] " response

if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
  #cd ../ &&
  wp "@$TO" db export &&
  wp "@$FROM" db export - | wp "@$TO" db import - &&
  wp "@$TO" search-replace "$FROMSITE" "$TOSITE" --skip-columns=guid &&
  rsync -F -az --progress "$FROMDIR" "$TODIR"
fi

I can SSH into web@staging and web@production.

strarsis avatar Jun 13 '17 14:06 strarsis

Yeah, with current setup both destinations cannot be remote as rsync commands assumes you run things locally. We will need to adjust the rsync command to ssh in when need be. See also https://serverfault.com/a/449717/101547 . So if $FROMDIR is DEV or PROD SSH in and then rsync. When I have time and some luck I will update the code. Thanks for reporting @strarsis

jasperf avatar Jun 13 '17 14:06 jasperf

@jasperf: Yes, this would be great because then I can sync back directly from production to staging.

strarsis avatar Jun 16 '17 23:06 strarsis

Working on a new branch here to see if I can do this with an embedded conditional. Not tested yet as I need to think about it all some more.

jasperf avatar Jun 17 '17 04:06 jasperf