今天要跟朋友们分享的是linux shell 目录备份脚本,希望对朋友们有所帮助!下面一起来看看吧!
linux shell 目录备份脚本:
#!/bin/bash
#this shell is create by ben@enmuo.cn
filename=`date +%Y%m%d%H%M%S`
echo -n "please input backup directory name:"
read directory
if [ ! -d $directory ]
then
echo 2>&1 >> /dev/null
echo -e "\033[41;37;5m $directory is not in thid directory ,please check your input!\033[0m"
else
tar -cf $directory-$filename.tar $directory
fi
if [ -f $directory-$filename.tar ]
then
echo "$directory backup successed ! backup name is $directory-$filename.tar"
else
echo -e "\033[41;37;5m warning $directory backup fail,please check!\033[0m"
fi
支持( 0 ) 盖楼(回复)