diff --git a/src/main/java/org/nachc/tools/githubbackup/main/GitHubBackupMain.java b/src/main/java/org/nachc/tools/githubbackup/main/GitHubBackupMain.java index 7f5323b..694e32d 100644 --- a/src/main/java/org/nachc/tools/githubbackup/main/GitHubBackupMain.java +++ b/src/main/java/org/nachc/tools/githubbackup/main/GitHubBackupMain.java @@ -53,8 +53,10 @@ public static void main(String[] args) { writer.append("\n-- DONE WITH MONTHLY CLONE"); } } - // delete older daily backups - DeleteOlderThanOneMonth.exec(writer); + if(monthlyTargetDir != null) { + // delete older daily backups + DeleteOlderThanOneMonth.exec(writer); + } writer.flush(); writer.close(); log.info("Done!"); @@ -75,7 +77,7 @@ private static File getTargetDir() { private static File getMonthlyTargetDir() { String targetDir = GithubBackupAppProps.getTargetDir(); String today = TimeUtil.format(TimeUtil.getNow(), "yyyy_MM_dd"); - if(today.endsWith("01") == false) { + if(today.endsWith("22") == false) { return null; } log.info("Today: " + today); diff --git a/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java b/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java index 55a5f95..3d0e001 100644 --- a/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java +++ b/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java @@ -32,7 +32,7 @@ public static void exec(BufferedWriter writer) { String fileName = file.getName(); log.info("FILE: " + fileName); writer.append("\nFILE: " + fileName); - if("MONTHLY".equals(fileName) == false && "github-backup".equals(fileName) == false && file.isDirectory() && fileName.contains(thisMonth) == false && fileName.contains(lastMonth) == false) { + if("MONTHLY".equals(fileName) == false && "github-backup".equals(fileName) == false && file.isDirectory() && fileName.contains(thisMonth)) { log.info("!!!REMOVING!!!"); writer.append("\n!!!REMOVING!!!"); FileUtil.rmdir(file);