#!/bin/bash
BACKUP=backup_date
SOURCE=Arithmetic_Operators
echo "Taking backup from ${SOURCE} directory to backup directory ${BACKUP} .."
# Checking the source directory ${SOURCE} exists or not ! if not exists die
# Script is unsuccessful with exit status # 1
[ ! -d $SOURCE ] && echo "source directory $SOURCE not found"
exit 1
# Checking the backup directory ${BACKUP} exists or not ! if not exists die
# Script is unsuccessful with exit status # 2
[ ! -d $BACKUP ] && echo "backup directory $BACKUP not found"
exit 2
# Let Start the backing up
tar cvf $SOURCE $BACKUP 2> /wrong/logs.txt
if [ $? -ne 0 ]
then
# die with unsuccessful shell script termination exit status # 3
echo "An error occurred while making a source directory backup, see /wrong/logs.txt file".
exit 3
fi
这是我的脚本源目录(Arithmetic_Operators)备份到目标目录(backup_date),运行脚本我的脚本与消息结束而shell脚本备份源目录备份目录
以备份从Arithmetic_Operators目录备份目录backup_date ..
源目录Arithmetic_Operators找不到
在那里我没有错,为什么牛逼他的脚本没有运行,你能帮我解决吗?
最proabably没有目录'Arithmetic_Operators '在你启动脚本的目录中。 –
谢谢Gerald !!,同时脚本没什么问题,它可能是目录不在路径上或目录本身不存在的问题。 – PradyJord
谢谢Pradyjord – viswa