Copy data and create directory


 

A script to copy data and create a directory

 

today_date=`date +%e%m%y`

#trims the space when date start with a 0
current_date=”${today_date#”${today_date%%[![:space:]]*}”}”

# The directory that the orders will be backed upto
backup_directory=/home/nisbets_copyorders/$current_date
# The backup home directory
backup_directory_home=/home/copyorders
# The directory to copy the orders to
to_directory=/home/incoming
# The directory to copy the orders from
from_directory=/home/xxx/incoming

echo $current_date
echo $backup_directory
echo $to_directory
echo $from_directory

cd $backup_directory_home
#if the backup directory exists then don’t do anything, if it does not then create it
if [ ! -d “$backup_directory/” ]; then
cd $backup_directory_home
mkdir $current_date
fi

cd $from_directory
cp $from_directory/* $to_directory/
cp $from_directory/* “$backup_directory/”

rm -f /home/xxx/incoming/*

 

 

 

 

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s