mirror of https://github.com/einverne/dotfiles.git
Ein Verne
7 years ago
2 changed files with 11 additions and 7 deletions
@ -1,32 +1,34 @@
|
||||
#!/bin/bash |
||||
|
||||
# This script creates a compressed backup archive of the given directory and the given MySQL table. More details on implementation here: http://theme.fm |
||||
# 发邮件方式备份网站数据 |
||||
# 脚本会创建一个压缩包,包含备份的目录和MySQL 数据库备份 |
||||
# Feel free to use this script wherever you want, however you want. We produce open source, GPLv2 licensed stuff. |
||||
# Author: Konstantin Kovshenin exclusively for Theme.fm in June, 2011 |
||||
# https://theme.fm/a-shell-script-for-a-complete-wordpress-backup/ |
||||
|
||||
# Set the date format, filename and the directories where your backup files will be placed and which directory will be archived. |
||||
# 设置备份文件名 |
||||
NOW=$(date +"%Y-%m-%d-%H-%M") |
||||
FILE="www.einverne.info.$NOW.tar" |
||||
GZ_FILE=$FILE.gz |
||||
# 备份文件压缩包存放路径 |
||||
BACKUP_DIR="/root/backups" |
||||
# 需要备份的路径文件夹 |
||||
WWW_DIR="/var/www/www.einverne.info/html" |
||||
# 接受者邮箱 |
||||
EMAIL_ADDR="[email protected]" |
||||
|
||||
mkdir -p $BACKUP_DIR |
||||
|
||||
# MySQL database credentials |
||||
# MySQL 数据库相关配置 |
||||
DB_USER="" |
||||
DB_PASS="" |
||||
DB_NAME="" |
||||
DB_FILE="www.einverne.info.$NOW.sql" |
||||
|
||||
# Tar transforms for better archive structure. |
||||
# 将Tar压缩包内内容,分别保存到 html 和 database 两个文件夹下 |
||||
WWW_TRANSFORM='s,^var/www/www.einverne.info/html,html,' |
||||
DB_TRANSFORM='s,^root/backups,database,' |
||||
|
||||
# 以上内容需要自定义 |
||||
|
||||
mkdir -p $BACKUP_DIR |
||||
# Create the archive and the MySQL dump |
||||
tar -cvf $BACKUP_DIR/$FILE --transform $WWW_TRANSFORM $WWW_DIR |
||||
mysqldump -u$DB_USER -p$DB_PASS $DB_NAME > $BACKUP_DIR/$DB_FILE |
||||
|
Loading…
Reference in new issue