[Gllug] rsync-ing sub-directories only
GLLUG at getaroundtoit.co.uk
GLLUG at getaroundtoit.co.uk
Sun Nov 22 21:57:15 UTC 2009
Dear commandLN mavens,
Is there a way to have rsync one-way mirror my laptop's Desktop and my
'main machine', in such a way as to only target Desktop sub-directories
whilst ignoring all simple files sitting on the Desktop itself?
Any and all advice will be appreciated,
=dn
The long-winded version:
I'm traveling around and not permanently connected to the Internet,
often having to take my old, slow, portable to use public library and
cyber-cafe connections, but preferring to use a more powerful desktop
(and full-sized keyboard) at home=work. Keeping the two in-sync is a bit
of a hassle:
It is easy enough to rsync something like "Desktop/ProjectNotes" between
my two machines. However I may have several projects or topics on the
go, and new projects come along, just as old projects eventually 'go
away'. To avoid embarrassment (either of storage space or personal
organisation) I try to keep as little as possible on the laptop.
At the library I will gather any downloads, saved web pages, notes that
I have made, etc, etc, into a sub-directory on my Desktop. Trouble is, I
may have other junk, eg reminder notes, general newspaper pages to read
later, an eBook I'm working my through, ie general detritus, also
sitting as (simple) files on the portable's Desktop. These I do not need
to back-up - and doing so creates a periodic 'clean-up job' on the main
PC! I also don't want it to follow a link to the WinXP partition of this
dual-boot machine.
I would prefer not to have to specifically nominate each individual
'project directory' (multiplied by the number of (current) projects),
but to script rsync to back-up any and every sub-directory that it might
find on the Desktop - ie regardless of which, how few, or how many, are
there, each time.
I like rsync's ability to decide that I have updated my notes and to
copy that document from the portable into the main project directory,
over-writing the older version (--backup). Also that I might only have a
few of the files relating to a project within my Desktop sub-directory
and not only will it not copy them unnecessarily (if they haven't been
changed) but it won't wipe out anything in the main PC's directory just
because it doesn't also exist on the laptop (ie the portable might
contain a sub-set not an exact "mirror" of the main PC's 'authoritative'
directory contents).
I can't see how any of the rsync options will help me directly because
they don't differentiate between files and directories. I have also
tried using `ls` or `find` and maybe a bit of `grep` to feed an rsync
--include or --exclude* but these are clumsy and messy, so surely
there's a better way?
* I successfully use rsync --exclude to maintain an in-house mirror of
the CentOS 5.3/5.4 repository but without bothering with the isos/
sub-directory, which is both elegant and works efficiently and effectively.
- or are you going to tell me I'm overloading rsync and to take a look
at unison or similar? - I might be lazy but I'm thinking that would be
"overkill"!
Regards,
=dn
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list