How to use rsync in linux like "robocopy /MIR" in Windows?
- User
How to use rsync in linux like "robocopy /MIR" in Windows?
- Assistant
In Windows,
robocopy /MIRis a command that mirrors directories by copying files from the source to the destination, while also deleting files in the destination that no longer exist in the source.rsyncin Linux can perform similar functionality.To use
rsyncto mirror directories likerobocopy /MIR, you can use the following command:bashrsync -av --delete /path/to/source/ /path/to/destination/ - User
multiple exclude rsync?
- Assistant
To exclude multiple files or directories when using
rsync, you can specify the--excludeoption multiple times in the command or use an--exclude-fromoption with a file that lists all patterns to exclude.Method 1: Using Multiple
--excludeOptionsYou can specify the
--excludeoption multiple times, each specifying a different pattern to exclude. For example:bashrsync -av --delete \ --exclude='*.tmp' \ --exclude='*.log' \ --exclude='cache/' \ /path/to/source/ /path/to/destination/Method 2: Using
--exclude-fromOptionIf you have many patterns to exclude, it may be more convenient to put them in a file, one pattern per line. Then you can use the option to read the patterns from that file.