Working with Ubuntu

Web-based viewer for git

Posted in git by nigelbabu on July 21, 2010

I’ve been looking for a simple to set up viewer for git that would list out all the git repositories that I have on my git server.  It took a bit of a search and I finally discovered viewgit.  So far, I’ve found it pretty nice.  Setting up viewgit is very simple.

Download the tarball from sourceforge.  Extract it to your htdocs or www folder.  Make a copy of example-localconfig.php and rename it as localconfig.php.  Comment out the line $conf['projects'] and uncomment $conf['projects_glob'] = array('/path/to/repo/); . If like me, you store all your git repos in one folder, this is the best viewer for the amount of work I’ve had to do. Maybe I should write about how to store git repos in one folder. A story for tomorrow!

Tagged with:

Automatic database backup

Posted in git, xampp by nigelbabu on July 20, 2010

I use git extensively for version control.  Its nice to use git since it backs up the code, but the database still remains unversioned.  Well, thankfully, XAMPP has a script that does a database dump.  So, I wrote a script to do the dump and then commit it to git.

Big Ben by vgm8383 on flickr

Big Ben by vgm8383 on flickr. Used under Attribution-NonCommercial 2.0 Generic license

Step 1
Create a directory in the home directory for the database dump

~$ mkdir projectname-database
~$ cd projectname-database

Step 2
Initialize git in the directory

~$ git init

Step 3
Do a database dump for the initial commit

~$ /./opt/lampp/bin/mysqldump -u root database-name > database.sql

Step 4
Commit the database file

~$ git add .
~$ git commit -a -m "Initial database commit"

Step 5
Now we’ll write a script to do the database dump and add commits. Open your favorite text editor and write the following script. Save the file as probably “database-project” in your home folder

#!/bin/bash
/opt/lampp/bin/./mysqldump -u root database-name > /home/username/projectname-database/database.sql
cd /home/username/projectname-database/
git commit -a -m "Database dump at `date`"

Save the script so that you can run it via a cron.

Step 6
Open crontab with the following command

~$ crontab -e

Step 7
Add the following line

00,30 * * * * /home/username/./database-project

This cron will run the script every 30 minutes.

Basically what happens here is the database dump will be taken every 30 minutes and the change will be committed to a git repository allowing you to keep track of the overwriting. I’ve found it quite useful and I hope you will too.

Tagged with: , , , ,
Follow

Get every new post delivered to your Inbox.