refactor(backups): standardize backup file naming using getBackupTimestamp utility

- Replaced inline timestamp generation with the new getBackupTimestamp function across various backup modules (compose, libsql, mariadb, mongo, mysql, postgres, web-server, and volume-backups).
- Improved code readability and maintainability by centralizing timestamp formatting logic.
This commit is contained in:
Mauricio Siu
2026-04-03 17:13:00 -06:00
parent 6192c08400
commit 71de71fb8a
9 changed files with 19 additions and 46 deletions

View File

@@ -2,7 +2,7 @@ import path from "node:path";
import { paths } from "@dokploy/server/constants";
import { findComposeById } from "@dokploy/server/services/compose";
import type { findVolumeBackupById } from "@dokploy/server/services/volume-backups";
import { getS3Credentials, normalizeS3Path } from "../backups/utils";
import { getBackupTimestamp, getS3Credentials, normalizeS3Path } from "../backups/utils";
export const getVolumeServiceAppName = (
volumeBackup: Awaited<ReturnType<typeof findVolumeBackupById>>,
@@ -32,12 +32,7 @@ export const backupVolume = async (
const { VOLUME_BACKUPS_PATH, VOLUME_BACKUP_LOCK_PATH } = paths(!!serverId);
const destination = volumeBackup.destination;
const s3AppName = getVolumeServiceAppName(volumeBackup);
const timestamp = new Date()
.toISOString()
.replace("T", "_")
.replace(/:/g, "-")
.replace(".", "_");
const backupFileName = `${volumeName}-${timestamp}.tar`;
const backupFileName = `${volumeName}-${getBackupTimestamp()}.tar`;
const bucketDestination = `${s3AppName}/${normalizeS3Path(prefix || "")}${backupFileName}`;
const rcloneFlags = getS3Credentials(volumeBackup.destination);
const rcloneDestination = `:s3:${destination.bucket}/${bucketDestination}`;