Skip to content
Permalink
Browse files
JENKINS-13239: provide a option to skip the wait for idle condition (…
…untested)

git-svn-id: https://svn.jenkins-ci.org/trunk/hudson/plugins/thinBackup@40359 71c3de6d-444a-0410-be80-ed276b4c234a
  • Loading branch information
msteinkogler committed Mar 27, 2012
1 parent 6fea7c2 commit 5324059e1f9100af23612ecba1049a9384a032e5
Showing 4 changed files with 68 additions and 10 deletions.
@@ -76,8 +76,12 @@ protected void backupNow(final BackupType type) {
backupPath = plugin.getExpandedBackupPath();

if (!StringUtils.isEmpty(backupPath)) {
LOGGER.fine("Wait until executors are idle to perform backup.");
Utils.waitUntilIdleAndSwitchToQuietMode(plugin.getForceQuietModeTimeout(), TimeUnit.MINUTES);
if (plugin.isWaitForIdle()) {
LOGGER.fine("Wait until executors are idle to perform backup.");
Utils.waitUntilIdleAndSwitchToQuietMode(plugin.getForceQuietModeTimeout(), TimeUnit.MINUTES);
} else
LOGGER.warning("Do not wait until jenkins/hudson is idle to perform backup. This could cause corrupt backups.");

new HudsonBackup(plugin, type).backup();
} else {
LOGGER.warning("ThinBackup is not configured yet: No backup path set.");
@@ -42,15 +42,16 @@ public class ThinBackupPluginImpl extends Plugin {

private String fullBackupSchedule = "";
private String diffBackupSchedule = "";
private int forceQuietModeTimeout = Utils.FORCE_QUIETMODE_TIMEOUT_MINUTES;
private String backupPath = "";
private int nrMaxStoredFull = -1;
private String excludedFilesRegex = null;
private boolean waitForIdle = true;
private int forceQuietModeTimeout = Utils.FORCE_QUIETMODE_TIMEOUT_MINUTES;
private boolean cleanupDiff = false;
private boolean moveOldBackupsToZipFile = false;
private boolean backupBuildResults = true;
private boolean backupBuildArchive = false;
private boolean backupNextBuildNumber = false;
private String excludedFilesRegex = null;

private static ThinBackupPluginImpl instance = null;

@@ -201,6 +202,14 @@ public String getExcludedFilesRegex() {
return excludedFilesRegex;
}

public void setWaitForIdle(boolean waitForIdle) {
this.waitForIdle = waitForIdle;
}

public boolean isWaitForIdle() {
return this.waitForIdle;
}

public FormValidation doCheckForceQuietModeTimeout(final StaplerRequest res, final StaplerResponse rsp,
@QueryParameter("value") final int timeout) {
if (timeout < 0)
@@ -312,5 +321,12 @@ public FormValidation doCheckExcludedFilesRegex(final StaplerRequest res, final

return FormValidation.ok();
}

public FormValidation doCheckWaitForIdle(final StaplerRequest res, final StaplerResponse rsp, @QueryParameter("value") final String waitForIdle) {
if (Boolean.parseBoolean(waitForIdle))
return FormValidation.ok();
else
return FormValidation.warning("This may or may not generate corrupt backups! Be aware that no data get changed during the backup process!");
}

}
@@ -45,12 +45,6 @@
checkUrl="'${rootUrl}/plugin/thinBackup/checkBackupSchedule?value='+escape(this.value)"/>
</f:entry>

<f:entry title="Force Jenkins to quiet mode after specified minutes" field="forceQuietModeTimeout"
help="/plugin/thinBackup/help/help-forceQuietModeTimeout.html">
<f:textbox value="${it.configuration.forceQuietModeTimeout}" name="forceQuietModeTimeout"
checkUrl="'${rootUrl}/plugin/thinBackup/checkForceQuietModeTimeout?value='+escape(this.value)"/>
</f:entry>

<f:entry title="Max number of backup sets" field="nrMaxStoredFull"
help="/plugin/thinBackup/help/help-nrMaxStoredFull.html">
<f:textbox value="${it.configuration.nrMaxStoredFull}" name="nrMaxStoredFull" />
@@ -61,6 +55,17 @@
<f:textbox value="${it.configuration.excludedFilesRegex}" name="excludedFilesRegex"
checkUrl="'${rootUrl}/plugin/thinBackup/checkExcludedFilesRegex?value='+escape(this.value)"/>
</f:entry>

<f:optionalBlock title="Wait until Jenkins/Hudson is idle to perform a backup"
help="/plugin/thinBackup/help/help-waitForIdle.html"
checked="${it.configuration.waitForIdle}"
name="waitForIdle" >
<f:entry title="Force Jenkins to quiet mode after specified minutes" field="forceQuietModeTimeout"
help="/plugin/thinBackup/help/help-forceQuietModeTimeout.html">
<f:textbox value="${it.configuration.forceQuietModeTimeout}" name="forceQuietModeTimeout"
checkUrl="'${rootUrl}/plugin/thinBackup/checkForceQuietModeTimeout?value='+escape(this.value)"/>
</f:entry>
</f:optionalBlock>

<f:optionalBlock title="Backup build results"
help="/plugin/thinBackup/help/help-backupBuildResults.html"
@@ -0,0 +1,33 @@
<!--
The MIT License
Copyright (c) 2011, Borland (a Micro Focus Company), Matthias Steinkogler, Thomas Fuerer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<div>
<p>
Wait until Jenkins/Hudson is idle to perform a backup (recommended/default setting). However, you can do a backup without waiting for the idle condition. This may cause problems which results in corrupt backups, because files that will be written in the same moment as they will be backuped could be locked in the file system.
Nevertheless, in the case of long running jobs (e.g. test jobs) you probably do not have a free time slot for your backup task. During this jobs you are sure nothing is changed or locked in the file system (e.g. because the build job is done on a slave). In this case you could disable this option to perform a backup in parallel to a running job.
</p>
<p>
<b>NOTE:</b><br/>We cannot 100% guarantee that the backup is correct if you disable this option.
</p>
</div>

0 comments on commit 5324059

Please sign in to comment.