[PLUG] Copying to new host, excluding a directory tree
Rodney W. Grimes
freebsd at gndrsh.dnsmgr.net
Wed Jul 31 21:46:31 UTC 2019
> > Well, I'm the only human element involved and I have no problems.
> > When
> > synchronizing an entire directory there's never been an issue. What I
> > want
> > to learn is how to exclude a specific subdirectory on the source
> > host.
>
> In an earlier reply I mentioned using a file to exclude things that is
> referenced on the rsync command line. I know that things can be
> excluded as an argument on the command line but I've been tripped up
> doing it like that in the past. I would suggest trying the following
> using your correct information of course.
>
> Create a file on the source node /home/rshepard/excludes.txt that
> includes the directory you want to exclude (in this case data no /
> needed), and possibly excludes.txt
>
> The following should do what you want as it works prefectly for me with
> my specific directories and excludes.
>
> rsync -arvP -e ssh --exclude-from='/home/rshepard/excludes.txt'
> /home/rshepard/ rshepard at salmo:/home/rshepard/
>
> I have files with commands resembling the one above on several
> computers which have worked for me for years.
I would highly encourage this solution, as the other
solution using the command line exclude is a filter
"On that word(s)" and may actually exclude more than
just the directory you wish should that word appear
anyplace in any other file name. This comes with a
voice of experience in using command line exclude filters,
imho they should be abolished as wasted program space,
command line complexity and bad user experience.
The formal traditional "unixy" way to do this is to
feed a right proper constructed list of desired files
to a command using a filter, most often find and grep {,-v}.
I'll give rsync a nod, it has more options than ls :-)
You can use the --list-only to get the list of files,
then pipe that through a properly anchored grep -v to
prune out the undesired files to locally create the above
excludes.txt file.
> Hope this helps
> --
> David
--
Rod Grimes rgrimes at freebsd.org
More information about the PLUG
mailing list