Sunday, February 3, 2013

Backup your GIT Repositories

Hello,

We most of us use GIT as version control for our projects. Many of us use github or our own servers for managing git repositories.

If you are using github, then github will take care of backing up your repositories. But if you are having your own server for storing your repositories, then you need to ensure that the repositories are being backed up regularly (may be once or twice in a day).

There are various options through which you can backup your git by using git bundle or other rails scripts. As i am looking at different options i found out (actually my friend Prashant found this) git clone using mirror option. This basically mirrors your git repository including all branches.

Below is a simple script which will basically backup all the git repositories present in a specific location into FTP drive.


#!/bin/bash
# GIT Backup Script
# Copyright (c) 2012-2013 Asif Noor (asif@azrisolutions.com)
# This script is licensed under GNU GPL version 2.0 or above. 

current_date=`date +%d-%m-%Y-%H-%M-%S`
echo GIT Backup Started $current_date >> /var/log/git-backup.log
### Enable backups ###
BAKGIT="1"
GIT_CODEBASE_DIR="GIT_DIR" //example: "/opt/git/"
GIT_CREDENTIALS="username:passwd"
backup_dir="/backup/git/"
cd $GIT_CODEBASE_DIR
for file in *.git; do 
  file_backup=$file"_backup.git"
  //The below command will mirror the entire git including branches.
  git clone --mirror $GIT_CODEBASE_DIR$file $file_backup
  tar cf $file_backup.tar $file_backup
  bzip2 $file_backup.tar
  mv $file_backup.tar.bz2 $backup_dir  
  echo $file_backup
  rm -rf $file_backup
done

BAKFILES="0"
BAKENCRYPT="0"
BAKFTP="1"
BAKDELETE="1"

### FTP server Setup ###
FTPD="//incremental"
FTPU="FTPUSER"
FTPP="FTPPASS"
FTPS="FTPHOST"
NCFTP="$(which ncftpput)"

### SYSTEM STEUP ###
HOST="$(hostname)"
NOW=$(date +"%Y%m%d-%H%M%S")
EMAILID="mail@email.com"

### Dump backup using FTP ###
#Start FTP backup using ncftp
if [ "$BAKFTP" -eq "1" ]
then
ncftp -u"$FTPU" -p"$FTPP" $FTPS<
mkdir $HOST
mkdir $HOST/$NOW
cd $HOST/$NOW
lcd $backup_dir
mput *
quit
EOF
fi

current_date=`date +%d-%m-%Y-%H-%M-%S`
echo Backup Ended $current_date >> /var/log/git-backup.log

NOTE: In the script, you need to put the actual logins to get it working. If you do not have ftp drive, you can copy to other server as well. Do let me know your comments about the script. 


Friday, January 20, 2012

ctrl + s hangs the shell, then press ctrl +q to resume

Many of you who are familiar with Emacs(ctrl +x and ctrl +s) or Windows (ctrl +s), have an habit of pressing ctrl+s often. If you are in a shell and type ctrl +s, the shells freezes and does not allow anything to be edited.

To unfreeze the shell, press ctrl +q instead of closing the session.

Hope this helps

Thursday, March 10, 2011

Day 3 at Drupalcon

Day 3 also i attended more BoFs, met different project managers discussed about planning, tools, estimations, etc

I went to every booth, collected stickers, T-shirts from different companies.

Overall, the experience of Drupalcon is great as i get a chance not only to meet drupal developers across the world but also there are many new things that i come to know and learn.

There are popular drupal distros such as atrium, open public, open publish available which are being used by so many people across the world. For testing, automated testing being used using selenium, walter , automated deployment using hudson/jenkins

Next Drupalcon is going to happen in London and after that it is going to be in North America (Denver).

Day 2 at Drupalcon

On Day 2, i participated more in BoFs as we can always view the sessions online. Discussed with different people, attended day stage.

Day 2 was quite fun and exciting as i got a chance to talk with different drupal core developers and contributors.


Me and Angie Byron (Webchik)


Me and Angie Byron (this pose was suggested by Webchik)


Me with Core Drupal developers


Me and Atrium core developer (Jeff)


Me and Pantheon Core Developer

Day 1 at Drupalcon

The day started well with Dries keynote. View Dries keynote here.

http://chicago2011.drupal.org/keynote-dries-buytaert

Dries discussed about D8, co-maintainer, roadmap of D8, etc.

After that, i got a chance to get hold of Dries for a minute. Had an quick talk with him on Drupal 8, object orientation of drupal, new features in D8 and his visit to India. Took a quick snap with him :)

Sunday, March 6, 2011

1st Day in Chicago

Hey guys, Landed in chicago last night along with prajwala to attend the Drupalcon. For those who don't know what is Drupal, here is a small writeup.

"DrupalCon is the twice-yearly gathering of Drupalers to learn about, discuss, and advance Drupal, and to network with other Drupal community members. There, you will have the opportunity to meet Drupal community leaders, top developers, your favorite module maintainers, dojo trainers, members of the Drupal association, potential business partners, and future employees!"

Travel was quite okay with no hiccups at London or at immigration in US. It was smooth than expected.

By the time we come out of immigration it was past 10 pm and we have been welcomed with cold weather, heavy winds and snow :)

Checked in hostel, got settled. Was feeling hungry. Thought both us of make a maggi. As you all aware, it is the most easiest food to prepare :) But unfortunately it was not the case with us :)

We screwed up 2 maggi packages by making some part of it overcooked and some part of it semi-cooked. Result, no food. Had few snacks which we bought from home.

Today, will go out , check out chicago and get use to the weather.

Keep you updated about drupal and my adventures :)

In Chicago

Hey guys, Landed in chicago last night to attend the Drupalcon.

"DrupalCon is the twice-yearly gathering of Drupalers to learn about, discuss, and advance Drupal, and to network with other Drupal community members. There, you will have the opportunity to meet Drupal community leaders, top developers, your favorite module maintainers, dojo trainers, members of the Drupal association, potential business partners, and future employees!"

Travel was quite okay with no hiccups at London or at immigration in US. It was smooth than expected.

In Chicago

When we come out of immigration it was night around 9 pm and we have been welcomed with cold weather, heavy winds and snow :)

Presently staying in hostel, which has free wifi :)