release: v1.3.0 — 整站备份恢复、跨后端同步与任务中心
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
This commit is contained in:
1 parent
b05d572221
commit
f17d79b236
72 files changed
+4312
-559
No files matched your search
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Export a full PicHost site backup (.phost.tar.gz).
|
||||
*
|
||||
* Usage:
|
||||
* node server/cli/backup-export.mjs
|
||||
*
|
||||
* Docker:
|
||||
* docker exec pichost backup-export
|
||||
*/
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { loadServerModule } from './backup-cli-loader.mjs'
|
||||
|
||||
const { ensureBackupSchema } = loadServerModule('utils/backup/schema.ts')
|
||||
const { createBackupJob, getBackupJob } = loadServerModule('utils/backup/jobs.ts')
|
||||
const { runFullExportJob } = loadServerModule('utils/backup/full-export.ts')
|
||||
|
||||
function readAppVersion() {
|
||||
try {
|
||||
const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'))
|
||||
return String(pkg.version ?? '0.0.0')
|
||||
} catch {
|
||||
return '0.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
ensureBackupSchema()
|
||||
const job = createBackupJob({
|
||||
type: 'full_export',
|
||||
message: 'CLI 导出'
|
||||
})
|
||||
|
||||
await runFullExportJob(job.id, readAppVersion())
|
||||
const done = getBackupJob(job.id)
|
||||
if (!done || done.status !== 'done') {
|
||||
console.error(`[PicHost] Export failed: ${done?.error ?? done?.message ?? 'unknown error'}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`[PicHost] Export complete: ${done.outputPath}`)
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(`[PicHost] Export error: ${error instanceof Error ? error.message : String(error)}`)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in new issue
Block a user