You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

git-backup 521B

123456789101112131415161718192021222324252627282930313233
  1. #! /usr/bin/env sh
  2. configFile=/etc/git-backup.conf
  3. initPath()
  4. {
  5. cd "$1" &&
  6. if [ ! -e .git ]
  7. then
  8. git init &&
  9. git remote add origin git:backup/$(hostname)$(pwd | tr '/' '-')
  10. fi
  11. }
  12. if [ $# -eq 1 ] && [ "$1" = "--init" ]
  13. then
  14. while read path
  15. do
  16. initPath "${path}"
  17. done < "${configFile}"
  18. exit
  19. fi
  20. while read path
  21. do
  22. echo "Backing up ${path}..."
  23. cd ${path} &&
  24. (
  25. git add -A
  26. git commit -m "[GIT-BACKUP] $(date)"
  27. git push origin master --quiet
  28. )
  29. done < "${configFile}"