The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
SyncMirror: Sync to server with user interface Thread Tools Search this Thread Display Modes
Overview
This is a user interface and scripts to sync your OmniFocus document folder and a 'Mirrored' folder between two or more machines and a central server. I use it to 'transfer control' of my Omnifocus and other documents between a laptop and desktop.

SyncMirror is based on a post by Ken Case, and then detailed instructions by Señor Pantalones. From their work, I rewrote it, added a user interface, and lots of new features to make it more user friendly.

How it works
Omnifocus 1.0 can't merge changes made by multiple users into a single document, so in our case sync really means tracking which is the most-current document, or put another way, who owns it, and then copying it to another machine. To transfer ownership of the sync, the files (or at least the recent changes to the files) are copied to the server, and then copied from the server to the new owner.

MirrorSync uses a central server to store the synced documents from each client, with one folder for each client in a 'Mirrors' folder. Note that the central server could also be a client, but I haven’t tested this. We use the term 'Push' when we copy from a client to the server, and 'Pull' when client files are replaced with files from another client that are on the server.

The script keeps track of who 'owns' the sync. The name of the owner is stored on the server.

Another reason the word 'sync' is used here is that we use rsync to push or pull the files. rsync is efficient, only copying changes, not entire files or unchanged files.

Using SyncMirror
After installation and setup, open the SyncMirror application. If you're using a remote server, it may take a few seconds for SyncMirror to contact the server to find out who owns the sync. If you own the sync, you'll see:



The title bar shows that you own the sync. If you want to transfer it to, say, your desktop, then click Push. SyncMirror will first check to see if any applications are running that you have specified (i.e. OmniFocus), and warn you, so that there aren't any unsaved changes. The list of applications is cQuitAppList in SyncMirror. It then copies your changes since the last push to the server.

Now, go to your desktop machine and open SyncMirror on that machine. You will see:



Just hit return, and SyncMirror will compare the local files to the files on the server for the sync owner (in this case MacBook-Pro-David), and update the local files to match. If you run SyncMirror again, it will show that your desktop machine now owns the sync.

To help you remember if you do or don't own the sync, SyncMirror will change the color of your 'Mirrored' folder and its immediate descendants to green if you own it, red if you don't.


Timed Push
As with the original post by Ken, you can optionally set up timed pushes so that the server always has a recent copy of your Mirrored and OmniFocus folders. This is useful if you forget to do a push, and want to later pull on another machine. The only downside is if you have open documents, you may loose unsaved changes. Timed pushes also make manual pushes faster.

Terminal commands
If you prefer using the terminal, you can use push_files and pull_files.

push_files
This pushes the current version of your Omnifocus and Mirrored folders 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.

pull_files computername
This gets the latest version of your Omnifocus and Mirrored folders 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.

get_who_last_pulled
This gets the computer name of the client that last pushed to the server. You can pipe this to pull_files. It also colors the Mirrored folder.
 
Installation
I have taken these instructions: Ken Case, Senor Pantalones, and heavily modified them.

Requirements
You must have a central (either local or on the internet), 99% uptime repository with a static IP.

Growl
I you want to this to be awesome, install Growl and the growlnotify tool, because growl notifications are included in the script, alerting when it syncs. The script detects if growlnotify is installed and uses it if it's available. Note that growlnotify doesn't currently work reliably in Leopard, so if you're using 10.5 don't expect to get all notifications.

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

Each of your client computers has a "computer name." You can find this by typing "hostname -s" in terminal. 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 and Mirrored folders.

myhost.com refers to your static IP of your host. In SP's case, it's code404.com. In ken's case (ken case! ha!), it's example.org. If it's a local machine with a manually-entered IP addres, it will be something like "10.0.1.101" If your host is 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.

Host:
1. On any client computer, open terminal. Type the following: ssh myname@myhost.com Enter your password. This window will be where you enter host commands.

2. Type "ssh-keygen -tdsa", and accept all defaults.

Leave this host window open.

Client:
3. On a client computer, open Terminal (or open a new window if you did step 1 on this machine). You're now most likely in your home directory. Type "ssh-keygen -tdsa", and accept all defaults.

