Skip to content

Commit 19c3414

Browse files
committed
refactor 2.0.0
0 parents  commit 19c3414

File tree

1,128 files changed

+801982
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,128 files changed

+801982
-0
lines changed

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
105+
106+
# VS Code
107+
.vscode
108+
109+
# DB Files
110+
/db/mysql-backup-db.json
111+
112+
# Tmp
113+
/backup-tmp

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM node:13.8.0-alpine
2+
LABEL AUTHOR="yi-ge"
3+
LABEL maintainer="a@wyr.me"
4+
5+
RUN apk add --no-cache \
6+
libstdc++ \
7+
libgcc \
8+
openssh-client \
9+
bash \
10+
ca-certificates \
11+
zlib \
12+
git
13+
14+
WORKDIR /usr/src/app
15+
16+
COPY package*.json ./
17+
18+
RUN npm install
19+
20+
COPY . .
21+
22+
EXPOSE 80
23+
24+
CMD ["npm", "start"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Yige
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# MySQL Backup
2+
3+
[![license](https://img.shields.io/github/license/yi-ge/mysql-backup.svg?style=flat-square)](https://github.com/yi-ge/mysql-backup/blob/master/LICENSE)
4+
[![GitHub last commit](https://img.shields.io/github/last-commit/yi-ge/mysql-backup.svg?style=flat-square)](https://github.com/yi-ge/mysql-backup)
5+
6+
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)
7+
8+
Automatically get your mysql database backup and uploading it to the Object Storage.
9+
10+
自动获取 MySQL 数据库备份文件并将其上传到对象存储。
11+
12+
Demo: [https://mysql-backup.demo.wyr.me](https://mysql-backup.demo.wyr.me)
13+
14+
默认超级管理员
15+
账号:admin
16+
密码:admin888
17+
18+
![mysql-backup](/mysql-backup.png)
19+
20+
## Features
21+
22+
1. 支持加密后压缩上传(默认上传到私密存储的“归档存储”类型,文件需解冻后方可下载)。
23+
2. 定时自动执行任务。
24+
3. Web 可视化动态添加配置,支持同时管理多个数据库,可以设置需要备份的表或不需要备份的表。
25+
4. ~~支持生成单个 PHP 文件,用于仅内网可访问数据库或虚拟主机数据库的备份。~~
26+
5. ~~支持生成 Shell 文件,用于仅内网可访问数据库的备份。~~(由于 Docker 部署已非常方便,这个功能不再开发)
27+
6. 支持 Swagger UI 查看 API,方便与其它系统整合。
28+
7. 支持`超级管理员`添加多个`普通管理员``超级管理员`可以管理所有数据库,`普通管理员`之间内容互不可见,适合普通开发团队的使用场景。
29+
8. 由于此系统仅为灾备设计,仅支持全量备份,默认备份`数据+结构`(包含视图、触发器等),不支持增量备份。如果您的数据非常重要,请勿将此作为唯一备份系统,可配合服务商提供的备份功能使用。
30+
31+
## 使用方法
32+
33+
```bash
34+
docker run -itd --name mysql-backup --restart always \
35+
-v /etc/localtime:/etc/localtime:ro \
36+
-p 80:80 \
37+
wy373226722/mysql-backup:latest
38+
```
39+
40+
为确保定时任务准确执行,请确保服务器的时区和时间设置正常。
41+
42+
请勿重复点击某个保存按钮,前端没有做重复点击限制。请谨慎操作。
43+
44+
**国内用户高速通道:**
45+
46+
阿里云:`docker pull registry.cn-shenzhen.aliyuncs.com/yi-ge/mysql-backup:latest`
47+
48+
腾讯云:`docker pull ccr.ccs.tencentyun.com/yi-ge/mysql-backup:latest`
49+
50+
**推荐用法:**
51+
配合[docker-letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion)使用,快速生成SSL证书。
52+
53+
```bash
54+
docker run --detach \
55+
--name nginx-proxy \
56+
--publish 80:80 \
57+
--publish 443:443 \
58+
--volume /etc/nginx/certs \
59+
--volume /etc/nginx/vhost.d \
60+
--volume /usr/share/nginx/html \
61+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
62+
jwilder/nginx-proxy
63+
64+
docker run --detach \
65+
--name nginx-proxy-letsencrypt \
66+
--volumes-from nginx-proxy \
67+
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
68+
jrcs/letsencrypt-nginx-proxy-companion
69+
70+
docker run -itd --name mysql-backup --restart always \
71+
-v /etc/localtime:/etc/localtime:ro \
72+
--env "VIRTUAL_PORT=80" \
73+
--env "VIRTUAL_HOST=你的域名" \
74+
--env "LETSENCRYPT_HOST=你的域名" \
75+
registry.cn-shenzhen.aliyuncs.com/yi-ge/mysql-backup:latest
76+
```
77+
78+
### 系统环境变量
79+
80+
| 变量名 | 默认值 | 描述 |
81+
| ------------ | ----------- | ---------------------------- |
82+
| `SCHEME` | `"https"` | `使用http还是https` |
83+
| `PORT` | `"80"` | `端口号` |
84+
| `HOST` | `"0.0.0.0"` | `监听的HOST` |
85+
| `JWT_SECRET` | `随机数` | `JWT私钥` |
86+
| `WORKPATH` | `db` | `存储本地数据库(JSON文件)` |
87+
88+
**注意**
89+
通常情况下使用默认值即可,其余配置项可在系统后台进行配置。
90+
91+
## API 文档
92+
93+
**Swagger:** <https://yourdomain/documentation>
94+
95+
**在线文档:** <https://mysql-backup.demo.wyr.me/documentation>
96+
97+
## 支持的对象存储
98+
99+
- 阿里云
100+
- 腾讯云
101+
- 七牛云
102+
103+
### 对象存储使用须知
104+
105+
1. `阿里云对象存储`存储请在创建`Bucket`时选择“归档存储”,默认所有数据均创建为`归档存储`类型(最适合备份数据库、价格最低)。
106+
2. 请创建`“私有”`类型的`Bucket`
107+
3. 数据需要先解冻才能访问,归档存储均无免费额度,操作归档存储API及取回数据均存在费用。
108+
4. 归档存储的最小计量大小为 64 KB,小于 64KB 的 Object 按照 64KB 计算存储空间,超过 64KB 的 Object 按照实际大小计算存储空间。
109+
5. 归档存储最短存储时间为 60 天(腾讯云为90天),早于 60 天删除的资源,其存储费用按 60 天计算。
110+
6. `七牛云对象存储`解冻时间1~5分钟,解冻一次有效期7天。`阿里云对象存储`解冻时间1分钟,解冻一次有效期24小时。
111+
7. `腾讯云对象存储`恢复模式:分别为标准模式、极速模式、批量模式,解冻一次有效期7天。
112+
113+
- 极速模式:需要的时间最短,只需要1~15分钟即可恢复。支持256MB以下文件的快速读取。当您在特定情况下,需要紧急获取档案数据的时候,使用加急模式可以大大缩短时间和提高效率。(备份系统默认小于256MB使用极速模式)
114+
- 标准模式:使用标准模式,一般可以在3~5小时完成恢复。(备份系统大于256MB且小于5GB使用标准模式)
115+
- 批量模式:成本最低,如果获取档案数据紧急程度低,采用批量模式可以用极低的成本获取大量的档案数据,一般在5~12小时可完成档案数据取回。(备份系统大于5GB使用批量模式)
116+
117+
### 对象存储参考文档
118+
119+
阿里云对象存储: [https://github.com/ali-sdk/ali-oss](https://github.com/ali-sdk/ali-oss)
120+
腾讯云对象存储: [https://github.com/tencentyun/cos-nodejs-sdk-v5](https://github.com/tencentyun/cos-nodejs-sdk-v5)
121+
七牛云对象存储: [https://developer.qiniu.com/kodo/sdk/1289/nodejs](https://developer.qiniu.com/kodo/sdk/1289/nodejs)
122+
123+
## Q & A
124+
125+
1. 已经有云服务了,为什么还需要使用此系统?
126+
A: 这取决于您的数据重要程度,这是一套灾备系统。
127+
128+
2. 是否支持其他数据库?
129+
A: 这是一个早期的个人业余项目,由于我主要使用MySQL数据库,因此在[mysqldump](https://github.com/bradzacher/mysqldump)的基础上实现了MySQL的备份。开源的目的就是希望能有更多人的使用这个系统,受益的同时获得其它数据库备份功能的支持。
130+
131+
3. 为什么使用`jQuery + Bootstrap`这样的“过时”前端架构?为什么不用`Angular``Vue``React`来开发前端?
132+
A: 这是由于历史原因决定的,我最初创建该系统的时候,采用`PHP混合HTML`实现,那时候还没有`Vue`之类的框架。并且`jQuery + Bootstrap`久经岁月考验,适合这类追求稳定的超小型系统。我已将相关依赖都升级为最新版并优化了部分代码。
133+
134+
4. 直接使用代码进行配置存在安全问题吗?
135+
A: 这是一个自用系统,如果已有管理员权限必然也可以操作相应的功能,因此逻辑上不存在由此导致的安全问题。
136+
137+
5. 是否具备删除对象存储中备份数据的功能?
138+
A: 不具备。在对象存储中的数据以“年/月/日”路径存储。为防止极端情况下导致数据被删除,故而不提供直接删除对象存储中备份数据的功能。

db/.gitkeep

Whitespace-only changes.

mysql-backup.png

427 KB
Loading

0 commit comments

Comments
 (0)