rsync excluding folders

From WebHostingNeeds.com
Jump to: navigation, search

Exclude Multiple Folders

rsync -avz "-e ssh -p 3333" --exclude={dn,backup}  /home/ [email protected]:/backup/s12/home/

This command will rsync all folders in /home to /backup/s12/home/ on remote server. It will exclude folders /home/dn and /home/backup


Note: the directory path is relative to the folder you are syncing.

Multiple Exclude

Following command will exclude folders /proc and /backup

rsync -avz --exclude=/proc --exclude=/backup "-e ssh -p 22" / [email protected]:folder


Exclude A List

You can make a file with list of folders you need to exclude from backup. To do this create a file

vi /root/exclude.txt

Now put the folders in the file.

/backup
/proc

run rsync with option --exclude-from

rsync -avz --exclude-from=/root/exclude.txt "-e ssh -p 22" / [email protected]:folder




rsync

full server backup with rsync