lunedì 13 settembre 2010

Backup dir with tar and date inclusion

It’s a study I made related to shell scriptting. It’s a simple backup script of a directory that compresses and puts the date on the file name.
Here the code:

#!/bin/sh
#               scimanse.sh
# author....: Muratore Alessandro
# email.....: muratore.ale@gmail.com
# project...: studies related to shell scripting
# title.....: simple backup dir with tar and date inclusion
#
bck_date="backup-%(date '+%d-%m-%y').tar.gz" 

# setting up the name of your backup with
# date inclusion 

dir_data="/var/www/apache/htdconf"   

# dir where you have files for backuping 

dir_bck="/mnt/pendrive"     

# setting up pendrive device for your backup
# change /mnt/pendrive with /cdrom or
# /home/backup or what you want.  

echo " Starting compression and backup of $dir_data..."
tar zcvf $dir_bck/$bck_date $dir_data
echo " Finish compression and backup of $dir_data."
echo "You can find your backup: $dir_bck."

Nessun commento:

Posta un commento