I ran into an issue today where I wanted to copy some files from my laptop to the web server.
Usually, I just run the scp command like so:
scp -r /path/to/files/on/laptop/ [email protected]:/path/to/put/files/
This will copy all of the files without problems.
The problem is that there were nearly 300 files to copy, and so I left the laptop to do the copy. In the meantime, it went to sleep, stopping the copy. Scp is not smart enough to just copy the files that didn’t get copied, but will copy all nearly 300 files again.
There is a program that has this intelligence, though… rsync !
Run this command like so:
rsync -avz /path/to/files/on/laptop/ -e ssh [email protected]:/path/to/put/files/
This usually works great… except when there are umlauts in the file names. Apparently Macs and Linux use a different terminology when talking UTF-8.
The default Mac version of rsync is woefully out of date, though, and doesn’t support an option to fix this issue.
The solution!
You’ll need to have homebrew installed in order to update to the latest version of rsync. If you don’t have homebrew installed already, you need to.
Then it’s a simple install command:
brew install rsync
And now you can do the rsync command again:
rsync -avz --iconv=UTF8-MAC,UTF-8 /path/to/files/on/laptop/ -e ssh [email protected]:/path/to/put/files/
The –inconv option allows Mac and Linux to speak the same UTF-8 language.
Special thanks to Janak Singh for the rsync option and detailed information on the issue.
Update: December 9, 2014.
There were some issues with the umlauts on the Linux server, and with the names of the files as I put them into Omeka, so I decided to do away with the special characters altogether. But how to change all of the file names? Easy, use the rename command.
On the Linux server it was easy as:
rename ü ue *.png
on the Mac I needed to install the rename command with homebrew first:
brew install rename
The syntax is a little bit different on the Mac:
rename -s ü ue *.png
You can also do a dry run to make sure it the command doesn’t do something you don’t like.
rename -n -s ü ue *.png
That takes care of the special characters issue.