We all know it’s important to frequently backup the most important files & website data to your backup server. Rsync is a powerful backup tool to keep your files backed up on a chosen server or even on your local PC. By running default rsync command, all newly created and modified data will be copied and sync with a backup server.

However, in many situations Rsync software will sync all temporarily created files. Which means, all tmp, cache, imagecache, and other folders with their entries will be stored on your chosen location and eat much of your hard disk space.

Commands to Exclude Folders from Being Synced

In our case we will test commands with imaginary folders named;wordpress, cache, imagecache and cachedir.

1. Exclude a specific folder:

rsync -avz --exclude=cache/ /home/wpfreaks/public_html/testfolder/ wpfreaks@backupserver.com:server

Transferred directories and their content: wordpress, imagecache and cachedir
Ignored directories and their content: cache

2. Exclude all directories that contain cache, using a wildcard:

rsync -avz --exclude=*cache*/* /home/wpfreaks/public_html/testfolder/ wpfreaks@backupserver.com:server

Rsync Exclude Folders
Transferred directories and their content: wordpress
Ignored directories and their content: cache, imagecache and cachedir

In the recent example you can see how to exclude all cache folders from being copied to the backup location.

One Comment

  1. Thanks. Now I can run backups with no junk (temporary files) being copied to my second server.

Related Posts