When we are migrating a site, rsync is our friend. Let's get intimate and hands on with file synchronization.
...
Note that the slash appears on the source, but not the target destination.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ drush rsync @mysite.dev:%files/images/ @mysite.local:%files/images |
Here, we pull down all files from live to local, but exclude drupal's private files
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ drush rsync --exclude=private @mysite.live:%files/ @mysite.local:%files |
...
Drush has some option flags of its own we can send to test operations before committing. In this case we are going from our local to staging:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ drush --simulate --debug rsync --mode=razoglp @sitename.local:%files/images/ @sitename.staging:%files/images |
...
Drush provides the ability to leverage parts of rsync, but will not easily exclude files based on patterns. We can exclude paths, however:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ drush rsync -y --mode=razog --exclude-paths=%files/private:%files/css:%files/js:%files/styles:%files/ctools:%files/backup_migrate @mysite.localdev:%files/ @mysite.devlocal:%files/ |
Using native rsync for full control of file transfers
...
Here is a verbose exclude list using straight rsync:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ rsync -razv --delete --exclude=css --exclude=*_cache --exclude=js --exclude=googleanalytics --exclude=xmlsitemap \ --exclude=backup_migrate user@domain.com:/path/to/remote/files/ \ /path/to/local/files/ |
...
These greatly simplify logging in via SSH. Now, instead of
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ ssh -p 2222 username@test.mysite.com |
you can simply do:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ ssh mysite.test |
-e 'ssh -axp 1022'
By default, symbolic links are not transferred at all.
...
Here are files and directories to exclude from drupal's files directory.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
css civicrm ctools js googleanalytics xmlsitemap backup_migrate tmp .DS_Store .DS_Store* .sass-cache ehthumbs.db Icon? Thumbs.db ._* *.bak *_cache *.tgz *.un~ .buildpath .project .settings *.sublime-project *.sublime-workspace *.sublime-projectcompletions nbproject |
...