diff --git a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions.properties b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions.properties
index a5b4f84..17c3bb3 100644
--- a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions.properties
+++ b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions.properties
@@ -3,3 +3,4 @@ restore_configuration = Restore Configuration
restore_next_build_number = Restore next build number file (if found in backup)
restore_options = Restore options
restore_plugins = Restore plugins
+restore_config_history = Restore config-history (if found in backup)
diff --git a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions_de.properties b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions_de.properties
index ff7c126..f2685b5 100644
--- a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions_de.properties
+++ b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupMgmtLink/restoreOptions_de.properties
@@ -1,5 +1,6 @@
restore_backup_from = Backup wiederherstellen von:
restore_configuration = Restore Konfiguration
-restore_next_build_number = Nächste Build Nummer Datein wiederherstellen (falls im Backup vorhanden)
+restore_next_build_number = Nächste Build Nummer Dateien wiederherstellen (falls im Backup vorhanden)
restore_options = Restore Optionen
restore_plugins = Plugins wiederherstellen
+restore_config_history = Config-history wiederherstellen (falls im Backup vorhanden)
diff --git a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory.html b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory.html
index 448b4fd..0111c69 100644
--- a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory.html
+++ b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory.html
@@ -24,6 +24,6 @@
- If this option is enabled, the directory config-history will also be backed up.
+ If this option is enabled, the directory which is configured within the config-history plugin will also be backed up (only if plugin is installed).
diff --git a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory_de.html b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory_de.html
index 452bc0f..20afc91 100644
--- a/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory_de.html
+++ b/src/main/resources/org/jvnet/hudson/plugins/thinbackup/ThinBackupPluginImpl/help-backupConfigHistory_de.html
@@ -24,6 +24,6 @@
- Falls diese Option aktiviert ist, wird das Verzeichnis config-history zum Backup hinzugefügt.
+ Falls diese Option aktiviert ist, wird das Verzeichnis, welches im config-history konfiguriert ist, zum Backup hinzugefügt (nur wenn das Plugin installiert ist).
diff --git a/src/main/webapp/help/help-restoreConfigHistory.html b/src/main/webapp/help/help-restoreConfigHistory.html
new file mode 100644
index 0000000..5811b82
--- /dev/null
+++ b/src/main/webapp/help/help-restoreConfigHistory.html
@@ -0,0 +1,30 @@
+
+
+
+
+ If this option is enabled, the config-history gets restored.
+ This will only work, if the config-history plugin is installed, otherwise it cannot read the config folder.
+
+
diff --git a/src/main/webapp/help/help-restoreConfigHistory_de.html b/src/main/webapp/help/help-restoreConfigHistory_de.html
new file mode 100644
index 0000000..3c5cb87
--- /dev/null
+++ b/src/main/webapp/help/help-restoreConfigHistory_de.html
@@ -0,0 +1,30 @@
+
+
+
+
+ Falls diese Option aktiviert ist, wird die config-history aus dem Backup wiederhergestellt.
+ Es wird nur funktionieren, falls das config-history Plugin installiert ist, sonst kann der Konfigurationsordner nicht ausgelesen werden.
+
+
diff --git a/src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestBackupWithCloudBeesFolder.java b/src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestBackupWithCloudBeesFolder.java
index 7d0f86d..6bcbc64 100644
--- a/src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestBackupWithCloudBeesFolder.java
+++ b/src/test/java/org/jvnet/hudson/plugins/thinbackup/backup/TestBackupWithCloudBeesFolder.java
@@ -22,7 +22,7 @@
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
@WithJenkins
-class TestBackupWithCloudBeesFolder {
+class TestBackupWithFolder {
@TempDir
private File tmpFolder;
diff --git a/src/test/java/org/jvnet/hudson/plugins/thinbackup/restore/TestRestore.java b/src/test/java/org/jvnet/hudson/plugins/thinbackup/restore/TestRestore.java
index d29144d..48c7577 100644
--- a/src/test/java/org/jvnet/hudson/plugins/thinbackup/restore/TestRestore.java
+++ b/src/test/java/org/jvnet/hudson/plugins/thinbackup/restore/TestRestore.java
@@ -16,6 +16,7 @@
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
+import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.jvnet.hudson.plugins.thinbackup.ThinBackupPeriodicWork;
@@ -32,6 +33,64 @@ class TestRestore {
@TempDir
private File tmpFolder;
+ @Test
+ void testRestoreWithConfigHistory(JenkinsRule r) throws Exception {
+ // create to test afterward
+ File backupDir = newFolder(tmpFolder, "junit");
+
+ final ThinBackupPluginImpl thinBackupPlugin = ThinBackupPluginImpl.get();
+ thinBackupPlugin.setBackupPath(backupDir.getAbsolutePath());
+ thinBackupPlugin.setBackupBuildResults(true);
+ thinBackupPlugin.setBackupNextBuildNumber(true);
+ thinBackupPlugin.setBackupConfigHistory(true);
+ final File rootDir = r.jenkins.getRootDir();
+ final Date date = new Date();
+
+ // create 2 jobs
+ final FreeStyleProject test = r.createFreeStyleProject("test");
+ final FreeStyleProject test2 = r.createFreeStyleProject("test2");
+
+ // adjust description to create config history
+ test.setDescription("new test");
+ test2.setDescription("new test2");
+
+ // run backup
+ final HudsonBackup backup =
+ new HudsonBackup(thinBackupPlugin, ThinBackupPeriodicWork.BackupType.FULL, date, r.jenkins);
+ backup.backup();
+
+ // delete jobs
+ test.delete();
+ test2.delete();
+
+ // delete config-history
+ final File configHistory = new File(rootDir, "config-history");
+ FileUtils.deleteDirectory(configHistory);
+
+ // check that files are gone
+ final File jobs = new File(rootDir, "jobs");
+ String[] jobList = jobs.list();
+ assertEquals(0, jobList.length);
+
+ // now do the restore without config-history
+ HudsonRestore hudsonRestore =
+ new HudsonRestore(rootDir, backupDir.getAbsolutePath(), date, false, false, false);
+ hudsonRestore.restore();
+
+ // verify jobs are back
+ jobList = jobs.list();
+ assertEquals(2, jobList.length);
+
+ // verify config-history is missing
+ assertFalse(configHistory.exists());
+
+ // restore from backup INCLUDING config-history
+ hudsonRestore = new HudsonRestore(rootDir, backupDir.getAbsolutePath(), date, false, false, true);
+ hudsonRestore.restore();
+
+ assertTrue(configHistory.exists());
+ }
+
@Test
void testRestoreFromFolder(JenkinsRule r) throws Exception {
// create to test afterward
@@ -72,7 +131,8 @@ void testRestoreFromFolder(JenkinsRule r) throws Exception {
assertEquals(0, jobList.length);
// now do the restore without build number
- HudsonRestore hudsonRestore = new HudsonRestore(rootDir, backupDir.getAbsolutePath(), date, false, false);
+ HudsonRestore hudsonRestore =
+ new HudsonRestore(rootDir, backupDir.getAbsolutePath(), date, false, false, false);
hudsonRestore.restore();
// verify jobs are back
@@ -83,7 +143,7 @@ void testRestoreFromFolder(JenkinsRule r) throws Exception {
assertFalse(new File(test2rootDir, "nextBuildNumber").exists());
// restore from backup INCLUDING build number
- hudsonRestore = new HudsonRestore(rootDir, backupDir.getAbsolutePath(), date, true, false);
+ hudsonRestore = new HudsonRestore(rootDir, backupDir.getAbsolutePath(), date, true, false, false);
hudsonRestore.restore();
assertTrue(new File(test2rootDir, "nextBuildNumber").exists());
@@ -146,7 +206,7 @@ void testRestoreFromZip(JenkinsRule r) throws Exception {
// now do the restore without build number
HudsonRestore hudsonRestore =
- new HudsonRestore(rootDir, backupDir.getAbsolutePath(), restoreFromDate, false, false);
+ new HudsonRestore(rootDir, backupDir.getAbsolutePath(), restoreFromDate, false, false, false);
hudsonRestore.restore();
// verify jobs are back
@@ -157,7 +217,7 @@ void testRestoreFromZip(JenkinsRule r) throws Exception {
assertFalse(new File(test2rootDir, "nextBuildNumber").exists());
// restore from backup INCLUDING build number
- hudsonRestore = new HudsonRestore(rootDir, backupDir.getAbsolutePath(), restoreFromDate, true, false);
+ hudsonRestore = new HudsonRestore(rootDir, backupDir.getAbsolutePath(), restoreFromDate, true, false, false);
hudsonRestore.restore();
assertTrue(new File(test2rootDir, "nextBuildNumber").exists());
@@ -166,7 +226,7 @@ void testRestoreFromZip(JenkinsRule r) throws Exception {
@Test
void testLogsForRestoringWithoutBackupPath(JenkinsRule r) {
try (LogRecorder l = new LogRecorder().capture(3).record("hudson.plugins.thinbackup", Level.SEVERE)) {
- final HudsonRestore hudsonRestore = new HudsonRestore(null, null, null, false, false);
+ final HudsonRestore hudsonRestore = new HudsonRestore(null, null, null, false, false, false);
hudsonRestore.restore();
assertThat(
l, recorded(Level.SEVERE, containsString("Backup path not specified for restoration. Aborting.")));
@@ -176,7 +236,7 @@ void testLogsForRestoringWithoutBackupPath(JenkinsRule r) {
@Test
void testLogsForRestoringWithoutRestoreFromDate(JenkinsRule r) {
try (LogRecorder l = new LogRecorder().capture(3).record("hudson.plugins.thinbackup", Level.SEVERE)) {
- final HudsonRestore hudsonRestore = new HudsonRestore(null, "/var/backup", null, false, false);
+ final HudsonRestore hudsonRestore = new HudsonRestore(null, "/var/backup", null, false, false, false);
hudsonRestore.restore();
assertThat(
l,