import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; import OptionsTab from "./options_tab.js"; const TPL = `

Automatic backup

Trilium can back up the database automatically:


It's recommended to keep the backup turned on, but this can make application startup slow with large databases and/or slow storage devices.

Backup now

`; export default class BackupOptions extends OptionsTab { get tabTitle() { return "Backup" } lazyRender() { this.$widget = $(TPL); this.$backupDatabaseButton = this.$widget.find("#backup-database-button"); this.$backupDatabaseButton.on('click', async () => { const {backupFile} = await server.post('database/backup-database'); toastService.showMessage("Database has been backed up to " + backupFile, 10000); }); this.$dailyBackupEnabled = this.$widget.find("#daily-backup-enabled"); this.$weeklyBackupEnabled = this.$widget.find("#weekly-backup-enabled"); this.$monthlyBackupEnabled = this.$widget.find("#monthly-backup-enabled"); this.$dailyBackupEnabled.on('change', () => this.updateCheckboxOption('dailyBackupEnabled', this.$dailyBackupEnabled)); this.$weeklyBackupEnabled.on('change', () => this.updateCheckboxOption('weeklyBackupEnabled', this.$weeklyBackupEnabled)); this.$monthlyBackupEnabled.on('change', () => this.updateCheckboxOption('monthlyBackupEnabled', this.$monthlyBackupEnabled)); } optionsLoaded(options) { this.setCheckboxState(this.$dailyBackupEnabled, options.dailyBackupEnabled); this.setCheckboxState(this.$weeklyBackupEnabled, options.weeklyBackupEnabled); this.setCheckboxState(this.$monthlyBackupEnabled, options.monthlyBackupEnabled); } }