0
votes

I want to copy a directory from remote machine to local using rsync, but without some inner folders.

I'm using this command:

rsync -rave --exclude 'js' --exclude 'css' --exclude 'fonts' root@{IP}:/rem_dir1/rem_dir2/public /local_dir1/local_dir2/public

But result of it is:

Unexpected remote arg: root@{IP}:/rem_dir1/rem_dir2/public
rsync error: syntax or usage error (code 1) at main.c(1361) [sender=3.1.2]

I'm sure remote root is correct. So the problem is in rsync command syntax.

What is the correct way to exclude several folders using rsync?

For example we have /public folder which contains dir1, dir2, dir3, dir4 and dir5. How to copy only dir1 and dir2 from /public?

1

1 Answers

0
votes

As with your other question, the -rave makes no sense. You want just -av.

You can get fancy with include and exclude commands, but the easiest way to copy just two directories is just to list them:

rsync -av \
    root@{IP}:/rem_dir1/rem_dir2/public/dir1 \
    root@{IP}:/rem_dir1/rem_dir2/public/dir2 \
    /local_dir1/local_dir2/public/

where \ is just line-continuation (so I can wrap the long line), and I deliberately only added / to the end of the destination path, not the source paths.