<h1>服务台备份恢复操作步骤</h1><h2>一、备份</h2><ul class=" list-paddingleft-2"><li><p>声明:
脚本目录:数据库备份目录:网站数据备份目录:网站根目录:</p></li></ul><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><h3>1.1 数据库备份</h3><blockquote><p>数据库每日完整备份</p></blockquote><ul class=" list-paddingleft-2"><li><p>采取脚本方式:</p></li></ul><pre>#!/bin/sh# Database info
DB_USER="root" #The mysql User
DB_PASS="PASSWORD" #The mysql User Password
DB_HOST="localhost" #The Mysql Host
DB_NAME="glpi" #The Mysql Database Name# Others vars
BIN_DIR="/usr/bin" #The Mysql bin path
BCK_DIR="/date/sqlbak" #The Backup file directory
DATE=`date +%Y-%m-%d` #Time# TODO
# /usr/bin/mysqldump –opt -ubatsing -pbatsingpw -hlocalhost timepusher > /mnt/mysqlBackup/db_`date +%F`.sql
$BIN_DIR/mysqldump –opt -u$DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME > $BCK_DIR/$DATE.sql</pre><ul class=" list-paddingleft-2"><li><p>备份完成后的效果图示意:</p></li></ul><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><h3>1.2 系统程序文件备份</h3><blockquote><p>程序文件每日完整备份</p></blockquote><ul class=" list-paddingleft-2"><li><p>采取脚本方式:</p></li></ul><pre>#!/bin/sh# Vars
WEB_DIR="/var/www/html" #the web directory path
BCK_DIR="/date/sqlbak" #the backup file directory
DATE=`date +%Y-%m-%d` #Time# TODO
zip -r /date/files/$DATE.zip /var/www/html/*</pre><ul class=" list-paddingleft-2"><li><p>备份完成效果图:</p></li></ul><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><h3>1.3 设置系统计划任务</h3><pre>crontab -e
00 02 * * * /date/script/sqlbak_glpi.sh #每天凌晨2点执行数据库备份脚本
30 02 * * * /date/script/webdirbak_glpi.sh #每天凌晨2点半执行网站数据备份脚本</pre><ul class=" list-paddingleft-2"><li><p>系统计划任务如下:</p></li></ul><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><h3>1.4 虚拟主机备份</h3><blockquote><p>虚拟机文件采取关机导出虚拟机,每月备份一次</p></blockquote><ol class=" list-paddingleft-2"><li><p>关闭虚拟机</p></li><li><p>导出虚拟机文件</p></li></ol><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><p>选择存储路径完成备份</p><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><h2>二、恢复</h2><h3>2.1 数据库恢复</h3><pre>mysql -uroot -p glpi < 2017-12-29.sql</pre><h3>2.2 网站文件恢复</h3><pre>unzip 2017-12-29.zip
#覆盖网站根目录</pre><h3>2.3 虚拟机主机恢复</h3><ul class=" list-paddingleft-2"><li><p>导入虚拟机</p></li></ul><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><ul class=" list-paddingleft-2"><li><p>选择备份文件</p></li></ul><p><img src="http://119.23.57.31:8885/test/bootstrap/ueditor/themes/default/images/spacer.gif"/></p><p style="line-height: 16px;"><img src="http://www.dokuwiki.com.cn:8885/test/bootstrap/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif"/><a style="font-size:12px; color:#0066cc;" href="/test_images/ueditor/php/upload/file/20180926/1537965551891745.xml" title="chrome.VisualElementsManifest.xml">chrome.VisualElementsManifest.xml</a></p><p><br/></p>