summaryrefslogtreecommitdiff
path: root/git_backup/git_backup.sh
blob: 5082b9b2eb690bc810fa57ba32502c2377876e73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# https://git.seveas.net/how-to-back-up-a-git-repository.html

#But even if you do not have the capability to do snapshots, you can still make consistent backups, as long as you back up objects after refs. You might end up with some dangling objects, but your repository will be consistent and all refs will point to existing objects. With rsync, that could look like:

TIMESTAMP=$(date +%Y%m%d%H%M%S)
INPUT=comet:/var/lib/gitolite/repositories
OUTPUT=~/comet_git_backup/$TIMESTAMP

echo BACKING UP REFS etc ...
rsync -av --delete --exclude "*/objects" $INPUT $OUTPUT
echo BACKING UP OBJECTS AFTER REFS
rsync -av --delete --include "*/" --include "*/objects/**" --exclude "*" $INPUT $OUTPUT
#rsync -av --delete --include '/*/objects' --include "/*" --exclude '/*/*' $INPUT $OUTPUT
#rsync -av --delete --include '/*/objects/*' --exclude '/*/*/*' $INPUT $OUTPUT