rmayr / dvcs-autosync

dvcs-autosync is a project to create an open source replacement for Dropbox/Wuala/Box.net/etc. based on distributed version control systems (DVCS). It offers nearly instantaneous mutual updates when a file is added or changes on one side but with the added benefit of (local, distributed) versioning and does not rely on a centralized service provider.
http://www.mayrhofer.eu.org/dvcs-autosync
Other
98 stars 14 forks source link

What does it do?

Automatically keep DVCS repositories in sync whenever changes happen by automatically committing and pushing/pulling.

How does it do it?

  1. Set up desktop notifications (for these nice bubble-style popups when anything happens) and log into a Jabber/XMPP account specified in the config file.

  2. Monitor a specific path (and its subdirectories) for changes with inotify. At the moment, only one path is supported and multiple script instances have to be run for multiple disjoint paths. This path is assumed to be (part of) a repository. Currently tested with git, but should support most DVCS (the config file allows to specify the DVCS commands called when interacting with it). Optionally, an [ignores] file is read with one exclusion pattern per line and files matching any of the patterns are ignored. This will typically be the .gitignore file already existing the git tree.

  3. When changes are detected, check them into the repository that is being monitored (or delete, or move, etc.). It automatically ignores any patterns listed in .gitignore and the config file allows to exclude other directories (e.g. repositories within the main repository).

  4. Wait for a configurable time. When nothing else changes in between, commit.

  5. Wait a few seconds longer (again configurable) and, if nothing else is commited, initiate a push.

  6. After the push has finished, send an XMPP message to self (that is, to all clients logged in with the same account) to notify other accounts of the push.

Furthermore:

Dependencies

Linux:

Mac OS X:

Recommended:

Installation

(on Mac OS X, see INSTALL_MAC file for detailled instructions)

[PREFERRED] PACKAGE INSTALLATION

MANUAL INSTALLATION

Create the repository and do initial push

[on the server used to host the central git repository] $ git init --bare autosync.git

[on the first host using that repository] $ cd ~ && git clone :autosync.git autosync $ cd autosync $ [ populate initial contents and add to index ] $ git commit -m 'Initial commit' $ git push origin master

[on each additional host] $ git clone :autosync.git autosync

Note that these are only examples. You can use arbitrary directories and repositories.

Configuration

Running the program

autosync.py [config file] # config defaults to ~/.autosync

Potential pitfalls

Thoughts that should be considered at some point but have not yet been implemented:

Disclaimer

This is my first Python program that is longer than 100 lines. Please be easy on me with the patches, complaints and "what did you think, doing it this way?" messages. I have tried to comment wherever I found it necessary for my own understanding, but this is neither the best structured nor the most elegant program I ever wrote. Any hints for improving it are greatly welcome, and interoperability patches to work with Sparkleshare even more so. In the future, the two projects should definitely interoperate, which will come done to implementing each other's notification mechanism. My autosync Python script could then be used wherever headless operation might be required and/or Mono is not installed. I have tested it between three systems and, in this version, it works reasonably well. However, there does seem to be the occasional kink when editors go crazy on temporary file creation, renaming, deleting originals, etc. These might be races, but I don't know for certain yet. Additional test cases are more then welcome. This script should be fairly safe to try, considering that the worst it will do is add a few hundred commits to your DVCS repo and push them to the configured default remote. But, after all, what is the point in using a DVCS if you can't roll back any changes made by you or a buggy script (yes, I did have to do that a number of times while developing the manual inotify event coalescing to cooperate better with git add/remove/mv actions).

Rene Mayrhofer rene@mayrhofer.eu.org