服务器备份脚本
Web备份:
除去指定不要备份文件
#!/bin/sh
#Backup directory
BACK_DIR=/data/backup/web_backup
WEB_DIR=/data/www/wwwroot/erjihuibar.h863.net
EX1=”wwwroot/erjihuibar.h863.net/angelupload”
TAR=”/bin/tar”
TAR_FLAG=”-czf”
###################Backup############################
if [ ! -d $BACK_DIR ];then
mkdir -p $BACK_DIR
fi
#sleep 5
COMM=”$TAR –exclude $EX1 $TAR_FLAG $BACK_DIR/web-`date +%Y%m%d`.tar.gz wwwroot/erjihuibar.h863.net”
cd /data/www
eval $COMM
#delte old web
find $BACK_DIR -name “web-*.tar.gz” -mtime +15 |xargs rm -rf
Mysql备份:
#!/bin/bash
#Backup directory
BACK_DIR=/data/backup/db_backup
DB_DIR=/data/mysql/data
TAR=”/bin/tar”
TAR_FLAG=”czf”
if [ ! -d $BACK_DIR ];then
mkdir -p $BACK_DIR
fi
COMM=”$TAR $TAR_FLAG $BACK_DIR/db-`date +%Y%m%d`.tar.gz data/h863_erjihui_bar/”
cd /data/mysql
eval $COMM
find $BACK_DIR -name “db-*.tar.gz” -mtime +15 |xargs rm -rf