feat(backups): improve backup retention across different database types

- Add serverId parameter to keepLatestNBackups function
- Execute backup retention commands on the specific server for each database type
- Remove global backup retention call in favor of per-database type retention
This commit is contained in:
Mauricio Siu
2025-03-09 11:54:36 -06:00
parent 688601107c
commit 6467ce0a24
3 changed files with 19 additions and 9 deletions

View File

@@ -13,15 +13,17 @@ export const scheduleBackup = (backup: BackupSchedule) => {
scheduleJob(backupId, schedule, async () => {
if (databaseType === "postgres" && postgres) {
await runPostgresBackup(postgres, backup);
await keepLatestNBackups(backup, postgres.serverId);
} else if (databaseType === "mysql" && mysql) {
await runMySqlBackup(mysql, backup);
await keepLatestNBackups(backup, mysql.serverId);
} else if (databaseType === "mongo" && mongo) {
await runMongoBackup(mongo, backup);
await keepLatestNBackups(backup, mongo.serverId);
} else if (databaseType === "mariadb" && mariadb) {
await runMariadbBackup(mariadb, backup);
await keepLatestNBackups(backup, mariadb.serverId);
}
await keepLatestNBackups(backup);
});
};