From 615b9842fea388b3cfaf621aec4a5468661a4254 Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Fri, 10 Jan 2025 12:39:09 +0100 Subject: [PATCH] #31030 Making backup directory configurable. --- .../main/java/com/dotmarketing/util/ConfigUtils.java | 11 ++++++++++- .../dotmarketing/util/starter/ImportStarterUtil.java | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dotCMS/src/main/java/com/dotmarketing/util/ConfigUtils.java b/dotCMS/src/main/java/com/dotmarketing/util/ConfigUtils.java index e0509a5a5c4c..9cb883ead8ac 100644 --- a/dotCMS/src/main/java/com/dotmarketing/util/ConfigUtils.java +++ b/dotCMS/src/main/java/com/dotmarketing/util/ConfigUtils.java @@ -68,10 +68,19 @@ public static String getLucenePath() { return getDynamicContentPath() + File.separator + "dotlucene"; } + /** + * Retrieves the configurable path for the backup directory. + * Defaults to DYNAMIC_CONTENT_PATH/dotsecure/backup if not overridden. + * + * @return the backup directory path + */ public static String getBackupPath() { - return getDynamicContentPath() + File.separator + "backup"; + String dynamicContentPath = getDynamicContentPath(); + return Config.getStringProperty("backup.directory", + Paths.get(dynamicContentPath, "dotsecure", "backup").toString()); } + public static String getBundlePath() { final Path path = Paths.get(String.format("%s%sbundles",getAbsoluteAssetsRootPath(),File.separator)).normalize(); File pathDir = path.toFile(); diff --git a/dotCMS/src/main/java/com/dotmarketing/util/starter/ImportStarterUtil.java b/dotCMS/src/main/java/com/dotmarketing/util/starter/ImportStarterUtil.java index ce7be09abbf4..61f968f58194 100644 --- a/dotCMS/src/main/java/com/dotmarketing/util/starter/ImportStarterUtil.java +++ b/dotCMS/src/main/java/com/dotmarketing/util/starter/ImportStarterUtil.java @@ -99,9 +99,10 @@ public class ImportStarterUtil { /** - * The path where tmp files are stored. This gets wiped alot + * Fully configurable path for the backup directory. */ - private String backupTempFilePath = ConfigUtils.getBackupPath() + File.separator + "temp"; + private static final String BACKUP_DIRECTORY = ConfigUtils.getBackupPath(); + private String backupTempFilePath = BACKUP_DIRECTORY + File.separator + "temp"; private ArrayList classesWithIdentity = new ArrayList<>(); private Map sequences; private Map tableIDColumns;