0

I have a server that has a bunch of csv files that get updated periodically, /home/peter/data/*.csv.

I want my local files to be in sync with remote. In my ssh config, I have the correct username and host set.

I've already tried using scp. Currently I'm trying:

rsync -e "ssh remote" -v --include='~/dat/*.csv'--include='*/' --exclude='*' . .

This does nothing. I get:

skipping directory .

None of the files get updated.

1

When rsync is not doing a recursive file transfer (-r is not used), it will refuse to transfer directories.

Instead:

rsync -v remote:'data/*.csv' ./

This will copy all the .csv files from the data directory in your home directory on the machine called remote. The files will be transferred to the current directory on the local host.

To set the permissions, timestamps, etc., on the files locally as they are set on the remote files, add the --archive (-a) option:

rsync -va remote:'data/*.csv' ./

The -a flag implies -r and a bunch of other flags (-rlptgoD), but the -r flag is not really used here since you're getting files from a single directory. To use the specific flags that sets local permissions and timestamps, use --perms (-p) together with --times (-t) instead.

0

According to man rsync you need the -a flag

-a, --archive  archive mode; equals -rlptgoD (no -H,-A,-X)

rsync -e "ssh remote" -av ....

details

-r, --recursive             recurse into directories
-l, --links                 copy symlinks as symlinks
-p, --perms                 preserve permissions
-t, --times                 preserve modification times
-g, --group                 preserve group
-o, --owner                 preserve owner (super-user only)
-D, --devices --specials    preserve devices and special files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.