Difference between revisions of "Unison File Synchronizer"

From MagnetoWiki
Jump to navigation Jump to search
(updated applescript, and fixed some typos)
Line 52: Line 52:
  
 
  -auto  
 
  -auto  
the user interface will not ask to confirm non-conflicts, but only ask questions about conflicts
+
if "auto" is set the user interface will not ask to confirm non-conflicts, but only ask questions about conflicts
 
  -batch  
 
  -batch  
the user interface will ask no questions at all; non-conlficts will be propogated, conflicts will be skipped
+
if "batch" is set the user interface will ask no questions at all; non-conlficts will be propogated, conflicts will be skipped
 
  -silent   
 
  -silent   
the textual interface will porint nothing at ell, except errors (automatically sets -batch TRUE)
+
if "silent", the textual interface will porint nothing at ell, except errors (automatically sets -batch TRUE)
 
  -times
 
  -times
synchronize the modification times?
+
"times" synchronizes the modification times?
-ignore 'Name .DS_Store"
+
-terse
 +
if "terse" is set, status messages are not reported, so only conflicts are reported.
 +
-ignore 'Name .DS_Store"
 
Unison will ignore all files with the name .DS_Store (On Mac OS X,  .DS_Store files encode only trivial appearance stuff like icon position, but .DS_Store files are changed everytime a folder is opened so frequently generate irrelevant conflicts.)
 
Unison will ignore all files with the name .DS_Store (On Mac OS X,  .DS_Store files encode only trivial appearance stuff like icon position, but .DS_Store files are changed everytime a folder is opened so frequently generate irrelevant conflicts.)
  
 
==AppleScript==
 
==AppleScript==
 
 
To avoid opening the terminal window, create the following AppleScript and save as an application.
 
To avoid opening the terminal window, create the following AppleScript and save as an application.
  
  do shell script "unison /User/houpt/uniDisk ssh://houptlab.org/uniDisk -ui text -batch -times -ignore 'Name .DS_Store' "
+
  set resultsText to do shell script "unison /Users/houpt/uniDisk ssh://houptlab.org/uniDisk -ui text -batch -times -terse -ignore 'Name .DS_Store'"
 +
 +
-- display the results text in a new TextEdit window
 +
-- note that if "-terse" is set, then unison only returns a result if there are conflicts
 +
tell application "TextEdit"
 +
activate
 +
set NewDoc to make new document
 +
if (0 is length of resultsText) then
 +
set text of NewDoc to (date string of (current date)) & (time string of (current date)) & return & return & "Unison reports no conflicts."
 +
else
 +
set text of NewDoc to (date string of (current date)) & (time string of (current date)) & return & return & resultsText
 +
end if
 +
end tell
  
Results of the synch will be silent, but will be stored in the "unison.log" file. If there are conflicts to be resolved, then the applescript will post a dialog window.
+
Results of the synch will be silent, but will be stored in the "unison.log" file. If there are conflicts to be resolved, then the applescript will post a TextEdit window.
  
 
==Conflicts==
 
==Conflicts==

Revision as of 17:43, 21 January 2014

Unison project website.

Unison Manual.

Unison Mac OS X FAQs.

Set Up

Downloaded GUI Universal Binary 2.32.12 "(2009.05.06, stable, should work on Tiger and Leopard)."

1. Installed on both Principia (King office) and houptlab.org (magnet.neuro.fsu.edu) by screen sharing...

2. Logged into Magnet as User, and launched Unison on Magnet.

3. On Magnet, under System Preferences, set Unison to run automatically on start-up on houpt log-in. (Will it be running even if I don't log in to magnet as user?)

4. On Principia, In the finder, made a new folder in home directory "/Users/houpt/uniDisk"

5. Ran Unison on Principia; created a new profile:

Profile name: "uniDisk"
First Root:File: "/Users/houpt/uniDisk" 
Second Root:Remote
Second Root:User:"houpt"
Second Root:Host:"houptlab.org"
Second Root:File:"uniDisk"

Save the profile.

(Apparently don't need to setup a profile on the server.)

(Profiles are stored as .prf files in "/Library/Application Support/Unison" folder; apparently only way to delete a profile is to trash the .prf file manually.)

6. To sync, run Unison, choose uniDisk profile, hit "Open". First time of launch will be prompted for password.

7. Hit "Go" for default synchronization.

And it just worked! (apparently don't need to create a profile on the remote host. Folder will be created on the server side on the first sync.)

If you close the profile window, you can't reopen the window except by quiting and relaunching Unison? Hit "restart" button to get back to list of profiles. Apparently no way to edit the profiles after creation.

Command Line

To synchronize the folder "/Users/houpt/uniDisk" from the command line (without invoking GUI app):

1. Make sure you are starting from directory "/Users/houpt" (maybe should use absolute paths in command line?))

2. type following command:

unison uniDisk ssh://houptlab.org/uniDisk -ui text -batch -times

3. prompted for password

4. If there are any conflicts etc., will be prompted for directions. These can be suppressed with various command line options, for example:

-auto 

if "auto" is set the user interface will not ask to confirm non-conflicts, but only ask questions about conflicts

-batch 

if "batch" is set the user interface will ask no questions at all; non-conlficts will be propogated, conflicts will be skipped

-silent  

if "silent", the textual interface will porint nothing at ell, except errors (automatically sets -batch TRUE)

-times

"times" synchronizes the modification times?

-terse

if "terse" is set, status messages are not reported, so only conflicts are reported.

-ignore 'Name .DS_Store"

Unison will ignore all files with the name .DS_Store (On Mac OS X, .DS_Store files encode only trivial appearance stuff like icon position, but .DS_Store files are changed everytime a folder is opened so frequently generate irrelevant conflicts.)

AppleScript

To avoid opening the terminal window, create the following AppleScript and save as an application.

set resultsText to do shell script "unison /Users/houpt/uniDisk ssh://houptlab.org/uniDisk -ui text -batch -times -terse -ignore 'Name .DS_Store'"

-- display the results text in a new TextEdit window
-- note that if "-terse" is set, then unison only returns a result if there are conflicts
tell application "TextEdit"
	activate
	set NewDoc to make new document
	if (0 is length of resultsText) then
		set text of NewDoc to (date string of (current date)) & (time string of (current date)) & return & return & "Unison reports no conflicts."
	else
		set text of NewDoc to (date string of (current date)) & (time string of (current date)) & return & return & resultsText		
	end if
end tell

Results of the synch will be silent, but will be stored in the "unison.log" file. If there are conflicts to be resolved, then the applescript will post a TextEdit window.

Conflicts

Conflicts arise when the server and the local directory have conflicting dates (i.e. the versions on office computer and laptop were independently edited, so are now out of sync.) If there are conflicts to be resolved, then the applescript will post a dialog window.

To resolve the conflicts, run the following command (make sure you are in Users/houpt directory)

unison uniDisk ssh://houptlab.org/uniDisk -ui text -times -ignore 'Name .DS_Store'

For each conflict, < moves from server to local, > moves from local to server, / skips the file, f means follow Unison recommendation.