backup one file ( v2 )
#!/bin/bash
if [ -z "$1" ]
then
echo "No argument supplied"
exit
fi
FULLPATH=$(/usr/bin/readlink -f $1)
BASENAME1=$(/bin/basename $FULLPATH )
MYPATH=$(/usr/bin/dirname $FULLPATH)
backupdir="$MYPATH/backupdir"
mydate=$(date +"%m-%d-%y-%N")
if [ ! -d "$backupdir" ]; then
mkdir $backupdir
fi
cp $MYPATH/$BASENAME1 $backupdir/$BASENAME1-$mydate
echo " copied to $backupdir/$BASENAME1-$mydate"
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
Subscribe to:
Posts (Atom)