Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
docs:git:backing_up_repository [2009/10/19 23:46] – created billh | docs:git:backing_up_repository [2010/05/28 11:28] (current) – billh | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== backing up repository ====== | ====== 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 / | ||
+ | git init --bare myproject.git | ||
+ | </ | ||
+ | * do the initial push of your project to the backup repo< | ||
+ | cd /myproject | ||
+ | git push --all --force / | ||
+ | </ | ||
+ | * in your local git repo, make a copy of the .git/ | ||
+ | # assuming you have a mount point at /gitshare | ||
+ | echo -e " | ||
+ | git push --all --force / | ||
+ | </ | ||
+ | |||
+ | ===== without changing local repo ===== | ||
* you have a myproject directory containing the .git repository, and would like to back up the repository contents | * you have a myproject directory containing the .git repository, and would like to back up the repository contents | ||
* clone your project as a " | * clone your project as a " | ||
Line 12: | Line 35: | ||
</ | </ | ||
- | ===== notes ===== | + | ===== automating backup of many repos ===== |
- | * don't use rsync, because | + | * you have many projects that you want to backup, like to a usb drive |
+ | * clone each project< | ||
+ | cd / | ||
+ | git clone --mirror / | ||
+ | </ | ||
+ | * create a shell script (i.e. **pullall.sh**) to loop through each project and fetch< | ||
+ | #!/bin/sh | ||
+ | |||
+ | `which ls` -1d *.git | while read item;do | ||
+ | echo -e " | ||
+ | cd " | ||
+ | git fetch --all --force | ||
+ | cd .. | ||
+ | done | ||
+ | </ | ||
+ | * run the script with ./ |