mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
feat(react/settings): port backup DB now
This commit is contained in:
parent
33ae91f49c
commit
6f19fde76e
@ -1,4 +1,8 @@
|
|||||||
|
import { BackupDatabaseNowResponse } from "@triliumnext/commons";
|
||||||
import { t } from "../../../services/i18n";
|
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 FormCheckbox from "../../react/FormCheckbox";
|
||||||
import FormGroup from "../../react/FormGroup";
|
import FormGroup from "../../react/FormGroup";
|
||||||
import FormText from "../../react/FormText";
|
import FormText from "../../react/FormText";
|
||||||
@ -9,6 +13,7 @@ export default function BackupSettings() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AutomaticBackup />
|
<AutomaticBackup />
|
||||||
|
<BackupNow />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -43,4 +48,18 @@ export function AutomaticBackup() {
|
|||||||
<FormText>{t("backup.backup_recommendation")}</FormText>
|
<FormText>{t("backup.backup_recommendation")}</FormText>
|
||||||
</OptionsSection>
|
</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 ValidationError from "../../errors/validation_error.js";
|
||||||
import sql_init from "../../services/sql_init.js";
|
import sql_init from "../../services/sql_init.js";
|
||||||
import becca_loader from "../../becca/becca_loader.js";
|
import becca_loader from "../../becca/becca_loader.js";
|
||||||
import { DatabaseCheckIntegrityResponse } from "@triliumnext/commons";
|
import { BackupDatabaseNowResponse, DatabaseCheckIntegrityResponse } from "@triliumnext/commons";
|
||||||
|
|
||||||
function getExistingBackups() {
|
function getExistingBackups() {
|
||||||
return backupService.getExistingBackups();
|
return backupService.getExistingBackups();
|
||||||
@ -18,7 +18,7 @@ function getExistingBackups() {
|
|||||||
async function backupDatabase() {
|
async function backupDatabase() {
|
||||||
return {
|
return {
|
||||||
backupFile: await backupService.backupNow("now")
|
backupFile: await backupService.backupNow("now")
|
||||||
};
|
} satisfies BackupDatabaseNowResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
function vacuumDatabase() {
|
function vacuumDatabase() {
|
||||||
|
@ -97,3 +97,7 @@ export interface EtapiToken {
|
|||||||
export interface PostTokensResponse {
|
export interface PostTokensResponse {
|
||||||
authToken: string;
|
authToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BackupDatabaseNowResponse {
|
||||||
|
backupFile: string;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user