WDCP自动备份数据库脚本

2018-12-1811:56:31 发表评论 536

WDCP后台也有备份数据库和网站的任务,这个是我以前自已用的手动的

文件名是 backup.sh 以下是内容:



#!/bin/sh

if [ ! -d "/www/backup" ]; then
mkdir "/www/backup"
fi

time=$(date +%Y%m%d%H%M%S)

# Backup project
tar zcvf /www/backup/public_html-${time}.tar.gz /www/web/您的网站名/public_html

if [ -f "/www/backup/public_html-${time}.tar.gz" ]; then
echo "It's successful to backup web! ok!!"
else
echo "Backup web fail! no!!"
fi

# Backup database
mysqldump -u数据库名 -p"数据库密码" -hlocalhost we_car > /www/backup/we_car-${time}.sql

if [ -f "/www/backup/备份文件名-${time}.sql" ]; then
echo "It's successful to backup database! ok!! "
else
echo "Backup database fail! no!!"
fi

发表评论

您必须登录才能发表评论!