You don't need the **
and for a single pattern you might as well just use --exclude
. The --include
pattern ensures that directories matching the --exclude
pattern are included in the copy.
rsync -a --include '*/' --exclude='.*.swp' /home/username/Documents/ remotehost:/home/username/Documents/
If your remote username has /home/username
as its home directory you can further simplify with a relative path:
rsync -a --include '*/' --exclude='.*.swp' /home/username/Documents/ remotehost:Documents/
Bear also in mind that vim
will use other filenames for its swap file if one matching *.swp
already exists or is in use. But you'll catch most of them with this single pattern. Here's what the documentation warns:
If this file already exists (e.g., when you are recovering from a crash) a
warning is given and another extension is used, ".swo", ".swn", etc.
You could adapt the exclusion pattern to use .*.sw[a-p]
if you were sufficiently concerned.
--exclude=
expect the patters themselves.--exclude-from=
is how you specify the file that has patterns into it. Also, why are you using **.swp instead of *.swp?