
Untitled
By: a guest on
Apr 26th, 2012 | syntax:
None | size: 1.00 KB | hits: 13 | expires: Never
#!/bin/sh
# This post-commit hook is designed to serve as a central script for any repository you want to backup (via git bundle)
# based on the original idea of David Gageot https://gist.github.com/736547
# Backup configuration
backupRoot="$HOME/Mes documents/My Dropbox/gitbackup/"
#howManyTime=--since=5.days
howManyTime=-10
branchToBackup=master
# After some testing (under msysgit only for the moment), it seems like whereever you commit, the post-commit hook
# always gets executed from the repository root.
# So, let's just take the repository directory name for the bundle.Even when pwd
currentDirectory=`pwd`
backupFileName=`basename $currentDirectory`
git bundle create "$backupRoot$backupFileName" $howManyTime $branchToBackup
echo "Backup ok (time=$howManyTime,branch=$branchToBackup)"
# TODO/IDEAS
# * Externalize backup script, so that one can decide how&where he wants to backup
# * support many branches to backup if specified
# * Use default "git config" properties to get non-default values for this script