View Single Post
Hi all,

I've taken Ken's post and created the files necessary and instructions for everyone to do this themselves. You can add as many other files and folders to this process as you like. It's not limited to OF.

Requirements:
You must have a central, 99% uptime repository with a static IP. (I am using my personal domain at Dreamhost). I you want to this to be awesome, install Growl and the growlnotify tool, because i've included growl notifications in the script, alerting when it syncs.

Terms:
"Client" refers to the client computers running OmniFocus.

Each of your client computers has a "computer name." You can find this by going to system preferences -> sharing. Ken's examples were jamethiel and hypno.

"Host" refers to the central computer (which could be running OmniFocus) which contains the Mirrors folder and hosts sync files/backups for OmniFocus

myhost.com refers to your static IP of your host. In my case, it's code404.com. In ken's case (ken case! ha!), it's example.org. If you are using a mac, enable remote access in the sharing preferences

myname refers to your login name/account name on myhost.com

Setting up the DSA keys:
Since you don't want to be entering passwords everywhere, you should generate DSA keys so your computers can freely communicate.

1. On your first client computer, open Terminal. You're now most likely in your home directory. Type "ssh-keygen -tdsa", and accept all defaults.

2. On your host computer, do the same.

3. On your client computer, open another terminal window. Type the following:
ssh myname@myhost.com
Enter your password. Just leave this window alone. We'll use it to do some cleanup later.

4. In the first terminal window, where you ran ssh-keygen, type the following:
scp ~/.ssh/id_dsa.pub myname@myhost.com:id_dsa.pub

5. In the second terminal window (myhost.com), type the following commands:
cat id_dsa.pub >> ~/.ssh/authorized_keys2
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys2
rm id_dsa.pub


6. Repeat steps 1-5 for each client computer.

This will now allow you to ssh, scp and rsync from your client to host without having to enter your password.

If you're not much of a terminal junkie, you're likely using bash, the default shell. If you're using tcsh or zsh, you already know enough about what you're doing to modify the following instructions to meet your needs.

Creating the environment functions
1. Grab the file bash_profile.zip included in this post.

2. Put it in your home directory.

3. Double click it to unzip it, then delete the zip file.

4. type the following command:
mv bash_profile .bash_profile

5. Edit the .bash_profile. If you have BBEdit or TextMate installed, type bbedit .bash_profile or mate .bash_profile. If you don't, type
/Applications/TextEdit.app/Contents/MacOS/TextEdit .bash_profile.

I've renamed "push-focus" and "sync-focus" to "-files" because I've modified my own personal one to sync multiple files, not just OmniFocus. Change the content in red to your own information. Also, if you didn't install growlnotify, delete the two lines in blue

username="enter your username here"
hostname="enter your hostname here"

function push-files() {
/usr/bin/rsync -vP -az --delete $* ~/Library/Application\ Support/OmniFocus/. ${username}@${hostname}:Mirrors/$(hostname -s)/OmniFocus/.
/usr/local/bin/growlnotify -m "Synced OmniFocus (push)"
}

function sync-files() {
if [ "$1" = "" ]; then
echo "Usage: sync-focus hostname"
else
echo "Syncing from $1"
rsync -avP -z --delete ${username}@${hostname}:Mirrors/$1/OmniFocus/Perspectives ~/Library/Application\ Support/OmniFocus/
rsync -avP -z --delete ${username}@${hostname}:Mirrors/$1/OmniFocus/'OmniFocus.ofocus*' ~/Library/Application\ Support/OmniFocus/
/usr/local/bin/growlnotify -m "Synced OmniFocus (sync)"
fi
}


6. Save, and close the file.
7. if the process is still hanging from textedit, and you don't have a prompt, hit control-c (not command-c).

8 (I think?). Once you've saved it with your edits, type source ~/.bash_profile to reload it.

Creating the auto-syncing script
1. Grab the file filesync.sh.zip included in this post.

2. Put it in your home directory.

3. Double click it to unzip it, then delete the zip file.

4. Edit it and replace your own info just like you did for the last one.

Yay! They're now fully-functional scripts. But we can't do anything with them yet...

