Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[简体中文](README.md) | **English**

Track backup times, locations, and notes for files and folders. Supports batch entry, backup history, private folders, and data recovery.
Track backup times, locations, and notes for files and folders. Supports batch entry, backup history, and private folders.

## Deploy with Docker

Expand Down Expand Up @@ -40,7 +40,7 @@ To connect an existing MongoDB instance, see [Database configuration](docs/docke
- **Batch entry:** Enter batch mode and select items, or paste a table. Each batch supports up to 20 records.
- **Find and edit records:** Open backup history → filter by item, location, or date → edit or delete records.
- **Private folders:** Click DataBack in the upper-left corner and enter your privacy password. Click it again to hide private folders.
- **Undo deletion:** Use Undo in the deletion notification, or restore items from the recycle bin in data management within 30 days.
- **Undo deletion:** Click Undo in the deletion notification.

## Update

Expand Down Expand Up @@ -85,13 +85,11 @@ Set the `DATABACK_PRIVACY_PASSWORD` environment variable before using private fo

## Back up and restore data

- **Export:** Unlock private folders → open data management → export JSON to save the complete ledger.
- **Automatic backups:** Open automatic backups in data management. DataBack keeps one backup per day and retains the latest 30. You can download a backup or create one immediately.
- **Restore:** Select a backup → review its contents → confirm. DataBack saves the current ledger before replacing it.
- **Automatic backups:** The server saves one ledger snapshot per day and retains the latest 30. Docker stores these in the `databack_snapshots` volume by default.
- **Full local backup:** Stop the app, then copy `data/`.
- **Full Docker backup:** Stop the service and back up its data volumes and `.env`. See [Full backup](docs/docker.en.md#full-backup) for commands.

Ledger JSON contains folders and backup records. Save actual files, recycle-bin contents, and deployment credentials separately.
The ledger records folders and backup information. Save actual files and deployment credentials separately.

## Layout

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**简体中文** | [English](README.en.md)

记录文件和文件夹的备份时间、位置与说明,支持批量登记、历史查询、隐私目录和数据恢复。
记录文件和文件夹的备份时间、位置与说明,支持批量登记、历史查询和隐私目录。

## Docker 部署

Expand Down Expand Up @@ -40,7 +40,7 @@ DATABACK_ALLOWED_HOSTS=backup.example.com,127.0.0.1:8767,localhost:8767
- **批量登记:** 点击批量登记后勾选项目,或粘贴表格,每批最多 20 条。
- **查询与修改:** 历史记录 → 筛选资料、位置、日期 → 编辑或删除记录。
- **隐私目录:** 点击左上角 DataBack → 输入隐私密码;再次点击收起。
- **撤销删除:** 删除提示中点击撤销,或到数据管理的回收站恢复,保留 30 天。
- **撤销删除:** 在删除后的提示中点击撤销。

## 更新

Expand Down Expand Up @@ -85,13 +85,11 @@ Windows 构建 `web/` 后,双击 `desktop/启动.cmd`;关闭时双击 `deskt

## 数据备份与恢复

- **导出:** 解锁隐私目录 → 数据管理 → 导出 JSON,保存完整台账。
- **自动备份:** 数据管理 → 自动备份,每天一份、保留最新 30 份,可下载或立即备份。
- **恢复:** 选择备份 → 核对内容 → 确认恢复;替换前自动保存当前台账。
- **自动备份:** 服务端每天保存一份台账快照,保留最新 30 份;Docker 默认保存在 `databack_snapshots` 数据卷。
- **本机完整备份:** 关闭程序后复制 `data/`。
- **Docker 完整备份:** 停止服务后备份数据卷和 `.env`,命令见 [数据备份](docs/docker.md#完整备份)。

台账 JSON 包含目录和备份记录,实际文件、回收站内容和部署密码另行保存。
台账只记录目录和备份信息,实际文件和部署密码另行保存。

## 目录

Expand Down
2 changes: 1 addition & 1 deletion docs/docker.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Merge these fields into the existing application configuration. For a separate c

For existing deployments, keep the database directory, users, passwords, replica set, and volume mounts. Replace only the application image. The original `deploy.nas.app_health` Compose health-check entry point remains supported.

To move between storage backends, export ledger JSON through the interface and import it into the destination. The migration CLI is at `web/scripts/migrate_to_mongo.py`; run it with `--help` for options.
To migrate an existing schema-3 ledger JSON file to MongoDB, use `web/scripts/migrate_to_mongo.py`; run it with `--help` for options.

## Full backup

Expand Down
2 changes: 1 addition & 1 deletion docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ networks:

沿用已有部署时,保留原数据库目录、用户、密码、副本集和挂载配置,仅替换应用镜像。原 Compose 的 `deploy.nas.app_health` 健康检查入口仍可使用。

台账可通过界面导出 JSON,在另一存储后端导入。迁移工具位于 `web/scripts/migrate_to_mongo.py`,运行 `--help` 查看参数。
将已有 schema-3 台账 JSON 迁移到 MongoDB 时,使用 `web/scripts/migrate_to_mongo.py`,运行 `--help` 查看参数。

## 完整备份

Expand Down
6 changes: 2 additions & 4 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type { DeleteTarget, EntityForm } from './components/EntityForms';
import { Overview } from './features/Overview';
import { AssetDetail } from './features/AssetDetail';
import { History } from './features/History';
import { DataManagement } from './features/DataManagement';

export default function App() {
const session = useSession();
Expand Down Expand Up @@ -83,7 +82,7 @@ function LedgerApp({session, onLogout,privacyOpen,onTogglePrivacy,onSetPrivate}:
finally { markPending.current = false; setMarking(false); }
};
const saved = async () => { await ledger.refresh({throwOnError: true}); setNotice('备份记录已保存。'); };
const deleted = async (trashId?: string) => { await ledger.refresh({throwOnError: true}); setNotice('已移入回收站。', trashId); };
const deleted = async (trashId?: string) => { await ledger.refresh({throwOnError: true}); setNotice('已删除。', trashId); };
const state = ledger.state;
const detail = state?.assets.find(asset => asset.id === detailId);
const directRecords = state && route.folderId && state.assets.some(asset => asset.id === route.folderId && asset.backup_target === true) && buildHierarchy(state.assets).isLeaf(route.folderId);
Expand All @@ -96,7 +95,6 @@ function LedgerApp({session, onLogout,privacyOpen,onTogglePrivacy,onSetPrivate}:
{!state ? <div className="initial-state"><h1>DataBack</h1><p>{ledger.loading ? `正在读取${nas ? '' : '本机'}台账…` : '恢复连接后即可继续查看和登记资料。'}</p></div> : <>
{route.page === 'overview' ? <Overview key={`directory:${route.folderId ?? 'root'}`} state={state} folderId={route.folderId} onFolder={openFolder} onCreate={createAsset} onAssetForm={entry => setEntity({kind: 'assets', entry})} onMark={markAsset} marking={marking} onAssetDelete={asset => setDeletion({collection: 'assets', id: asset.id, name: asset.name})} onRegister={assetId => setBackup({assetId})} onDetail={setDetailId} onLocateAsset={locateAsset} onEditRecords={assetId => setRecordEditor({assetId, mode: 'edit'})} onAddRecord={assetId => setRecordEditor({assetId, mode: 'new'})} onReorder={ledger.reorder} onRefresh={ledger.refresh} onBulk={assetIds=>setBulk({assetIds,mode:'selection'})} onPaste={()=>setBulk({mode:'paste'})} onPrivacy={onSetPrivate}/> : null}
{route.page === 'history' ? <History key={history.key} state={state} initialFilters={history.filters} onRegister={() => setBackup({})} onBulk={()=>setBulk({mode:'selection'})} onBulkEdit={setBulkRecordIds} onEdit={setRecord} onDelete={entry => setDeletion({collection: 'records', id: entry.id, name: '备份记录'})} /> : null}
{route.page === 'data' ? <DataManagement state={state} onRefresh={()=>ledger.refresh({throwOnError:true})} privacyOpen={privacyOpen} onUnlockPrivacy={onTogglePrivacy} /> : null}
{detail && route.page === 'overview' && !directRecords ? <AssetDetail key={`detail:${detail.id}`} asset={detail} state={state} onClose={() => setDetailId('')} onEditRecords={() => setRecordEditor({assetId: detail.id, mode: 'edit'})} onAddRecord={buildHierarchy(state.assets).isLeaf(detail.id) ? () => setRecordEditor({assetId: detail.id, mode: 'new'}) : undefined} /> : null}
{recordInfo && recordEditor ? <BackupInfoDialog key={`record-editor:${recordInfo.id}:${recordEditor.mode}`} state={state} asset={recordInfo} initialMode={recordEditor.mode} onClose={() => setRecordEditor(null)} onSaved={saved} onDeleted={deleted} /> : null}
{backup ? <BackupDialog state={state} initialAssetId={backup.assetId} onClose={() => setBackup(null)} onSaved={saved} onChooseTargets={() => { setBackup(null); openFolder(null); }} /> : null}
Expand All @@ -109,6 +107,6 @@ function LedgerApp({session, onLogout,privacyOpen,onTogglePrivacy,onSetPrivate}:
setNotice(nas ? '已保存。' : '已保存到本机台账。');
}} /> : null}
</>}
{deletion ? <DeleteDialog target={deletion} onClose={() => setDeletion(null)} onRemove={async (collection, id) => { const receipt = await ledger.remove(collection, id); setNotice('已移入回收站。', receipt.trash_id); }} /> : null}
{deletion ? <DeleteDialog target={deletion} onClose={() => setDeletion(null)} onRemove={async (collection, id) => { const receipt = await ledger.remove(collection, id); setNotice('已删除。', receipt.trash_id); }} /> : null}
</Shell>;
}
2 changes: 1 addition & 1 deletion web/src/components/AssetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function AssetDialog({ state, entry, initialKind = 'folder', parentId = n
{!entry ? <div className="directory-create-modes" role="tablist" aria-label="添加方式"><button type="button" role="tab" aria-selected={!batch} disabled={busy || submitted.current} onClick={() => { setMode('single'); setError(''); }}>单个</button><button type="button" role="tab" aria-selected={batch} disabled={busy || submitted.current} onClick={() => { setMode('batch'); setError(''); }}>批量</button></div> : null}
{!batch ? <Field label="资料名称"><input autoFocus required disabled={busy} maxLength={200} placeholder={draft.kind === 'file' ? '例如:旅行清单.pdf' : '例如:Photos 或 2025'} value={draft.name} onChange={e => update('name', e.target.value)} /></Field> : null}
<div className="form-grid"><Field label="类型" hint={hasChildren ? '已有下级,仅可选文件夹。' : undefined}><select disabled={busy || submitted.current} value={draft.kind} onChange={e => update('kind', e.target.value as Asset['kind'])}><option value="folder">文件夹</option><option value="file" disabled={hasChildren}>文件</option></select></Field>
<Field label="所属目录"><select disabled={busy || submitted.current} value={draft.parent_id} onChange={e => update('parent_id', e.target.value)}><option value="">全部资料(根目录)</option>{tree.moveOptions(entry?.id).map(asset => <option key={asset.id} value={asset.id}>{tree.path(asset.id)}</option>)}</select></Field></div>
<Field label="所属目录"><select disabled={busy || submitted.current} value={draft.parent_id} onChange={e => update('parent_id', e.target.value)}><option value="">全部(根目录)</option>{tree.moveOptions(entry?.id).map(asset => <option key={asset.id} value={asset.id}>{tree.path(asset.id)}</option>)}</select></Field></div>
{batch ? <><Field label="名称或相对路径" hint="每行一项,最多 200 行;用 / 分隔目录。"><textarea required rows={6} maxLength={200000} disabled={busy || submitted.current} value={paths} placeholder={draft.kind === 'file' ? 'Photos/2026/旅行.jpg\n笔记/清单.md' : 'Photos/2026\nEmotion/Letter'} onChange={event => { setPaths(event.target.value); setError(''); }} /></Field><FormError message={preview.error} />
{preview.valid ? <section className="directory-batch-preview" aria-label="创建预览"><div className="directory-batch-summary" role="status">新增 {preview.created} 项 · 已有跳过 {preview.skipped} 项</div><div className="directory-batch-rows"><table><thead><tr><th>名称</th><th>类型</th><th>处理</th></tr></thead><tbody>{preview.rows.map((row, index) => <tr key={`${index}-${row.path}`}><td>{row.path}</td><td>{row.kind === 'file' ? '文件' : '文件夹'}</td><td>{row.status === 'create' ? '新增' : '跳过'}</td></tr>)}</tbody></table></div></section> : null}
<div className="form-actions"><button type="button" className="button secondary" disabled={busy} onClick={onClose}>取消</button><button type="submit" className="button primary" disabled={busy || (!submitted.current && (!preview.valid || !preview.created))}>{busy ? '正在保存…' : submitted.current ? '重试读取' : '确认添加'}</button></div></> : <FormActions busy={busy} onCancel={onClose} />}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/EntityForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ export function DeleteDialog({ target, onClose, onRemove }: { target: DeleteTarg
catch (reason) { setError(reason instanceof Error ? reason.message : '删除失败,请重试。'); }
finally { setBusy(false); }
}
return <Modal title="确认删除" onClose={onClose} busy={busy}><form className="form-body" onSubmit={submit}><p className="delete-description">将「{target.name}」移入回收站?30 天内可恢复。</p>{target.collection !== 'records' ? <p className="muted">有关联备份记录时,系统会保留条目并说明原因。</p> : null}<FormError message={error} /><div className="form-actions"><button type="button" className="button secondary" disabled={busy} onClick={onClose}>取消</button><button className="button danger" type="submit" disabled={busy}>{busy ? '正在删除…' : '确认删除'}</button></div></form></Modal>;
return <Modal title="确认删除" onClose={onClose} busy={busy}><form className="form-body" onSubmit={submit}><p className="delete-description">确认删除「{target.name}」?删除后可在提示中点击撤销。</p>{target.collection !== 'records' ? <p className="muted">有关联备份记录时,系统会保留条目并说明原因。</p> : null}<FormError message={error} /><div className="form-actions"><button type="button" className="button secondary" disabled={busy} onClick={onClose}>取消</button><button className="button danger" type="submit" disabled={busy}>{busy ? '正在删除…' : '确认删除'}</button></div></form></Modal>;
}
Loading