#!/bin/sh
bakPath="/usr/local/upload_backup/"
echo "bakPath is $bakPath"
filePathName=`date +%Y_%m_%d`
echo "filePathName is $filePathName"
fileName=pics_`date +%Y_%m_%d.tar`
echo "fileNameis $fileName/fileName "
echo " $bakPath$filePathName/$fileName "
sourceDir="/usr/local/upload"
echo "fsourceDir is $sourceDir "
BACKUP_DIR="/usr/local/"
echo "{BACKUP_DIR} is ${BACKUP_DIR} "
if [ ! -d "$bakPath" ]; then
echo "/usr/local/upload_backup"
mkdir "$bakPath"
echo "$bakPath文件夹创建成功"
else
echo "$bakPath文件夹已经存在"
fi
if [ ! -d "$bakPath`date +%Y_%m_%d`" ]; then
echo "/usr/local/upload_backup"
mkdir "$bakPath`date +%Y_%m_%d`"
echo "$filePathName文件夹成功"
else
echo "$filePathName文件夹已经存在"
fi
cd ${BACKUP_DIR}
BAK_FLAG=0
checkRead(){
if [ $MAX_NO -ne 0 -a $MAX_NO -ne 1 ] ; then
actionRead
fi
}
actionRead(){
echo -n "是否备份已上传图片?是请输入1;否请输入0 "
read MAX_NO
checkRead
}
actionRead
if [ $MAX_NO -eq 1 ] ; then
tar -czvPf $bakPath$filePathName/$fileName $sourceDir
fi
http://www.cnblogs.com/qq78292959/archive/2011/07/06/2099427.html tar指令解释