Ideally, I'd be doing this via rsync, but my webhost doesn't have sshd or rsyncd running. I contemplated setting up an rsync daemon in perl, but I think that that's probably more work than the alternative... which is to write a synchronisation tool in perl that syncs via FTP.

Unlike the rsync project, I don't think that "minimal transfer" (as in, parts of files) is really that important. Largely, I just need to check if a file locally has been added or changed (and thus need to be uploaded), or deleted (and thus needs to be deleted on the server). I think comparing timestamps should be sufficient here, as long as I can remember to convert the remote time stamp to GMT in its own timezone (which is different from mine). I don't think this will be hard. It may upload a bit more than needed, but I'd rather upload an extra meg of data than all 50MB (pics, PDFs, etc.) each time. And I want it automated just because I'm absolutely terrible about remembering what I've changed, whether that's new files, modifications, or deletions. I figure that if I can teach the computer how to do it, then I don't have to remember the minutiae that I know I'm horrible at. First, of course, I have to teach myself how to do it ;-)

The algorithm I'm trying to wrap my head around at the moment is how best to approach the recursive matching on two machines in parallel - one local, one remote. Including deleting entire trees from the remote system, e.g., if I have a /www/pics/2005/01 directory, and I delete the www/pics/2005 directory locally (no longer want to show those pics), I need to go into all the subdirs of www/pics/2005 and delete their contents so I can delete the directories, recursively, but in reverse order (I know there are terms for pre- and post-something, but I don't remember the terms, only that they'd apply here in describing how I'd scan to the bottom and only do the deletion after returning from the lower level of recursion). Obviously, handling local directories is easy with File::Find - but I'm not really sure how to best approach it when I'm trying to sync two different directories.

Perhaps I should practice just by syncing to another local directory - translating the "destination" from readdir/glob to Net::FTP is probably easier than this - at least to me.

Note: in my case, the local is considered the master for all directories with some exceptions (e.g., software that gets installed by the webhost's control panel). Any directory on the webhost that is neither local nor in the exception list (hash) will be removed.

Something tells me that I'm just missing something simple to make the whole thing "click" in my head... either that, or I'm just completely out to lunch and am missing the entirety of the concept. Hopefully another monk will be able to tell me which ;-)


In reply to Sync via FTP by Tanktalus

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.