chore: update docs

This commit is contained in:
henry.chen
2025-08-05 14:26:17 +08:00
parent 666161d37e
commit 07fc49db5c
7 changed files with 62 additions and 44 deletions

View File

@@ -3,7 +3,7 @@ apimode:
listen: 0.0.0.0:9000
database: # 数据库配置
driver: mongodb
source: mongodb://localhost:27017
source: mongodb://localhost:27017/eiblog
backupto: qiniu # 备份到, default: qiniu
interval: 7d # 备份周期, default: 7d
validity: 60 # 备份保留时间, default: 60

View File

@@ -24,14 +24,17 @@ func (r MongoStorage) Backup(name string) (string, error) {
if err != nil {
return "", err
}
arg := fmt.Sprintf("mongodump -h %s -d eiblog -o /tmp", u.Host)
if u.Path == "" {
return "", fmt.Errorf("no database specified")
}
arg := fmt.Sprintf("mongodump -h %s -d %s -o /tmp", u.Host, u.Path)
cmd := exec.CommandContext(ctx, "sh", "-c", arg)
err = cmd.Run()
if err != nil {
return "", err
}
// tar
arg = fmt.Sprintf("tar czf /tmp/%s -C /tmp eiblog", name)
arg = fmt.Sprintf("tar czf /tmp/%s -C /tmp %s", name, u.Path)
cmd = exec.CommandContext(ctx, "sh", "-c", arg)
err = cmd.Run()
if err != nil {
@@ -66,7 +69,7 @@ func (r MongoStorage) Restore(path string) error {
if err != nil {
return err
}
arg = fmt.Sprintf("mongorestore -h %s -d eiblog /tmp/eiblog", u.Host)
arg = fmt.Sprintf("mongorestore -h %s -d %s /tmp/%s", u.Host, u.Path, u.Path)
cmd = exec.CommandContext(ctx, "sh", "-c", arg)
return cmd.Run()
}

View File

@@ -1,5 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [3.0.3](https://github.com/eiblog/eiblog/compare/v3.0.2...v3.0.3) (2025-07-25)