0

I'm trying to sync two D8 sites. Both set up with drupal composer which means that the directory structure is a bit different than usual. Composer puts drupal files inside web sub directory like this:

/var/www/drupal8
|-- composer.json
|-- composer.lock
|-- drush
|-- scripts
|-- vendor
`-- web
    |-- autoload.php
    |-- core
    |-- index.php
    |-- modules
    |-- profiles
    |-- robots.txt
    |-- sites
    |-- themes
    |-- update.php
    `-- web.config

My aliases file looks like this:

<?php

$aliases["local"] = array (
  'root' => '/var/www/drupal8/web/',
  'uri' => 'http://local.site',
);

$aliases["remote"] = array (
  'root' => '/var/www/drupal8/web/',
  'uri' => 'http://site.example.com',
  'remote-user' => 'dev',
  'remote-host' => 'site.example.com',
);

When I do drush rsync @remote @local I end up with all files from @remote/web inside @local/web/web like this:

/var/www/drupal8
|-- composer.json
|-- composer.lock
|-- drush
|-- scripts
|-- vendor
`-- web
    |-- autoload.php
    |-- core
    |-- index.php
    |-- modules
    |-- profiles
    |-- robots.txt
    |-- sites
    |-- themes
    |-- update.php
    |-- web
        |-- autoload.php
        |-- core
        |-- index.php
        |-- modules
        |-- profiles
        |-- robots.txt
        |-- sites
        |-- themes
        |-- update.php
        `-- web.config
    `-- web.config

I can't edit aliases to remove web sub dir from root path because then drush will not work as it will complain that it needs a higher bootstrap level to run (because it won't know where is drupal root folder).

How can I instruct drush to use proper destination path for synchronisation?

2 Answers 2

1

I had the same problem took me ages to find out what was wrong. Turned out to be the slash (/) behind the root folder that was missing.

self.site.yml


remote:
  host: domain.com
  user: user
  root: /home/user/public_html/
  uri: http://domain.com

@see https://unix.stackexchange.com/questions/402555/why-add-a-trailing-slash-after-an-rsync-destination

Turned out to be a bug in drush https://github.com/drush-ops/drush/pull/3405

0

I cannot reproduce this problem. What version of Drush are you using? What version of rsync, on what OS?

I created temporary aliases for two sites, and set their root directory to /tmp/a and /tmp/b, respectively. I just put a couple of test files in /tmp/a.

$ tree /tmp/a
/tmp/a
├── composer.json
└── web
    └── index.php

1 directory, 2 files
$ drush rsync @tmp.a @tmp.b
You will delete files in /tmp/b/web/ and replace with data from /tmp/a/web//
Do you really want to continue? (y/n): y
$ tree /tmp/b
/tmp/b
└── web
    └── index.php

1 directory, 1 file

This behaves as expected.

I also did another test, using a remote alias as the source, and received similar results.

If you would like to see exactly what parameters Drush is using to call rsync, add the -s flag to the command line:

drush -s rsync @remote @local

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.