4. In the client window, type the following:
scp ~/.ssh/id_dsa.pub myname@myhost.com:id_dsa.pub You have just copied your key to the host

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


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

7. In host terminal window (myhost.com), type the following commands:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys2


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.

Installing Scripts
1. Grab the file "SyncMirror folder.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. Open bash_profile in a text editor like BBEdit or TextEdit.

Change the content in red to your own information.

omsync_username="yourname"
omsync_hostname="yourdomain.com"

5. Save, and close the file.

6. The "SyncMirror Folder" is now customized for your clients. Copy it to the other client computers you plan on using.

7. Move all of the files out of the "SyncMirror Folder" folder to your home folder. You can put the SyncMirror application anywhere.

8. Open terminal, and type the following command:
mv bash_profile .bash_profile

Repeat steps 7 and 8 for each client.

Pushing the files up there:
1. Open the SyncMirror applicaiton on the client machine with the files you want to push to the server. It will ask if you want to add your machine's name to the list, click yes.

2. Click Push, and wait for the Push to comlete. A Mirrored folder will be created on your client machine, which you can now put files in to be synced. A Mirrors folder will be created on your host, it will contain a folder for this client machine.

Verify that your files have been pushed to your server. If SyncMirror didn't work, you can try push_files from the terminal, and see any error messages.

Setting up the LaunchAgent:
This is optional, but recommended.

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.

1. The files filesync.sh and com.omnigroup.OmniFocusSync.plist should be in your home directory, added in "Installing Scripts" above.

2. Open com.omnigroup.OmniFocusSync.plist in a text editor like BBEdit or TextEdit.

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-home-directory-here/filesync.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1800</integer>
</dict>
</plist>


3. Save, and close the file.

4. Move the file to LaunchAgents, set permissions, and load it up. In Terminal, type:

mkdir -p ~/Library/LaunchAgents

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

sudo chown root: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.

Repeat all of these steps to setup launchagent for each client.

The cQuitAppList in SyncMirror
SyncMirror can check if certain applications are running before a sync. The cQuitAppList initially just has Omnifocus, but you can add others, as in this example:

--Fill in the following list with the applications that you want to be warned to quit before syncing
set cQuitAppList to {"OmniFocus", "Quicken", "SBook5"}

To edit the list, open SyncMirror in Script Editor, edit the list, and save.

If anyone has any problems, please let me know.
Attached Files
File Type: zip SyncMirror folder.zip (51.2 KB, 637 views)
 
Running the initial sync, I got the error "The variable 'wholastpulled' is not defined". Scripts in the terminal window weren't working.

----------------------

Update: So, I didn't source my .bash_profile file (checked the instructions from Senor Pantelones which included that as a step).

Now push_files worked from my primary OF (which is on my host machine). And then SyncMirror worked to push and pull.

Note: I had to move my databases back to the default location. I'd moved them elsewhere thinking I'd be syncing with iDisk or a USB, but saw in .bash_profile that they expect the default location..

-----------------------

Next Update: Pull on my client didn't copy anything. It said "List empty". As a potentially useful bit of information, the "Mirrored" directory on my host computer is empty, though "Mirrors" has the folders "tide", my short hostname, and "WhoLastPulled"

Ok, found solution: more details from Senor P, I needed to create a directory in Mirrors for my client computer that I was pulling from.

SUCCESS!

Thanks for all these! Both OF and the syncmirror.

Last edited by frilliams; 2008-03-13 at 07:53 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
New User Interface Ideas - what do you think? bafranklin OmniFocus 2 for Mac (Private Test) 29 2013-06-16 02:58 AM
User interface is very awkward! carlsson OmniFocus 1 for Mac 13 2012-01-16 10:29 PM
User interface... trash OmniFocus 1 for Mac 5 2011-04-02 01:28 PM
Sync fails after initial sync on Windows Server 2008 [Server Bug] Shortie Other WebDAV 5 2009-07-16 09:20 AM
Two user interface pleas (please!) alanterra OmniFocus 1 for Mac 9 2007-12-09 02:15 AM


All times are GMT -8. The time now is 02:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.