Difference between revisions of "Unison.pl"

From Organic Design wiki
m (cat in)
(How can I allow a Unison profile to be initiated from either end?)
Line 16: Line 16:
 
}
 
}
 
</perl>
 
</perl>
 +
 +
== 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:
 +
{{code|<pre>
 +
root = /home/bcpierce
 +
root = ssh://laptop//home/bcpierce
 +
 +
include homedir
 +
</pre>}}
 +
 +
 +
While on the laptop you use:
 +
{{code|<pre>
 +
root = /home/bcpierce
 +
root = ssh://desktop//home/bcpierce
 +
 +
include homedir
 +
</pre>}}
 +
 +
 +
On both ends, you maintain the included file .unison/homedir.prf, with the paths (and other settings):
 +
{{code|<pre>
 +
path = current
 +
path = common
 +
path = .netscape/bookmarks.html
 +
path = .unison/homedir.prf
 +
</pre>}}
 +
 +
 +
Note that the homedir.prf file itself is specified as a path to be synchronized.
 
[[Category:PERL]][[Category:Backup]]
 
[[Category:PERL]][[Category:Backup]]

Revision as of 06:27, 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>

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.