Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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<code> cd /backup/destination git init --bare myproject.git </code> * do the initial push of your project to the backup repo<code> cd /myproject git push --all --force /backup/destination/myproject.git </code> * in your local git repo, make a copy of the .git/hooks/post-commit file and modify it similar to this<code> # assuming you have a mount point at /gitshare echo -e "backing up repo...\n"; git push --all --force /backup/destination/myproject.git </code> ===== 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"<code> cd /backup/destination git clone --no-hardlinks --mirror /path/to/myproject backupfoldername </code> * work, work, work * commit inside myproject * time to backup...go to the backup directory and "fetch" the project<code> cd /backup/destination/backupfoldername git fetch </code> ===== automating backup of many repos ===== * you have many projects that you want to backup, like to a usb drive * clone each project<code> cd /path/to/your/usb/drive/destfolder git clone --mirror /project.git </code> * create a shell script (i.e. **pullall.sh**) to loop through each project and fetch<code> #!/bin/sh `which ls` -1d *.git | while read item;do echo -e "updating ${item}...\n" cd "${item}" git fetch --all --force cd .. done </code> * run the script with ./pullall.sh (make sure it is executable: chmod 755 pullall.sh) docs/git/backing_up_repository.txt Last modified: 2010/05/28 11:28by billh