Bỏ qua, đến nội dung

@digiforce-nc/plugin-backup-restore

Plugin sao lưu và phục hồi ứng dụng — dump database, download/upload backup file, restore toàn bộ hoặc migration giữa các môi trường.

Plugin này làm gì?

Hãy hình dung một hệ thống sao lưu và phục hồi như két sắt an toàn: bạn có thể chụp lại toàn bộ trạng thái ứng dụng (database, cấu hình) vào một file backup, cất giữ an toàn, và khi cần thì khôi phục lại đúng trạng thái đó — như quay ngược thời gian.

Ba nhiệm vụ chính

#Nhiệm vụChi tiết
1Sao lưu (Backup)Dump toàn bộ database thành file backup, lưu trên disk
2Phục hồi (Restore)Upload hoặc chọn backup file, khôi phục lại trạng thái database
3MigrationChuyển dữ liệu giữa môi trường (dev → staging → production)

Kiến trúc

Tổng quan 4 tầng

TầngVai tròThành phần
Client UITạo backup, xem danh sách, restoreBackupAndRestoreList, DuplicatorProvider
Server APIXử lý dump, restore, uploadDumper, Restorer, AppMigrator
DatabaseNguồn dữ liệu / đích khôi phụcToàn bộ collection trong hệ thống
Backup FilesFile backup trên diskKhông lưu trong DB, lưu trực tiếp trên filesystem

API endpoints

EndpointMô tả
backupFiles:listDanh sách backup file hiện có
backupFiles:getChi tiết một backup file
backupFiles:createTạo backup mới (trigger dump)
backupFiles:downloadDownload backup file
backupFiles:uploadUpload backup file từ máy tính
backupFiles:restorePhục hồi từ backup file
backupFiles:destroyXóa backup file
backupFiles:dumpableCollectionsDanh sách collection có thể backup

Luồng Backup & Restore

Thành phầnChức năng
DumperĐọc dữ liệu từ DB, đóng gói thành backup file
RestorerĐọc backup file, ghi ngược vào DB
AppMigratorXử lý migration giữa phiên bản/môi trường khác nhau
CLI restoreCommand digiforce restore cho restore từ terminal
Multer uploadMiddleware nhận file backup từ client

Database

Plugin này không tạo bảng riêng — backup files được lưu trực tiếp trên filesystem (thư mục storage/backups). Metadata file (tên, ngày tạo, kích thước) được đọc từ filesystem.

Thành phần client

Thành phầnMô tả
DuplicatorProviderContext provider cho tính năng backup/restore
BackupAndRestoreListTrang danh sách backup, nút tạo/restore/download/xóa

Dependencies

PackageVai trò
@digiforce-nc/actionsAction context types (peer)
@digiforce-nc/databaseDatabase ORM (peer)
@digiforce-nc/serverServer framework (peer)
@digiforce-nc/clientClient framework (peer)

Mục lục chi tiết