Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Synchronizing a directory between devices

by jakeeboy (Sexton)
on Dec 19, 2005 at 18:17 UTC ( #517837=perlquestion: print w/replies, xml ) Need Help??

jakeeboy has asked for the wisdom of the Perl Monks concerning the following question:

I have a need to sync an entire directory structure on my computer with my .Mac account so that I can have access to whereever I am. I've looked into CPAN and found the module File::DirSync which appears to be what I have in mind but it syncs two directories to appear to be exactly alike. It will clobber and overwrite the online directory if I make delete files in the original directory and I don't want to do that so I decided to write my own version. Here's what it will do:

Sync mode - new files will be uploaded. Newer versions of a file will be deleted on the iDisk and the newer version uploaded. Deleted files will not be touched on the iDisk. (Default mode)

Backup mode - new files will be uploaded. Newer versions will not replace but will be considered the newest copy, the iDisk file will be renamed with a version stamp. Deleted files will not be touched on the iDisk.

Mirror - this will mirror the original structure. Any file deleted will be deleted on iDisk. The iDisk directory will be backed up into a gzipped tarball. (Similar to File::DirSync)

My question, sorry for the length of this, is this. Since I'm creating a module for this for myself would I be duplicating someone else's effort? and should I upload this into CPAN when I'm done?

Right now, it's for a specific use with iDisk but I have plans to create this so that any Network location can be opened via WebDav/http/sftp/ftp. iDisk storage is the easiest for me since the OS X automatically syncs any changes to my local iDisk with the .Mac iDisk.

Just wanted to get a feel for what others think of this.

Thanks for your input.


Thanks for all the input. I'm still wanting to roll my own. Personally, this is more for me than for others but it sounds like that a CPAN module is not needed. There are plenty of solutions.

For me I'm trying to exercise and enhance my Perl skills. I don't necessarily have the same job I had when I picked up Perl and I just want to continue learning and working with Perl.

Resource forks are not an issue I'm using OS X and rolling this out with the current patched Perl 5.8.7

Considered: astaines: Title change to Synchronising a directory between device

Unconsidered: g0n - Enough keep votes ( Keep: 11, Edit: 6, Reap: 0 )

  • Comment on Synchronizing a directory between devices

Replies are listed 'Best First'.
Re: Recreating the wheel...
by tirwhan (Abbot) on Dec 19, 2005 at 18:22 UTC

    Are you familiar with rsync? It is able to do all the things that you're talking about and a bit more (transfer over encrypted channel via ssh for example). To be honest, I've never used any of the rsync modules on CPAN (never needed anything the base binary can't do), but you should probably check them out before you start off.

    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
Re: Recreating the wheel...
by pboin (Deacon) on Dec 19, 2005 at 19:18 UTC

    Sounds like you should be reading about Unison. Unless, you really want to implement your own solution, unison is really slick (and it's perfectly happy to work cross platform -- at least between linux & windows.)

    PS: You really should improve your titling of this node.

      Agreed, Unison is very good indeed - the only catch I know of is that you need to keep the same version of Unison on all your machines.

      -- Anthony Staines

      One thing to bear in mind with Unison is that it doesn't (at least last time I checked) handle Mac OS9-style resource forks at all. Rsync (under Tiger at least) is meant to be able to, but I've also read things about it not quite being 100% there yet. I'm presuming that might be an issue, given the OP's mention of iDisk.

      Having said that, I can't actually remember the last time I had to deal with a file with a resource fork...

        You can use RsyncX to preserve resource forks.

Re: Recreating the wheel...
by tphyahoo (Vicar) on Dec 19, 2005 at 18:32 UTC
    Maybe off topic, maybe not helpful but... you think maybe version controlling would help you out? I sort of use subversion as my "rsync", for the code I'm working on. Obviously this will only help if your workspace is relatively small, and ideally full of text but... anyway, TIMTOWTDI...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://517837]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2023-05-29 01:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found