#!/bin/bash
DATE=$(date '+%m%d%y')
FILE=archive$DATE.tar.gz
CONFIG_FILE=/home/user/archive/Files_To_Backup //注解 Files_To_Backup 该文件里存放需要备份的目录,文件
DESTINATION=/home/user/archive/$File
#Check Backup Config file exists
if [ -f $CONFIG_FILE ]
then
echo
else
echo
echo "$CONFIG_FILE dose not exist."
echo "Backup not completed due to missing Configuration File"
echo
exit
fi
#Bulid the names of all the files to backup
FILE_NO=1
exec < $CONFIG_FILE
read FILE_NAME
while [ $? -eq 0 ]
do
if [ -f $FILE_NAME -o -d $FILE_NAME ]
then
#if the file exists,add its name to the list.
FILE_LIST="$FILE_LIST $FILE_NAME"
else
# if the file doesn't exist,issue waring
echo
echo "$FILE_NAME ,dose not exist."
echo "Obviously,I will not include it in this archive."
echo “It is listed on the line $FILE_NO of the config file”
echo "Continuing to build archive list...."
echo
fi
FILE_NO=$[$FILE_NO+1]
read FILE_NAME
done
#Backup the files and compress Archive
tar -czf $DESTINATION $FILE_LIST 2>/dev/null
在 /home/user/archive 会存在备份好的压缩文件,

594

被折叠的 条评论
为什么被折叠?



