refactor: enhance volume backup path handling to ensure proper prefix usage

This commit is contained in:
Mauricio Siu
2026-03-07 01:22:53 -06:00
parent ce24eadbb4
commit 808001d8de
2 changed files with 7 additions and 2 deletions

View File

@@ -13,7 +13,10 @@ export const backupVolume = async (
const { VOLUME_BACKUPS_PATH, VOLUME_BACKUP_LOCK_PATH } = paths(!!serverId);
const destination = volumeBackup.destination;
const backupFileName = `${volumeName}-${new Date().toISOString()}.tar`;
const bucketDestination = `${normalizeS3Path(prefix)}${backupFileName}`;
const effectivePrefix = prefix
? normalizeS3Path(prefix)
: `${volumeBackup.appName}/`;
const bucketDestination = `${effectivePrefix}${backupFileName}`;
const rcloneFlags = getS3Credentials(volumeBackup.destination);
const rcloneDestination = `:s3:${destination.bucket}/${bucketDestination}`;
const volumeBackupPath = path.join(VOLUME_BACKUPS_PATH, volumeBackup.appName);

View File

@@ -81,7 +81,9 @@ const cleanupOldVolumeBackups = async (
try {
const rcloneFlags = getS3Credentials(destination);
const normalizedPrefix = normalizeS3Path(prefix);
const normalizedPrefix = prefix
? normalizeS3Path(prefix)
: `${volumeBackup.appName}/`;
const backupFilesPath = `:s3:${destination.bucket}/${normalizedPrefix}`;
const listCommand = `rclone lsf ${rcloneFlags.join(" ")} --include \"${volumeName}-*.tar\" :s3:${destination.bucket}/${normalizedPrefix}`;
const sortAndPick = `sort -r | tail -n +$((${keepLatestCount}+1)) | xargs -I{}`;