Skip to content

Instantly share code, notes, and snippets.

@zingbretsen
Created September 29, 2021 09:13
Show Gist options
  • Save zingbretsen/105d740e3bf9869bc7aa79d1a1319e84 to your computer and use it in GitHub Desktop.
Save zingbretsen/105d740e3bf9869bc7aa79d1a1319e84 to your computer and use it in GitHub Desktop.
Includes and excludes in rsync
set -eux
# Copies whole src dir into dest
rsync -avz src dest/
# Copies content of src dir into dest
rsync -avz src/ dest/
# Copies all files/directories except those specified exactly or with wildcard
rsync -avz --exclude='.gitignore' --exclude='*csv' --exclude='d2' src/ dest/
# Copies only .txt files
# Includes all directories, includes .txt files, then excludes all else
rsync -avz --include='*/' --include='*txt' --exclude='*' src/ dest/
# Copies nothing
# Order of arguments matters. This excludes all files at the start
# and so nothing is copied
rsync -avz --exclude='*' --include='*/' --include='*txt' src/ dest/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment