↑ ↓ select, Enter open, Esc close

rsync with excluded directories and files

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
rsync -av --exclude='wp-content/cache/' --exclude='*.log' /var/www/vhosts/example.com/httpdocs/ /backup/example.com/httpdocs/

Each --exclude skips paths or files that match the pattern. A pattern containing a slash is matched against the path relative to the source, a pattern without a slash such as *.log against every file name. A trailing slash restricts the pattern to directories.

Note: Many excludes can be written to a text file (one pattern per line) and loaded with --exclude-from=DATEI. Test with --dry-run first.

Also searched as

  • rsync exclude directory
  • skip cache folder in backup
  • rsync exclude example
  • do not copy certain files

Related one-liners

All in rsync and backup

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.