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.
In this blog (a.k.a Cube) I’m going to freely talk about almost everything I happen to face in my daily life. As I’m in the field of Computer science and IT, my posts are more likely to be about computers, Web2.0, IT and open source applications.
Thank you for visiting and don't forget to subscribe for Cube blog feeds.
Tama
October 29th, 2008 at 7:46 am
Interesting to know.