u
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { http } from './http.js';
|
||||
|
||||
/**
|
||||
* Backup API for listing backups, checking service status, and triggering manual backups.
|
||||
* Backup API for listing backups, checking service status, inspecting archived VFS files, and recovering VFS files.
|
||||
*/
|
||||
export const backup = {
|
||||
/**
|
||||
@@ -16,16 +16,36 @@ export const backup = {
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* POST /api/backup/run
|
||||
* Triggers a manual backup run.
|
||||
* Returns: 200 { success: bool, id: str, timestamp: str, promotedDaily: bool, promotedMonthly: bool, totalSizeBytes: int, pruneResult: { hourlyPruned: int, dailyPruned: int }, manifest: object }
|
||||
* GET /api/backup/:id/vfs
|
||||
* Lists VFS files archived in a specific backup for a company.
|
||||
* @param {string} id Backup identifier (e.g. backup-2026-10-14_02-00-00)
|
||||
* @param {number} [companyId] Optional company ID (defaults to active company)
|
||||
* @returns {Promise<{ backupId: string, companyId: number, files: Array<{ name: string, size: number, mime: string, mtime: string }> }>}
|
||||
*/
|
||||
// #region POST /api/backup/run — run
|
||||
// MARK: calls POST /api/backup/run from ./api/index.js
|
||||
run() {
|
||||
return http('/api/backup/run', {
|
||||
// #region GET /api/backup/{id}/vfs — listVfs
|
||||
// MARK: calls GET /api/backup/:id/vfs from ./api/index.js
|
||||
listVfs(id, companyId) {
|
||||
const q = companyId != null ? `?companyId=${encodeURIComponent(companyId)}` : '';
|
||||
return http(`/api/backup/${encodeURIComponent(id)}/vfs${q}`);
|
||||
},
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* POST /api/backup/:id/vfs/recover
|
||||
* Safely extracts and restores a VFS file from the specified backup into the active VFS.
|
||||
* @param {string} id Backup identifier
|
||||
* @param {string} path Relative file path within the VFS archive
|
||||
* @param {number} [companyId] Optional company ID
|
||||
* @returns {Promise<{ success: boolean, backupId: string, companyId: number, path: string, sizeBytes: number, mime: string }>}
|
||||
*/
|
||||
// #region POST /api/backup/{id}/vfs/recover — recoverVfs
|
||||
// MARK: calls POST /api/backup/:id/vfs/recover from ./api/index.js
|
||||
recoverVfs(id, path, companyId) {
|
||||
return http(`/api/backup/${encodeURIComponent(id)}/vfs/recover`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ path, companyId }),
|
||||
});
|
||||
},
|
||||
// #endregion
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user