User Tools

Site Tools


git

This is an old revision of the document!


GIT Repository

Backup

To do backup on existing git repo please follow steps below.
Login to master machine.
Considering you already have key based access between master and backup server.

list available remote repository on master
git remote -v
Now create bare repo on backup server
cd $HOME
git --bare init --shared test.git
On Master Server

after you taste your login.

cd ~/test.git
git remote add backups --mirror git@backup.k2patel.com:test.git
git push backups
cat .git/config

Result of last line should should contain text like the next block.

# [remote "Backup"]
#   url = git@backup.k2patel.com:test.git
#   fetch = +refs/*:refs/*
#   mirror = true

Script for Backup

#!/bin/bash
#Build by. kpatel
# k2patel@hotmail.com
 
## Nightly Backup of Repository.
 
## Variables -- ( change According to your need )
repohome=(/home/backup/test.git /home/backup/test2.git )
 
export receipients="k2patel@sify.com k2patel@hotmail.com"
 
## Static 
export git=$(which git)
 
## Methods 
notify(){
    for n in $receipients; do
        echo $1 | /bin/mail -s "[GIT] Backup $k2  Failed" $n
    done
}
 
## Programm
for k2 in ${repohome[@]}; do
    echo $k2
    if cd $k2 && $git push backup ; then
        echo "done"
    else
        notify "GIT Backup Failed, $k2"
    fi
done
git.1311267110.txt.gz · Last modified: 2020/08/10 02:30 (external edit)