Hello Magnolia25,

If you want to implement this yourself, you should look at the make_path function in the core module File::Path, and consider testing files either with one of the file test functions (such as -A for access time) or (better) with a module such as Digest::MD5 to determine which files need updating. (If you use MD5 you will need to store the known file hashes. A lightweight database such as DBD::SQLite will be useful here.)

But why reinvent the wheel when a module such as Dackup is available on ? As a test, I created a text file in a suitable directory structure and then ran the following script (adapted directly from the documentation):

#! perl use strict; use warnings; use Dackup; my $source = Dackup::Target::Filesystem->new ( prefix => '.\tmp\home', ); my $destination = Dackup::Target::Filesystem->new ( prefix => '.\home', ); my $dackup = Dackup->new ( source => $source, destination => $destination, delete => 0, dry_run => 0, verbose => 1, throttle => '1Mbps', ); $dackup->backup;

I then edited the text file and re-ran the script to verify that it copied the changed file to the destination (backup) location. You may need to experiment a bit to determine whether it meets your backup criteria.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: Copy directory structure and only latest changes in them when re-run by Athanasius
in thread Copy directory structure and only latest changes in them when re-run by Magnolia25

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.