Setting up the host:
There are better ways of folder-checking followed by folder creation and so on. I'm going for quick and dirty. We're going to manually set up the repository folders on the host computer. Assuming you still have a terminal window open connected to the host computer (if you don't, ssh myname@myhost.com and get one going)

Ok. So we're in a terminal window connected to the host.

1. Create a folder "Mirrors":
mkdir ~/Mirrors

2. Create folders inside it for each of the client computers. Repeat for each one
mkdir -p ~/Mirrors/Computer Name/OmniFocus
(e.g., mkdir -p ~/Mirrors/jmaxwell-laptop/OmniFocus)

You can now close the terminal window connected to the host.

Now the host is ready to receive the files. If you're going to sync other programs, make folders within each Computer Name folder for that program name, too. For example, I have folders for DEVONthink and OmniPlan inside each of mine.

Pushing the file up there:
1. in terminal, type push-files. The result should look something like this:
jmaxwell-mlap-2:~ jkmaxwell$ push-files
building file list ...
944 files to consider
./
OmniFocus.ofocus/
OmniFocus.ofocus.lock
495 100% 0.00kB/s 0:00:00 (1, 0.3% of 944)
OmniFocus.ofocus/2F142372-4714-4D3E-8D4C-20775EB8862A:B5689632-229D-4157-80CD-CED478B5F09D.xml
263 100% 28.54kB/s 0:00:00 (2, 17.5% of 944)
OmniFocus.ofocus/C7917066-B881-49C6-818B-91BC5559E280:2F142372-4714-4D3E-8D4C-20775EB8862A.xml
210 100% 18.64kB/s 0:00:00 (3, 76.3% of 944)

sent 83156 bytes received 80 bytes 18496.89 bytes/sec
total size is 807074 speedup is 9.70


And if you have growl, you'll get a growl notification when it finishes.

Setting up the LaunchAgent:
Although unix folks are more accustomed to cron, it's been phased out (but still supported) in OS X, in favor of LaunchAgents (for tasks run while the user is logged in) and LaunchDaemons (for tasks run regardless of user login). We're going to set up a LaunchAgent that runs every 30 minutes. (I haven't added growl notifications to this one, but I'd like to eventually and will edit this post when that happens)

1. grab the file com.omnigroup.OmniFocusSync.plist.zip from this post and put it in your home directory
2. double-click it to unzip it to com.omnigroup.OmniFocusSync.plist
3. delete the left-over zip file
4. open a terminal window and edit the file. If you have BBEdit or TextMate installed, type bbedit com.omnigroup.OmniFocusSync.plist or mate com.omnigroup.OmniFocusSync.plist. If you don't, type
/Applications/TextEdit.app/Contents/MacOS/TextEdit com.omnigroup.OmniFocusSync.plist.

Change the content in red to your own information.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.omnigroup.OmniFocusSync</string>
<key>ProgramArguments</key>
<array>
<string>/Users/(enter your account name here)/filesync.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1800</integer>
</dict>
</plist>


5. Save, and close the file.
6. if the process is still hanging from textedit, and you don't have a prompt, hit control-c (not command-c).
7. Move the file to LaunchAgents, set permissions, and load it up:

mv com.omnigroup.OmniFocusSync.plist ~/Library/LaunchAgents/

sudo chown root ~/Library/LaunchAgents/com.omnigroup.OmniFocusSync.plist

sudo chgroup wheel ~/Library/LaunchAgents/com.omnigroup.OmniFocusSync.plist

sudo launchctl load ~/Library/LaunchAgents/com.omnigroup.OmniFocusSync.plist


As long as you didn't get an error, you've successfully set up auto-syncing on your client computer. It will now sync omnifocus data every 30 minutes. As Ken said above, you can use push and sync manually in terminal now:

push-files
This pushes the current version of your omnifocus file from your client computer (the one on which you're typing) to the host. Use this right before you're about to switch from one computer to another, go home from work, etc.

sync-files computername
This gets the latest version of your omnifocus file from your host computer and puts it on your client computer. Use this when you get on another computer, when you get home from work, etc.

If anyone has any problems, please let me know.
Attached Files
File Type: zip bash_profile.zip (869 Bytes, 263 views)
File Type: zip com.omnigroup.OmniFocusSync.plist.zip (953 Bytes, 254 views)
File Type: zip filesync.sh.zip (766 Bytes, 244 views)

Last edited by Seņor Pantalones; 2008-01-31 at 12:14 PM.. Reason: Revised