The other day, I wrote this bash script; I thought it would be good to share it with others too, may save someone time or help somebody. I usually use it at the end of day to create a backup of the software package I developed during the day. Just run it with the directory address you’d like to create backup of as input and in a glimpse the backup tar.gz file will be ready at ~/backups/. Later, for more assurance you may upload your backups to an online repository site like box.net or filedropper.com.

The backup.sh script is:

#!/bin/bash          

SRCD=$1
TGTD=~/backups/

BASENAME=$(echo $1|rev|awk -F \/ ‘{print $1}’|rev)
if [ -z $BASENAME]; then
	BASENAME=$(echo $1|rev|awk -F \/ ‘{print $2}’|rev)
fi
OF=$BASENAME-$(date +%Y%m%d).tgz

tar -cZf $TGTD$OF $SRCD

Nothing special, just a simple backup script; Have a good day.

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Live
  • Reddit
  • StumbleUpon
  • Technorati
  • YahooMyWeb
  • Slashdot
  • TwitThis
  • E-mail this story to a friend!