HOWTO: recursive scp without following symbolic links

Recently I've acquired a new computer to be used as a file server. I have decided to move away from FreeNAS and switch over to a Ubuntu based desktop. Since I was using Software RAID on FreeNAS, I figured that it would be safer and easier to just copy files from FreeNAS to my new Ubuntu-based NAS over network via SCP. The problem that I've encountered with scp is that if I do a recursive copy, all the links that I've created will be followed and copied over.

Here's a solution I found that I think is great:

cd /local/destination/folder
ssh <a href="mailto:user@host">user@host</a> &quot;cd /remote/folder; tar cf - ./&quot; | tar xvf -

Now, let's look at what it does.
The first line is pretty obvious, we are changing our current folder to where we want data to be copied to.
Next line does the following:
1) SSH into your remote host
2) Change current folder into the folder that needs to be transferred over
3) tar that folder. Please note that '-' means that instead of archiving into a file, archive is written to stdin/stdout. Then, we are going to send that archive to be decompressed on the local machine

Personally, I think that this approach is great!

If you have any comments or suggestions, I'm all ears!

Comments