Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need to create a secure remote connection to a couple of files (SFTP, WebDAV/HTTPS,…).

Users need to connect and edit those files by downloading->editing->uploading-replacing or, even better, by editing them in place (if WebDAV).

The server (Linux or as a last resort Mac OS X Server 10.6) should create revisions everytime files are updated/replaced: Is it possible?

Any suggestions would be greately appreciated.

share|improve this question

2 Answers 2

up vote 8 down vote accepted

You can use inotify cron(incron) and git(fast version control system)

Install icron:

sudo apt-get install incron

Install git:

sudo apt-get install git-core

Allow root use incron:

echo "root" > /etc/incron.allow

Create git repository:

mkdir /git
cd /git
git init

Create script to auto commit /usr/local/sbin/git-autocommit:

#!/bin/bash

REP_DIR="/git"
NOTIFY_DIR="/srv"

cd $REP_DIR
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git add .
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git commit -a -m "auto"

Add incron rules:

sudo incrontab -e
/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO /usr/local/sbin/git-autocommit

I like git and Ubuntu)

share|improve this answer
    
Shouldn't the middle steps actually be "mkdir /git; cd /git; git init;" - otherwise you're not creating the git repo in the correct folder? –  Coops Mar 1 '11 at 10:44
    
Yes, you are right –  ooshro Mar 1 '11 at 10:47
    
+1 I hadn't come across incron before and it definitely will simplify some scripts I have hanging around the place! –  Niall Donegan Mar 1 '11 at 11:39

You could use a version control system, like Subversion. However it will require users to use it, rather than straight file operations. Or you could use rsnapshot (or similar backup programme) to take hourly backups. You may loose some intermediate versions that way, but users won't have to use SVN.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.