back up file for a single file

#!/bin/bash


if [ -z "$1" ]
  then
    echo "No argument supplied"
exit
fi

BASENAME1=$(/bin/basename $1)
MYPATH1=$(/bin/pwd)
backupdir="$MYPATH1/backupdir"
mydate=$(date +"%m-%d-%y-%N")

if [ ! -d "$backupdir" ]; then
    mkdir $backupdir
fi
cp $MYPATH1/$BASENAME1 $backupdir/$BASENAME1-$mydate

No comments:

Other Articles

Enter your email address: