SCP & RSYNC

scp

The scp (secure copy) command allows the user to to copy files (or folders) to or from a remote computer. To copy a file from the remote computer, use the following whilst logged into the local computer:

scp user@marble.earthsci.unimelb.edu.au:/path/to/source /path/to/destination

To copy a directory (copy recursively) from a local computer to a remote computer, use the following whilst logged into the local computer:

scp -r /path/to/source user@marble.earthsci.unimelb.edu.au:/path/to/destination

Normal access users will only be able to copy to (i.e. have write access) to their home directories (e.g. /home/STUDENT/user/), but will be able to read from the /data/marble/ directories.

This can be made easier to use by using key pairs and ssh alias’s (see tips & tricks).

rysnc

rsync is similar tool that synchronizes files and folders from one location to another. It only sends the file deltas (that is, the differences between the source between the source files and the destination files) and supposedly transfers large numbers of files faster and more efficiently.

The syntax for rsync is similar to scp. E.g.:

rsync -r /path/to/source user@marble.earthsci.unimelb.edu.au:/path/to/destination

As for scp, the r option copies file recursively. Other useful option are -a (archive mode), -v (increase verbosity, i.e. to see what it is doing) and -z to compress file data (see link above for more options). And similar to scp, rsync can also be made easier to use by using key pairs and ssh alias’s (see tips & tricks)

Options for running rsync are, e.g. -avr, where “a” stands for “archiving”, i.e. copying timestamps and permissions across, “v” stands for “verbose” so that you see on the screen, what rsync is doing, and “r” stands for “recursive”, which then copies across all folders, their contents, i.e. everything in lower hierarchies…

The other option is –dry-run, which is a good idea to check what rsync will be actually doing… rsync will then display all the files that it will copy.