Pages

September 22, 2025

Copying files over a network with rsync

I thought I had found a good solution to copying files over a network with scp, but it turns out that utility doesn't copy symlinks as symlinks. Rather, it replaces the symlink with a copy of the content.

 Fortunately, rsync can be used for this. The magic invocation is:

rsync -r -t -p -v --progress -l -s -e ssh {username}@{address}:'//home/foo/Documents/myDir' /home/bar/Documents


The options are as follows:

-r: recurse into directories

-t: preserve modification times

-p: preserve permissions

-v: increase verbosity

--progress: show progress during transfer

-l: copy symlinks as symlinks

-s: no space-splitting; wildcard chars only

-e: specify the remote shell to use (ssh in the above)

You can also get this done with grsync. In fact, I got the above command line by examining grsync's output. The gotcha here is that you need to be able to access the source account without a password. rsync will prompt you for a password if necessary.

No comments: