need help making hard link for a directory tree

fedora-list at jamesplace.net fedora-list at jamesplace.net
Tue Feb 15 21:49:08 UTC 2005


This worked brilliantly. I was able to modify the script a little and it works 
very well.
I just delete the entire (destination) structure each night, and re-create it 
with the script to account for the occasional/rare file rename/delete.

It was hard links to directories that I thought it best to avoid. 
This was very helpful.

Thanks much.

===

On Mon February 14 2005 8:31 am, Paul Howarth wrote:
> fedora-list at jamesplace.net wrote:
> > I need to mirror a complex directory structure with hard links. Of course
> > the directories themselves can not be hard linked, but is there a simple
> > way to create a duplicate directory tree and then make hard links to all
> > of the files?
> >
> > The links are to provide ftp access to files in a chrooted area on the
> > same partition.
>
> Try this script. Run it from the top-level directly that you want to
> copy-by-linking, after setting the CHROOT value to the full pathname of
> the directory you want to create the copy in. This script will only link
> regular files, not symlinks, device files etc., but you should be able
> to modify it to do that fairly easily if you need to do that.
>
> #!/bin/sh
>
> # TEMPLATE directory is root of tree you want to replicate.
> # It should *not* be an absolute pathname.
> TEMPLATE=.
>
> # CHROOT is absolute pathname of directory you want to clone the
> # template to.
> # It must be an absolute pathname and it must not be a subdirectory
> # of the template directory.
> CHROOT=/path/to/chroot
>
> # Replicate directory structure
> find $TEMPLATE -type d -exec mkdir -p $CHROOT/{} \;
>
> # Make hard links to files
> find $TEMPLATE -type f -exec ln {} $CHROOT/{} \;
>
>
>
> Paul.




More information about the fedora-list mailing list