|
|
Line 1: |
Line 1: |
− | <perl>
| + | #redirect [[Unison]] |
− | #!/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:
| |
− | {{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]]
| |