This is an old revision of the document!
backing up repository
notes
- do NOT use rsync
- git is smarter about what needs copied and will be faster
- a commit or other action could be in progress
using a hook
- you have a myproject directory containing the .git repository, and would like to back up the repository contents
- create the backup repo
cd /backup/destination git init --bare myproject.git
- do the initial push of your project to the backup repo
cd /myproject git push --all --force /backup/destination/myproject.git
- in your local git repo, make a copy of the .git/hooks/post-commit file and modify it similar to this
# assuming you have a mount point at /gitshare echo -e "backing up repo...\n"; git push --all --force /backup/destination/myproject.git
without changing local repo
- you have a myproject directory containing the .git repository, and would like to back up the repository contents
- clone your project as a “mirror”
cd /backup/destination git clone --no-hardlinks --mirror /path/to/myproject backupfoldername
- work, work, work
- commit inside myproject
- time to backup…go to the backup directory and “fetch” the project
cd /backup/destination/backupfoldername git fetch