So I've gotten excluding paths to work as a standalone command. When I paste this into a script however, it ignores the exclusions. Any advice? rsync -aXvr --times --links --exclude={'*.vdi','*.vmdk','*.ova','*.qcow2','.config/discord/'} /home/path/ user at nas:/NAS/HOME/destination/ Are there supposed to be some kind of brackets around this? Regards, Matt Stevens On 8/2/20 10:19 AM, Andy Smith via rsync wrote:> Hi Matt, > > On Sat, Aug 01, 2020 at 10:10:49PM -0400, Matt Stevens via rsync wrote: >> I lack development skills. Would there be a way for rsync to be passed an >> option to exclude a specific path during a sync operaton? All of my attempts >> to use exclude have failed, as it does not respect paths, only filetypes. > The existing --exclude and filter file options work for me for this. > Maybe show us what you're doing (command line), what you expect to > happen and what actually happens? > > You absolutely can exclude paths. The exclude and filter options are > very expressive. I've been doing it for years. > > Cheers, > Andy >
On Mon 03 Aug 2020, Matt Stevens via rsync wrote:> So I've gotten excluding paths to work as a standalone command. When I paste > this into a script however, it ignores the exclusions. Any advice? > > rsync -aXvr --times --links > --exclude={'*.vdi','*.vmdk','*.ova','*.qcow2','.config/discord/'} > /home/path/ user at nas:/NAS/HOME/destination/ > > Are there supposed to be some kind of brackets around this?Using these brackets with bash causes the --exclude to be repeated for each value: $ echo TEST: --exclude={'*.vdi','*.vmdk','*.ova','*.qcow2','.config/discord/'} TEST: --exclude=*.vdi --exclude=*.vmdk --exclude=*.ova --exclude=*.qcow2 --exclude=.config/discord/ I suspect you've pasted this into a shell script which does not start with #!/bin/bash but perhaps #!/bin/sh so that the script is not run by bash but e.g. ash or dash that don't do the braces expansion. It's always best (especially in a script) to write it out, don't rely on the shell for such things. Paul
Got it working properly. Many thanks! Regards, Matt Stevens On 8/3/20 10:28 AM, Paul Slootman via rsync wrote:> On Mon 03 Aug 2020, Matt Stevens via rsync wrote: > >> So I've gotten excluding paths to work as a standalone command. When I paste >> this into a script however, it ignores the exclusions. Any advice? >> >> rsync -aXvr --times --links >> --exclude={'*.vdi','*.vmdk','*.ova','*.qcow2','.config/discord/'} >> /home/path/ user at nas:/NAS/HOME/destination/ >> >> Are there supposed to be some kind of brackets around this? > Using these brackets with bash causes the --exclude to be repeated for > each value: > > $ echo TEST: --exclude={'*.vdi','*.vmdk','*.ova','*.qcow2','.config/discord/'} > TEST: --exclude=*.vdi --exclude=*.vmdk --exclude=*.ova --exclude=*.qcow2 --exclude=.config/discord/ > > I suspect you've pasted this into a shell script which does not start > with #!/bin/bash but perhaps #!/bin/sh so that the script is not run by > bash but e.g. ash or dash that don't do the braces expansion. > > It's always best (especially in a script) to write it out, don't rely on > the shell for such things. > > > Paul >