π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Add local preferences to backup
Smaug6739ad0b08b331b7
diff --git a/backend/controllers/backup.controller.go b/backend/controllers/backup.controller.goindex db502610..39f63beb 100644--- a/backend/controllers/backup.controller.go+++ b/backend/controllers/backup.controller.go@@ -28,8 +28,8 @@ func NewBackupController(app *app.App) BackupController {type CreateBackupRequest struct {IncludeDocuments *bool `json:"include_documents"` // Include documents/notes contentIncludeFiles *bool `json:"include_files"` // Include uploaded files- IncludeSettings *bool `json:"include_settings"` // Include user settingsIncludeMetadata *bool `json:"include_metadata"` // Include node metadata+ LocalData any `json:"local_data"` // Include data stored by the client to the archive}// CreateBackup starts an asynchronous backup job@@ -53,8 +53,8 @@ func (ctr *Controller) CreateBackup(c *gin.Context) (int, any) {options := types.BackupOptions{IncludeDocuments: req.IncludeDocuments == nil || *req.IncludeDocuments,IncludeFiles: req.IncludeFiles == nil || *req.IncludeFiles,- IncludeSettings: req.IncludeSettings == nil || *req.IncludeSettings,IncludeMetadata: req.IncludeMetadata == nil || *req.IncludeMetadata,+ LocalData: req.LocalData,}// Start async backupdiff --git a/backend/services/backup.service.go b/backend/services/backup.service.goindex 649ed5e4..058e718d 100644--- a/backend/services/backup.service.go+++ b/backend/services/backup.service.go@@ -288,6 +288,22 @@ func (s *backupService) processBackup(ctx context.Context, job *types.BackupJob,}}+ // Check for cancellation+ select {+ case <-ctx.Done():+ return+ default:+ }++ if job.Options.LocalData != nil {+ s.updateJobStatus(job, types.BackupStatusProcessing, 80, "Adding local data...", "")+ if err := s.addJSONToZip(zipWriter, "local_data.json", job.Options.LocalData); err != nil {+ s.updateJobStatus(job, types.BackupStatusFailed, 0, "", fmt.Sprintf("Failed to add local data: %v", err))+ return+ }+ }++ // Check for cancellationselect {case <-ctx.Done():return@@ -298,10 +314,14 @@ func (s *backupService) processBackup(ctx context.Context, job *types.BackupJob,// Create and add manifestmanifest := types.BackupManifest{- Version: backupVersion,- CreatedAt: time.Now(),- UserID: job.UserID,- Options: job.Options,+ Version: backupVersion,+ CreatedAt: time.Now(),+ UserID: job.UserID,+ Options: types.BackupOptions{+ IncludeDocuments: job.Options.IncludeDocuments,+ IncludeFiles: job.Options.IncludeFiles,+ IncludeMetadata: job.Options.IncludeMetadata,+ },Statistics: stats,}@@ -414,12 +434,10 @@ func (s *backupService) prepareDocumentsData(documents []*models.Node, includeMe"theme": doc.Theme,"accessibility": doc.Accessibility,"access": doc.Access,- "display": doc.Display,"order": doc.Order,"content": doc.Content,"content_compiled": doc.ContentCompiled,"created_timestamp": doc.CreatedTimestamp,- "updated_timestamp": doc.UpdatedTimestamp,}}return stripped, nildiff --git a/backend/types/backup.go b/backend/types/backup.goindex b8ddb453..eac31c4e 100644--- a/backend/types/backup.go+++ b/backend/types/backup.go@@ -19,8 +19,8 @@ const (type BackupOptions struct {IncludeDocuments bool `json:"include_documents"` // Include documents/notes contentIncludeFiles bool `json:"include_files"` // Include uploaded files (images, PDFs, etc.)- IncludeSettings bool `json:"include_settings"` // Include user settings and preferencesIncludeMetadata bool `json:"include_metadata"` // Include node metadata+ LocalData any `json:"local_data"` // Include data stored by the client to the archive}// DefaultBackupOptions returns the default backup options (everything included)@@ -28,7 +28,6 @@ func DefaultBackupOptions() BackupOptions {return BackupOptions{IncludeDocuments: true,IncludeFiles: true,- IncludeSettings: true,IncludeMetadata: true,}}diff --git a/frontend/app/pages/dashboard/settings/_views/backups.vue b/frontend/app/pages/dashboard/settings/_views/backups.vueindex c6dc29ba..c630dc58 100644--- a/frontend/app/pages/dashboard/settings/_views/backups.vue+++ b/frontend/app/pages/dashboard/settings/_views/backups.vue@@ -110,7 +110,8 @@ interface BackupJob {interface BackupOptions {include_documents: boolean;include_files: boolean;- include_settings: boolean;+ local_data?: object;+ include_settings?: boolean;include_metadata: boolean;}@@ -123,6 +124,7 @@ const options = reactive({const { numericDate } = useDateFormatters();const notifications = useNotifications();+const pref = usePreferences();const currentJob = ref<BackupJob | null>(null);const pollingInterval = ref<ReturnType<typeof setInterval> | null>(null);@@ -161,7 +163,7 @@ async function startBackup() {const result = await makeRequest<{ job_id: string; message: string }>('backup', 'POST', {include_documents: options.includeDocuments,include_files: options.includeFiles,- include_settings: options.includeSettings,+ local_data: options.includeSettings ? pref.all : null,include_metadata: options.includeMetadata,});@@ -235,7 +237,7 @@ function error(message?: string, error?: string) {status: 'failed',id: '',user_id: '',- options: { include_documents: false, include_files: false, include_settings: false, include_metadata: false },+ options: { include_documents: false, include_files: false, include_metadata: false },progress: 0,message: message || 'An error occurred while fetching the backup status. Please try again later.',error: error,