Skip to content

Commit

Permalink
Support auto renew backup and restore scripts online.
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarmen2 committed Dec 9, 2023
1 parent da7e02d commit a4eca07
Show file tree
Hide file tree
Showing 7 changed files with 518 additions and 536 deletions.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Documentation: [English version](https://github.com/fscarmen2/Argo-Nezha-Service
- [客户端接入](README.md#客户端接入)
- [SSH 接入](README.md#ssh-接入)
- [手动备份数据](README.md#手动备份数据)
- [手动更新备份和还原脚本](README.md#手动更新备份和还原脚本)
- [自动还原备份](README.md#自动还原备份)
- [手动还原备份](README.md#手动还原备份)
- [完美搬家](README.md#完美搬家)
Expand Down Expand Up @@ -92,16 +93,17 @@ Argo 隧道认证方式有 json 和 token,使用两个方式其中之一。推
用到的变量
| 变量名 | 是否必须 | 备注 |
| ------------ | ------ | ---- |
| GH_USER || github 的用户名,用于面板管理授权 |
| GH_CLIENTID || 在 github 上申请 |
| GH_CLIENTSECRET|| 在 github 上申请 |
| GH_BACKUP_USER || 在 github 上备份哪吒服务端数据库的 github 用户名,不填则与面板管理授权的账户 GH_USER 一致 |
| GH_REPO || 在 github 上备份哪吒服务端数据库文件的 github 库 |
| GH_EMAIL || github 的邮箱,用于备份的 git 推送到远程库 |
| GH_PAT || github 的 PAT |
| NGINX || 默认使用 gRPCwebProxy 应用来反代,这时可以不填写该变量;如需 nginx 反代,请设置该值为 1 |
| ARGO_AUTH || Json: 从 https://fscarmen.cloudflare.now.cc 获取的 Argo Json<br> Token: 从 Cloudflare 官网获取 |
| ARGO_DOMAIN || Argo 域名 |
| GH_USER || github 的用户名,用于面板管理授权 |
| GH_CLIENTID || 在 github 上申请 |
| GH_CLIENTSECRET || 在 github 上申请 |
| GH_BACKUP_USER || 在 github 上备份哪吒服务端数据库的 github 用户名,不填则与面板管理授权的账户 GH_USER 一致 |
| GH_REPO || 在 github 上备份哪吒服务端数据库文件的 github 库 |
| GH_EMAIL || github 的邮箱,用于备份的 git 推送到远程库 |
| GH_PAT || github 的 PAT |
| REVERSE_PROXY_MODE || 默认使用 nginx 应用来反代,这时可以不填写该变量;如需 gRPCwebProxy 反代,请设置该值为 `grpcwebproxy` |
| ARGO_AUTH || Json: 从 https://fscarmen.cloudflare.now.cc 获取的 Argo Json<br> Token: 从 Cloudflare 官网获取 |
| ARGO_DOMAIN || Argo 域名 |
| NO_AUTO_RENEW || 默认不需要该变量,即每天定时同步在线最新的备份和还原脚本。如不需要该功能,设置此变量,并赋值为 `1` |

Koyeb

Expand Down Expand Up @@ -135,7 +137,8 @@ docker run -dit \
-e ARGO_AUTH='<填获取的 Argo json 或者 token>' \
-e ARGO_DOMAIN=<填自定义的> \
-e GH_BACKUP_USER=<选填,选填,选填! 如与 GH_USER 一致,可以不要该环境变量> \
-e NGINX=<选填,选填,选填! 如想用 nginx 替代 gRPCwebProxy 反代的话,把该值设置为1> \
-e REVERSE_PROXY_MODE=<选填,选填,选填! 如想用 gRPCwebProxy 替代 nginx 反代的话,请设置该变量并赋值为 `grpcwebproxy`> \
-e NO_AUTO_RENEW=<选填,选填,选填! 如果不需要自动在线同步最新的 backup.sh 和 restore.sh,请设置该变量并赋值为 `1`>
fscarmen/argo-nezha
```

Expand All @@ -158,7 +161,8 @@ services:
- ARGO_AUTH='<填获取的 Argo json 或者 token>'
- ARGO_DOMAIN=<填自定义的>
- GH_BACKUP_USER=<选填,选填,选填! 如与 GH_USER 一致,可以不要该环境变量>
- NGINX=<选填,选填,选填! 如想用 nginx 替代 gRPCwebProxy 反代的话,把该值设置为1>
- REVERSE_PROXY_MODE=<选填,选填,选填! 如想用 gRPCwebProxy 替代 nginx 反代的话,请设置该变量并赋值为 `grpcwebproxy`>
- NO_AUTO_RENEW=<选填,选填,选填! 如果不需要自动在线同步最新的 backup.sh 和 restore.sh,请设置该变量并赋值为 `1`>
```


Expand Down Expand Up @@ -197,6 +201,10 @@ curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -
方法二: ssh 进去后,容器版本运行 `/dashboard/backup.sh`; 非容器版本运行 `/opt/nezha/dashboard/backup.sh`


## 手动更新备份和还原脚本
ssh 进去后,容器版本运行 `/dashboard/renew.sh`; 非容器版本运行 `/opt/nezha/dashboard/renew.sh`


## 自动还原备份
* 把需要还原的文件名改到 github 备份库里的 `README.md`,定时服务会每分钟检测更新,并把上次同步的文件名记录在本地 `/dbfile` 处以与在线的文件内容作比对

Expand Down Expand Up @@ -229,6 +237,7 @@ tar czvf dashboard.tar.gz /dashboard
|-- argo.yml # Argo 隧道 yml 文件,用于在一同隧道下,根据不同域名来分流 web, gRPC 和 ssh 协议的作用
|-- backup.sh # 备份数据脚本
|-- restore.sh # 还原备份脚本
|-- renew.sh # 在线更新备份和还原文件的脚本
|-- dbfile # 记录最新的还原或备份文件名
|-- resource # 面板主题、语言和旗帜等资料的文件夹
|-- data
Expand Down
34 changes: 22 additions & 12 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Documentation: English version | [中文版](https://github.com/fscarmen2/Argo-N
- [Client Access](README_EN.md#client-access)
- [SSH Access](README_EN.md#ssh-access)
- [Manual Backup data](README_EN.md#manual-backup-data)
- [Manual Rerew backup and restore scrpits](README_EN.md#manual-renew-backup-and-restore-scrpits)
- [Auto Restore Backup](README_EN.md#automatically-restore-backups)
- [Manual Restore Backup](README_EN.md#manually-restore-the-backup)
- [Migrating data](README_EN.md#migrating-data)
Expand Down Expand Up @@ -92,16 +93,17 @@ Image `fscarmen/argo-nezha:latest`, supports amd64 and arm64 architectures.
Variables used
| Variable Name | Required | Remarks |
| ------------ | ------ | ---- |
| GH_USER | Yes | github username for panel admin authorization |
| GH_CLIENTID | yes | apply on github |
| GH_CLIENTSECRET | yes | apply on github |
| GH_BACKUP_USER | No | The github username for backing up Nezha's server-side database on github, if not filled in, it is the same as the account GH_USER for panel management authorization |
| GH_REPO | No | The github repository for backing up Nezha's server-side database files on github |
| GH_EMAIL | No | github's mailbox for git push backups to remote repositories |
| GH_PAT | No | github's PAT |
| NGINX | No | If you want to use nginx instead of gRPCwebProxy for reverse proxying, set this value to 1 |
| ARGO_AUTH | Yes | Argo Json from https://fscarmen.cloudflare.now.cc<br>Argo token from Cloudflare official website |
| ARGO_DOMAIN | Yes | Argo domain |
| GH_USER | Yes | github username for panel admin authorization |
| GH_CLIENTID | yes | apply on github |
| GH_CLIENTSECRET | yes | apply on github |
| GH_BACKUP_USER | No | The github username for backing up Nezha's server-side database on github, if not filled in, it is the same as the account GH_USER for panel management authorization |
| GH_REPO | No | The github repository for backing up Nezha's server-side database files on github |
| GH_EMAIL | No | github's mailbox for git push backups to remote repositories |
| GH_PAT | No | github's PAT |
| REVERSE_PROXY_MODE | No | If you want to use gRPCwebProxy instead of nginx for reverse proxying, set this value to `grpcwebproxy` |
| ARGO_AUTH | Yes | Argo Json from https://fscarmen.cloudflare.now.cc<br>Argo token from Cloudflare official website |
| ARGO_DOMAIN | Yes | Argo domain |
| NO_AUTO_RENEW | No | The latest backup and restore scripts are synchronized online regularly every day. If you don't need this feature, set this variable and assign it a value of `1` |

Koyeb

Expand Down Expand Up @@ -135,7 +137,8 @@ docker run -dit \
-e ARGO_AUTH='<Fill in the fetched Argo json or token>' \
-e ARGO_DOMAIN=<fill in customized> \
-e GH_BACKUP_USER=<Optional, Optional, Optional! If it is consistent with GH_USER, you can leave it blank> \
-e NGINX=<Optional, Optional, Optional! If you want to use nginx instead of gRPCwebProxy for reverse proxying, set this value to 1> \
-e REVERSE_PROXY_MODE=<Optional, Optional, Optional! If you want to use gRPCwebProxy instead of nginx for reverse proxying, set this value to `grpcwebproxy`> \
-e NO_AUTO_RENEW=<Optional, Optional, Optional! If you don't need synchronized online, set this variable and assign it a value of `1`>
fscarmen/argo-nezha
```

Expand All @@ -158,7 +161,8 @@ services.
- ARGO_AUTH='<Fill in the fetched Argo json or token>'
- ARGO_DOMAIN=<fill in customized>
- GH_BACKUP_USER=<Optional, Optional, Optional! If it is consistent with GH_USER, you can leave it blank>
- NGINX=<Optional, Optional, Optional! If you want to use nginx instead of gRPCwebProxy for reverse proxying, set this value to 1>
- REVERSE_PROXY_MODE=<Optional, Optional, Optional! If you want to use gRPCwebProxy instead of nginx for reverse proxying, set this value to `grpcwebproxy`>
- NO_AUTO_RENEW=<Optional, Optional, Optional! If you don't need synchronized online, set this variable and assign it a value of `1`>
```


Expand Down Expand Up @@ -197,6 +201,11 @@ Method 1: Change the contents of the `README.md` file in the Github backup repos
Method 2: After ssh, run `/dashboard/backup.sh` for container version; `/opt/nezha/dashboard/backup.sh` for VPS host version.


## Manual Rerew backup and restore scrpits

After ssh, run `/dashboard/renew.sh` for container version; `/opt/nezha/dashboard/renew.sh` for VPS host version.


## Automatically restore backups
* Change the name of the file to be restored to `README.md` in the github backup repository, the timer service will check for updates every minute and record the last synchronized filename in the local `/dbfile` to compare with the online file content.

Expand Down Expand Up @@ -230,6 +239,7 @@ tar czvf dashboard.tar.gz /dashboard
|-- argo.yml # Argo tunnel yml file, used for streaming web, gRPC and ssh protocols under a single tunnel with different domains.
|-- backup.sh # Backup data scripts
|-- restore.sh # Restore backup scripts
|-- renew.sh # Scripts to update backup and restore files online
|-- dbfile # Record the name of the latest restore or backup file
|-- resource # Folders of information on panel themes, languages, flags, etc.
|-- data
Expand Down
Loading

0 comments on commit a4eca07

Please sign in to comment.