Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
- Current (Drush9+) aliases are described in Site aliases - Drush Docs and example.site.yml
- Old Drush8 aliases are descrbed in Drush GitHub repo (version 8.x).
.
Comments
Get the correct alias configuration of each server
You can use this command on the command line of the server to show the correct configuration and add this to the alias.drushrc file.
drush site-alias @self --full --with-optional
You get something like this, you can paste to your aliases file and change with your own alias like "local", "dev" or "prod".
Added
Added to the comment at the heading. Thanks!
How to pull files outside drupal directory
Hi,
How to pull files outside drupal path (example: /root/folder1 and /root/folder2) from a remote server to a local server.
Thank you.
Use rsync
You can use rsync to sync files down, either through drush or manually.
To rsync files down with drush:
drush rsync @sitename.prod:/path/to/files /path/to/local/destination
Using SSH only
If your server does not allow password authentication, try being explicit with your ssh key in your alias file:
Missing php tags for command
The command mentioned:
drush site-alias @self --full --with-optional >> ~/.drush/mysite.aliases.drushrc.php
This won't work because the php tags are missing
<?php ?>
in the mysite.aliases.drushrc.php file.This should work. You will
This should work. You will still need to edit it and change 'self' to another alias.
echo '<?php' > ~/.drush/mysite.aliases.drushrc.php && drush --root=/var/www/docroot site-alias @self --full --with-optional >> ~/.drush/mysite.aliases.drushrc.php
Missing php tags
Thanks for that. Sometimes it easy to forget the obvious. I couldn't figure out why it wasn't working. Much appreciated.
Very cool, thanks
Got here from Google, appreciated the quick knowledge drop, helped me out with a CircleCI Integration script I am writing. Awesome! Thank you!
Drush 9 changed to YAML
Due to the upgrade of my site from Drupal 8.3.7 to 8.4, I had to upgrade to drush 9. Found that Drush 9 doesn't use yoursite.aliases.drushrc.php anymore and you have to define your alias using a YAML configuration file.
To help the migration, you can run
drush site:alias-convert
which will convert your old aliases.drushrc.php into aliases.alias.yml.Here is an example file: https://raw.githubusercontent.com/drush-ops/drush/master/examples/example.aliases.yml
drush site:alias-convert does nothing.
"you can run drush site:alias-convert which will convert your old aliases.drushrc.php into aliases.alias.yml."
Doesn't work for me:
Existing aliases (for ALL my instances locally, so I don't have to manage them separately) located at "/Users/USERNAME/.drush/aliases.drushrc.php"
My CWD is '/Users/USERNAME/.drush/'.
It creates an empty '/Users/USERNAME/.drush/sites' folder, migrates nothing.
re: the example file ... where does one put a "single site" version of this file? In a project's drush folder? In the docroot/web 'sites' folder?
I'm not entirely clear on how to implement per-site alias files by hand, was hoping the alias-convert command would do it for me.
Thanks for any insight anyone can give. I feel I must be doing something wrong, here, or missing something obvious.
My experience with Drush D9 aliases convert
@ccshannon, it's been some time since I tested it, but I can give you some tips about how it should work.
I have a D8 site installed on /var/www/d8-project. Into this folder I have a drush folder with an aliases.drushrc.php, then the full path is /var/www/d8-project/drush/aliases.drushrc.php
My aliases.drushrc.php contains:
After upgrading to Drush 9 and running the drush site:alias-convert command, I found that it created a new folder site-aliases into the drush folder, with a d8-project.alias.yml file containing:
As you can see, what the command simply does, is to take all your defined aliases and generate a new YAML file with them.
Can't give you more details, but apparently your problem seems to be that the aliases.drushrc.php is not parsed properly or directly not found.
Thanks, man!
Thanks so much for that, @japicoder! This is very helpful for being able to construct an alias without the converter! :)
Just FYI for anyone having my issue, I figured out why my attempts yielded no results ... I typically store ALL my site aliases in one file (~/.drush/aliases.drushrc.php) on my local so I can control these from one place ... but the site:alias-convert command is not looking for a file with that name ... it is looking for *.aliases.drushrc.php, meaning there has to be a root name.
Here's what I did ... I copied my aliases.drushrc.php file to "bob.aliases.drushrc.php" (just random 'GROUPNAME') as detailed in the drush alias file documentation.
Then I ran:
drush site:alias-convert --sources=~/.drush
and it spit out one new alias file per site as listed in the 'bob' file -- e.g. "mysite.site.yml"! :)
Note, it also spit out a bob.site.yml (there is no bob site; it's just a made up groupname) which is empty and throws an exception when running "drush sa" against it. I just deleted that yml file.
My issue here now is ... even though this is great for when I am using my site's project folder as CWD (because I have placed the new *.site.yml file in my project/drush/sites folder) I work on enough projects at once that I like using the aliases for when I am NOT cd'd into a particular project, but want to run drush commands for it. Again, this is not for higher environments like dev/staging/production, where it makes sense to have each project have its own set of alias files. This is just my local system where I do a lot of experimenting and build/destroy lots of drupal instances.
The drush alias documentation talks of drush reading the central drush.yml file for aliases (on my system that is located at ~/.composer/vendor/drush/drush/drush.yml) before looking in the local drush/sites/ location. I'm not sure how to update it properly, but really that's not a blocker, just more a personal preference.
I'm all good now! Thanks!!!
Per Project Setup
I can see why you'd like to have a central repository for all your Drush aliases, especially if you don't do a lot of collaborative work. In case you may, at some time in the future, it may be good to move aliases to their respective projects.
One thing I didn't see that well-documented was that each alias now requires its own file.
Is it not the cae
hi @karolus
Is it not the case here?
of course this drush alias file is for one projet that has multiple environment stage, dev,prod