rsync is a tool for get backup and synch files between different servers or locations. If you want to exclude files from backup then you have to exclude the file or directory type from rsync. We define some example of exclude files or directory with rsync.

Exclude file:

If you want to exclude file then use the path relative to file via using exclude option.

Syntax:

$ rsync – avz – - exclude ‘dir1/myfile.txt ’ source/destination/.

Exclude File Type:

If you want to exclude a file with extension then use the following command.

Syntax:

$ rsync – avz - - exclude ‘*.txt’ source/destination.

Exclude Directory:

If you want to exclude a directory then use the given command.

Syntax:

$ rsync – avz - - exclude ‘mydir’ source/destination.

Multiple Directory:

If you want to exclude a directory with a particular pattern use the following command.

Syntax:

$ rsync – avz - - exclude ‘mydir*’ source/destination/.

Multiple directory and multiple files at same Time:

If you want to exclude multiple files and directories at same time then use the following command.

Syntax:

$ rsync – avz - - exclude myfile.txt - - exclude mydir/myfile2.txt source/destination.

Exclude path:

The exclude option seems to have the full path of a directory or file. But the rsync side the exclude path is a relative path.

Syntax:

$ rsync – avz - - exclude ‘mydir1/mydir2/myfile.txt’ source/destination.

Exclude file with specific extension:

You can also exclude file with their type or extension then use the following command.

Syntax:

$ rsync – avz - - exclude ‘*.txt’ source/destination.
Author
Jaishree
Views
2,104
First release
Last update
Rating
0.00 star(s) 0 ratings
Top