mirrorlinks
mirrorlinks is a small bash and python combo script that automatically mirrors the contents of a directory into another directory using symbolic links, so you don’t waste unnecessary disk space in copies. It’s also clever enough not to mirror Subversion’s .svn directories, so you can use a single Subversion working copy for several deployments of your projects.
This is better explained by example, of course:
- You have directories
Music,MoviesandShared. - You want to mirror both the contents of
Musicand the contents ofMoviesintoShared. For some specific reason, you don’t want to place links toMoviesandMusicintoShared,
With mirrorlinks, that’s easy to do:
mirrorlinks Music Shared mirrorlinks Music Movies
Now Shared has the contents of both the Music and Movies directories. To be more accurate, Shared has the directory structure of both Music and Movies merged into one single directory, with symbolic links pointing to the actual files. So if you had files into Music/ATB, Shared would contain a folder named ATB, and this folder would contain links to the files in Music/ATB.
Notes and frequently asked questions
- mirrorlinks creates absolute symlinks. If you want relative symlinks, see below.
- any directory named
.svnis automatically skipped. Thus, you can check in an entire merged directory full of symlinks into Subversion, and not have it choke or do wrong things.
Why does your script use symbolic links instead of hard links?
Two big reasons:
- Hard links don’t work across filesystems.
- You can’t check hard links into Subversion repositories.
I’m merging several directories into one, and mirrorlinks is refusing to continue because it says that a file already exists in the target directory
mirrorlinks, by default, won’t crush existing files in the destination directory (to prevent data loss). Thus, merging two source directories with files or directories in the same structural locations can be problematic. To instruct mirrorlinks to remove matching files and folders from the target directory, you can specify -r as the first command-line argument.
License
GPL, of course.





Sound off!
Write your own
Opinions