文件备份与更新
vi file-back
#!/bin/bash
date=`date +%Y-%m-%d` #取当前日期
time=`date +%H-%M` #取当前时间
mc=/usr/local/mc
backdir=/data/backfile
newdir=/data/fileserver
mkdir -p /data/backfile/$date/mc
mc-back()
{
printf "mc-server back start...\n"
cd /usr/local && tar -cf $backdir/$date/mc/mc-server_$time.tar mcserver
}
mc-up()
{
printf "mc-server Being updated...\n"
cp -r $newdir/mc/* $mc
if [ "$1" = "mc-back" ]; then
mc-back
elif [ "$1" = "mc-up" ]; then
mc-up
else
printf "Usage: /app/shell/file--back {mc-back|mc-up}\n"
fi
date=`date +%Y-%m-%d` #取当前日期
time=`date +%H-%M` #取当前时间
mc=/usr/local/mc
backdir=/data/backfile
newdir=/data/fileserver
mkdir -p /data/backfile/$date/mc
mc-back()
{
printf "mc-server back start...\n"
cd /usr/local && tar -cf $backdir/$date/mc/mc-server_$time.tar mcserver
}
mc-up()
{
printf "mc-server Being updated...\n"
cp -r $newdir/mc/* $mc
if [ "$1" = "mc-back" ]; then
mc-back
elif [ "$1" = "mc-up" ]; then
mc-up
else
printf "Usage: /app/shell/file--back {mc-back|mc-up}\n"
fi
转载于:https://blog.51cto.com/cqfish/166263