I'm just curious about a few things.

  1. Why backticks to get the day? Why not just use localtime and sprintf it yourself (there are many date-time modules that can make this simple, too)?
  2. Why system(STR) instead of system(LIST)? Get rid of the shell for all that. Though this won't help with the md5sum since you're actually using the shell to make it really simple to create your sums.md5 file, which is fine, since you're really using the shell. The rest should not have any shell special characters in them, so using the LIST form would be more explicit for catching errors should they appear (at this point, it'd be most likely while adding features).
  3. Why duplicate $day? I'd probably suggest that you put everything in ~/backup/$day, and skip the $day in the filenames.
  4. Why taronly anything? It's not like gzip costs you anything. As I had a conversation with a co-worker just the other day, the overhead of using gzip in CPU time is usually (always in our case at $work) overwhelmed by the disk I/O time of writing the difference that gzip saves. And, in your case, it would mean fewer things to think about or evaluate. Just tar.gz everything, no special cases for the non-compressed stuff.
  5. Is it that advantageous to archive each directory separately? Unless the combined total of all these directories started getting to be too large for your file system to handle, I'd think it'd just be far more convenient to put everything into a single tarball. You can still extract individual directories, or even files, should you need to.
  6. Normally, the purpose of a backup is to have your files in case the physical disk they're on fail. You're putting the backups presumably on the same partition, so you're merely staving off accidental deletes, not catastrophic failures. You should be putting the files on a separate disk, which means it probably should be a "my $backupdir = '/nfs/othermachine/backups/';" at the top somewhere that you use as the basis for the backups. (And it should use a subdirectory that is named based on your current hostname, followed by the user it's backing up, just to ensure uniqueness, before putting in the date.) Of course, if you don't have said other machine, you can still point it to your home directory, but at least you'll have written the flexibility in for when you do get that far.
Mind you, that all might just be me. :-)

++ for automation.


In reply to Re: Just another backup script by Tanktalus
in thread Just another backup script by chomzee

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.