Tanktalus has asked for the wisdom of the Perl Monks concerning the following question:
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 ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sync via FTP
by bart (Canon) on Mar 10, 2007 at 20:15 UTC | |
|
Re: Sync via FTP
by Rhandom (Curate) on Mar 11, 2007 at 04:34 UTC | |
|
Re: Sync via FTP
by graff (Chancellor) on Mar 11, 2007 at 07:45 UTC | |
|
Re: Sync via FTP - wget
by varian (Chaplain) on Mar 11, 2007 at 07:56 UTC | |
|
Re: Sync via FTP
by clinton (Priest) on Mar 11, 2007 at 10:19 UTC | |
|
Re: Sync via FTP
by Daneel S. Yaitskov (Initiate) on Aug 29, 2011 at 10:19 UTC |