mirror of
https://github.com/zadam/trilium.git
synced 2025-10-16 18:38:05 +08:00
feat(react/settings): port backup DB now
This commit is contained in:
parent
33ae91f49c
commit
6f19fde76e
3 changed files with 25 additions and 2 deletions
|
@ -1,4 +1,8 @@
|
|||
import { BackupDatabaseNowResponse } from "@triliumnext/commons";
|
||||
import { t } from "../../../services/i18n";
|
||||
import server from "../../../services/server";
|
||||
import toast from "../../../services/toast";
|
||||
import Button from "../../react/Button";
|
||||
import FormCheckbox from "../../react/FormCheckbox";
|
||||
import FormGroup from "../../react/FormGroup";
|
||||
import FormText from "../../react/FormText";
|
||||
|
@ -9,6 +13,7 @@ export default function BackupSettings() {
|
|||
return (
|
||||
<>
|
||||
<AutomaticBackup />
|
||||
<BackupNow />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -43,4 +48,18 @@ export function AutomaticBackup() {
|
|||
<FormText>{t("backup.backup_recommendation")}</FormText>
|
||||
</OptionsSection>
|
||||
)
|
||||
}
|
||||
|
||||
export function BackupNow() {
|
||||
return (
|
||||
<OptionsSection title={t("backup.backup_now")}>
|
||||
<Button
|
||||
text={t("backup.backup_database_now")}
|
||||
onClick={async () => {
|
||||
const { backupFile } = await server.post<BackupDatabaseNowResponse>("database/backup-database");
|
||||
toast.showMessage(t("backup.database_backed_up_to", { backupFilePath: backupFile }), 10000);
|
||||
}}
|
||||
/>
|
||||
</OptionsSection>
|
||||
)
|
||||
}
|
|
@ -9,7 +9,7 @@ import type { Request } from "express";
|
|||
import ValidationError from "../../errors/validation_error.js";
|
||||
import sql_init from "../../services/sql_init.js";
|
||||
import becca_loader from "../../becca/becca_loader.js";
|
||||
import { DatabaseCheckIntegrityResponse } from "@triliumnext/commons";
|
||||
import { BackupDatabaseNowResponse, DatabaseCheckIntegrityResponse } from "@triliumnext/commons";
|
||||
|
||||
function getExistingBackups() {
|
||||
return backupService.getExistingBackups();
|
||||
|
@ -18,7 +18,7 @@ function getExistingBackups() {
|
|||
async function backupDatabase() {
|
||||
return {
|
||||
backupFile: await backupService.backupNow("now")
|
||||
};
|
||||
} satisfies BackupDatabaseNowResponse;
|
||||
}
|
||||
|
||||
function vacuumDatabase() {
|
||||
|
|
|
@ -97,3 +97,7 @@ export interface EtapiToken {
|
|||
export interface PostTokensResponse {
|
||||
authToken: string;
|
||||
}
|
||||
|
||||
export interface BackupDatabaseNowResponse {
|
||||
backupFile: string;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue