Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.00 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2. # This post-commit hook is designed to serve as a central script for any repository you want to backup (via git bundle)
  3. # based on the original idea of David Gageot https://gist.github.com/736547
  4.  
  5. # Backup configuration
  6. backupRoot="$HOME/Mes documents/My Dropbox/gitbackup/"
  7. #howManyTime=--since=5.days
  8. howManyTime=-10
  9. branchToBackup=master
  10.  
  11. # After some testing (under msysgit only for the moment), it seems like whereever you commit, the post-commit hook
  12. # always gets executed from the repository root.
  13. # So, let's just take the repository directory name for the bundle.Even when pwd
  14. currentDirectory=`pwd`
  15. backupFileName=`basename $currentDirectory`
  16. git bundle create "$backupRoot$backupFileName" $howManyTime $branchToBackup
  17.  
  18. echo "Backup ok (time=$howManyTime,branch=$branchToBackup)"
  19.  
  20. # TODO/IDEAS
  21. # * Externalize backup script, so that one can decide how&where he wants to backup
  22. # * support many branches to backup if specified
  23. # * Use default "git config" properties to get non-default values for this script