mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
feat(backups): gzip compress backups and add retention config to Instance Settings
Compress database backups with gzip (.sql.gz), reducing file size ~83%. Add backup retention configuration to Instance Settings UI with preset options (7 days, 2 weeks, 1 month). The backup scheduler now reads retention from the database on each tick so changes take effect without restart. Default retention changed from 30 to 7 days.
This commit is contained in:
parent
316790ea0a
commit
cc44d309c0
11 changed files with 107 additions and 17 deletions
|
|
@ -31,6 +31,7 @@ import { setupLiveEventsWebSocketServer } from "./realtime/live-events-ws.js";
|
|||
import {
|
||||
feedbackService,
|
||||
heartbeatService,
|
||||
instanceSettingsService,
|
||||
reconcilePersistedRuntimeServicesOnStartup,
|
||||
routineService,
|
||||
} from "./services/index.js";
|
||||
|
|
@ -628,20 +629,25 @@ export async function startServer(): Promise<StartedServer> {
|
|||
|
||||
if (config.databaseBackupEnabled) {
|
||||
const backupIntervalMs = config.databaseBackupIntervalMinutes * 60 * 1000;
|
||||
const settingsSvc = instanceSettingsService(db);
|
||||
let backupInFlight = false;
|
||||
|
||||
|
||||
const runScheduledBackup = async () => {
|
||||
if (backupInFlight) {
|
||||
logger.warn("Skipping scheduled database backup because a previous backup is still running");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
backupInFlight = true;
|
||||
try {
|
||||
// Read retention from Instance Settings (DB) so changes take effect without restart
|
||||
const generalSettings = await settingsSvc.getGeneral();
|
||||
const retentionDays = generalSettings.backupRetentionDays;
|
||||
|
||||
const result = await runDatabaseBackup({
|
||||
connectionString: activeDatabaseConnectionString,
|
||||
backupDir: config.databaseBackupDir,
|
||||
retentionDays: config.databaseBackupRetentionDays,
|
||||
retentionDays,
|
||||
filenamePrefix: "paperclip",
|
||||
});
|
||||
logger.info(
|
||||
|
|
@ -650,7 +656,7 @@ export async function startServer(): Promise<StartedServer> {
|
|||
sizeBytes: result.sizeBytes,
|
||||
prunedCount: result.prunedCount,
|
||||
backupDir: config.databaseBackupDir,
|
||||
retentionDays: config.databaseBackupRetentionDays,
|
||||
retentionDays,
|
||||
},
|
||||
`Automatic database backup complete: ${formatDatabaseBackupResult(result)}`,
|
||||
);
|
||||
|
|
@ -660,7 +666,7 @@ export async function startServer(): Promise<StartedServer> {
|
|||
backupInFlight = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
logger.info(
|
||||
{
|
||||
intervalMinutes: config.databaseBackupIntervalMinutes,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue