Below is the script for creating .tar archives of the directories containing files, I have coded this script to create .tar archive of the RADIUS bill files.
This script simple create .tar (without compressing it) and later gzip filename could be used to compress the .tar files.
Script require one argument in the form of YYYYMM to create tar archive of all the directories for the specific month of the year.
For example to run, in the current directory
./billfiles 200912 <---will create .tar archives of all the directories in the current directory which have name like 200912*
The script
#!/usr/bin/bash
# Author: Askar Ali Khan
# Date: 2009-02-10
# Purpose: To create tar of bill files
# billfiles
SOURCEDIR="/export/home/backup_billdb/bb_bill_backup"
if [ ! "$1" ]
then
echo "Must provide correct month"
echo "Format: YYYYMM Eg, 200901"
exit 0
else
if [ ! -d "$SOURCEDIR"/"$1" ]
then
echo "Directory does not exists,creating ...."
mkdir "$SOURCEDIR"/"$1"
else
echo "Directory already exists"
exit 0
fi
# Creating tar
for f in "$1"*
do
echo "Making $f.tar, please wait..."
tar cvf "$SOURCEDIR"/"$1"/"$f".tar "$f"
done
fi
No comments:
Post a Comment