[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Copy ./ to subdirectory.



Mike Bird wrote:
> James Preece wrote:
> > cp -r ./ backup
>
> I'd use rsync locally.

+1 on rsync.  It is the perfect tool for this task.

> First a dry-run in case I'd made a mistake:

Excellent advice.  Follow the advice or suffer for it when a typo is
made! :-)

> rsync -a --delete --exclude=backup /mydirectory/ /mydirectory/backup/
> ...
> Please note that trailing slashes on directory names are significant
> to rsync.

That is another important point.  If the source includes a trailing
slash then it means that directory.  Plus on other systems such as
HP-UX in particular there are bugs which cause this to behave
differently than it should.  I have found that specifying the
source directory into the destination directory above with a trailing
slash to be most portable.

  rsync -avn sourcedir destdir/

This results in:

  destdir/sourcedir

Bob



Reply to: