Difference between revisions of "Unison.pl"

From Organic Design wiki
(How can I allow a Unison profile to be initiated from either end?)
m
Line 17: Line 17:
 
</perl>
 
</perl>
  
== How can I allow a Unison profile to be initiated from either end? ==
+
== Notes ==
 +
 
 +
=== How can I allow a Unison profile to be initiated from either end? ===
 
Imagine syncing between a laptop and a desktop computer, using the "minimal profile" from the manual. But you want to be able to initiate the synchronization from both computers. On the desktop use the profile:
 
Imagine syncing between a laptop and a desktop computer, using the "minimal profile" from the manual. But you want to be able to initiate the synchronization from both computers. On the desktop use the profile:
 
{{code|<pre>
 
{{code|<pre>

Revision as of 06:30, 19 July 2009

<perl>

  1. !/usr/bin/perl

use Expect; require( '/var/www/tools/wikid.conf' ); $bak_user = $name unless defined $bak_user;

for $dir ( @bak_paths ) { $cmd = "unison $dir ssh://$bak_user\@$bak_server$dir -batch -force $dir"; $exp = Expect->spawn( $cmd ); $exp->expect( undef, [ qr/password:/ => sub { my $exp = shift; $exp->send( "$bak_pass\n" ); exp_continue; } ], [ qr/Synchronization complete/ => sub { } ], ); $exp->soft_close(); } </perl>

Notes

How can I allow a Unison profile to be initiated from either end?

Imagine syncing between a laptop and a desktop computer, using the "minimal profile" from the manual. But you want to be able to initiate the synchronization from both computers. On the desktop use the profile:

root = /home/bcpierce
root = ssh://laptop//home/bcpierce

include homedir


While on the laptop you use:

root = /home/bcpierce
root = ssh://desktop//home/bcpierce

include homedir


On both ends, you maintain the included file .unison/homedir.prf, with the paths (and other settings):

path = current
path = common
path = .netscape/bookmarks.html
path = .unison/homedir.prf


Note that the homedir.prf file itself is specified as a path to be synchronized.