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.


In reply to Re: Creating a bash script "on the fly" by haukex
in thread Creating a bash script "on the fly" by ovedpo15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.