in reply to Creating a bash script "on the fly"

Since you already mention rsync: it should be able to do everything you mention. See its --archive (implies --recursive --links --perms --times --group --owner --devices --specials), --hard-links, and --sparse options for mirroring a filesystem as closely as possible (perhaps --no-owner --no-group if the UID/GIDs are different and you don't want to keep them), its --files-from option to give it a list of files to sync (this implies --relative and disables --recursive, so I usually add the latter back on), plus its --filter, --exclude-from and --include-from to control which files are included and excluded. If you have files spread out sparsely across the whole fileystem that you want to sync, it's possible, but setting up the right combination of the aforementioned options takes a bit of reading in the manpage to get right. The --dry-run --itemize-changes --verbose options are useful for testing.

Several years ago I did a bunch of research on rsync to arrive at the above combination of options and wrote a Perl frontend for it. Unfortunately it's not really something to publish, but maybe I'll get around to cleaning it up for publishing someday.

Of course I don't want to discourage writing a Perl solution though :-) Note you don't need to create a bash script: The equivalent to mkdir -p is File::Path's make_path, scp can be done by Net::OpenSSH, and links via symlink.