Montag, 25. Januar 2016

rsync: Sync Two Folders via SSH in Both Directions

After started writing about rsync from local to live. Here's a post about syncing in two directions.

Helpful in rsync is, that also the permissions- and owner information is transfered ("-a" parameter). The "--progress" parameter shows the progress and "--exclude" allows to exclude directories. Be carefully about "--delete". Mind hidden folders like ".git" and ".vagrant" etc.

SSH session on local system (developer desktop) to sync files from (stage/live) server to local system

Here we assume you are in a ssh session on your local development environment and you want to sync from the stage/live server to your local development environment.
rsync -a source/ destination-host:/destination-directory/
Example:

rsync -a --progress www/ --exclude=sites/default/files/ --exclude=.idea/ --exclude=.vagrant/ --exclude=provisioning/ --exclude=.git ssh-username@host.com:/srv/www/destination-folder/

From (stage/live) server to local system (developer desktop)

Here we assume you are in a ssh session on your stage/live server and you want to sync from your local development environment to stage/live server.

Example:
rsync -chavzP --stats --progress username@host.com:/srv/www/some-folder/ /var/www/some-folder/

explainshell.com 

Detailed explanation for the commands can be found at explainshell.com. The rsync command above is explained here.

Happy syncing.


Sonntag, 24. Januar 2016

Drush: Rebuild the cache of a single Drupal (8) site in a multi-site setup with the magic "-l" parameter

After lots of googling, testing, reading and so on, I've finally found out the Drush command to flush the cache of a single Drupal (8) site in a multi-site setup.

drush -l 8888.notes cache-rebuild
If your site is located at /sites/8888.notes you need the command above. The "-l" parameter is necessary. I could not find out what "-l" means, but this parameter seemed necessary. 

Sonntag, 17. Januar 2016

GitHub not accepting public SSH key: fix it by switching from HTTP(S) to SSH in the Git repository config

If you clone a Git repository from GitHub via the HTTPS URL, which is placed in the section as shown below, than your public SSH key will not be recognized by GitHub.

You can test your public SSH key for GitHub usage by the following command:
ssh -T git@github.com

If you have chosen the wrong HTTPS option before (it must be SSH), you can fix that by the following steps.
  1. Open the file at .git/config
  2. Look for 
    url = http://github.com/path/to/repository 
    or url = https://github.com/path/to/repository
  3. Replace it by
    url = ssh://git@github.com/path/to/repository
  4. Save the file and GitHub will accept the public SSH key on the next push. No username and password typing anymore.


Freitag, 8. Januar 2016

Fix Line Endings Between Various File Systems

If you work sometimes on Windows, sometimes on Mac and sometimes on Linux, you can get troubles with line endings. Programs which aren't smart enough to detect line endings by them self, will display the text as if the file contained no line breaks at all.

  • Windows, and DOS before uses a pair of CR and LF characters to terminate lines
  • UNIX (Including Linux and FreeBSD) uses an LF character only. 
  • OS X also uses a single LF character 
  • Classic Mac operating system used a single CR character for line breaks. 
That's tricky. A tool for fixing line endings is "SFK - The Swiss File Knife File Tree Processor". It's mentioned at http://stackoverflow.com/questions/7068179/convert-line-endlings-for-whole-directory-tree-git/16886243#16886243.

All you have is to use the following command for converting to Mac OSX:
sfk remcr -dir your_project_directory

The project homepage is at http://stahlworks.com/dev/index.php?tool=remcrlf