Monday, May 5, 2008

Git as a backup tool

Recently migrated from CVS to GIT at work, and started to look at other uses of local GIT repositories. Backing up config files in home directories seemed a natural application, and as usual someone else has thought of it, implemented it, and abandoned it:

git-home-history

Getting this built is pretty straightforward:
cd /usr/src
git clone http://jean-francois.richard.name/ghh.git
cd ghh
./autogen.sh
make
make install
cd ~
git-home-history init
vi .gitignore
git commit -a
crontab -e
* */4 * * * /usr/local/bin/git-home-history commit >/dev/null 2>&1


The last line is what should be added to crontab to run this every 4 hours.

There are similar projects for /etc and for general backup:
etckeeper
gibak

Other useful GITisms:
* install tgit
* install qgit
* get vim syntax and filetype plugins from vim-mode-for-git-commits; also check out the GitDiff plugin
* add the following to ~/.bashrc or equivalent:
GIT_PAGER=`which tig`
export GIT_PAGER
* add the following to ~/.vimrc or equivalent:
let git_diff_spawn_mode=1
autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=git

No comments:

Post a Comment