Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Mar 2004 22:54:03 -0800
From:      Bill Campbell <freebsd@celestial.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Two-way Sync of Directories - how? (rsync?)
Message-ID:  <20040315065403.GA94908@alexis.mi.celestial.com>
In-Reply-To: <87znaid47w.fsf@emptyhost.emptydomain.de>
References:  <4054B6A3.7080704@stevenfettig.com> <20040314201032.GA72170@alexis.mi.celestial.com> <200403152037.13184.satimis@icare.com.hk> <87znaid47w.fsf@emptyhost.emptydomain.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 15, 2004, Kai Grossjohann wrote:
...
>Explaining the trailing slash is more difficult.  I just remember a
>rule of thumb: if you want to copy directories with rsync, always
>specify a trailing slash.  On both the source and the destination.  Of
>course, "man rsync" has the full story...

I find this is a bit tricky, and non-intuitive.  If I do:

rsync -var ./ system:dest/

Everything in the current directory is copied to the remote directory as it
appears in the current directory.

rsync -var subdir system:dest/

copies subdir to system:dest/subdir

rsunc -var subdir/ system:dest/

copies subdir/* to systems:dest

I often have use the ``-n'' option first to make sure it's going to do what
I want before doing the real transfer.

Incidently if one leaves off the trailing ``.'' for the destination when
copying from a remote system to the current directory, rsync will show what
it will copy if you have it set for verbose output, but won't do the copy.

rsync -vaP remote:/path/\*.sh

This will show which files it would copy

rsync -vaP remote:/path/\*.sh .

This will do the copy.

Bill
--
INTERNET:  bill@Celestial.COM   Bill Campbell; Celestial Software LLC
UUCP:              camco!bill   PO Box 820; 6641 E. Mercer Way
FAX:           (206) 232-9186   Mercer Island, WA 98040-0820; (206) 236-1676

"Avoid revolution or expect to get shot.  Mother and I will grieve, but
we will gladly buy a dinner for the National Guardsman who shot you."
                -- Dr. Paul Williamson, father of a Kent State student



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040315065403.GA94908>