Class Utils
java.lang.Object
org.jvnet.hudson.plugins.thinbackup.utils.Utils
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertToDirectoryNameDateFormat
(String displayFormattedDate) static String
getBackupsAsDates
(File directory) getBackupSetZipFiles
(File parentDir) getBackupTypeDirectories
(File parentDir, ThinBackupPeriodicWork.BackupType backupType) static Date
getDateFromBackupDirectory
(File directory) static Date
getDateFromBackupDirectoryName
(String directoryName) static File
getFormattedDirectory
(File parent, ThinBackupPeriodicWork.BackupType backupType, Date date) static File
getReferencedFullBackup
(File diffBackup) getReferencingDiffBackups
(File fullBackup) getValidBackupSets
(File directory) getValidBackupSetsFromDirectories
(File directory) getValidBackupSetsFromZips
(File directory) protected static String
internalExpandEnvironmentVariables
(String path, Map<String, String> environmentVariables) static void
moveOldBackupsToZipFile
(File backupRoot, File currentBackup) Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.static void
static void
Waits until all Hudson slaves are idle.static void
waitUntilIdleAndSwitchToQuietMode
(int timeout, TimeUnit unit) Waits until all executors are idle and switch jenkins to quiet mode.
-
Field Details
-
DISPLAY_DATE_FORMAT
- See Also:
-
DIRECTORY_NAME_DATE_FORMAT
- See Also:
-
THINBACKUP_TMP_DIR
-
FORCE_QUIETMODE_TIMEOUT_MINUTES
public static final int FORCE_QUIETMODE_TIMEOUT_MINUTES- See Also:
-
-
Method Details
-
waitUntilIdle
public static void waitUntilIdle()Waits until all Hudson slaves are idle. -
waitUntilIdleAndSwitchToQuietMode
Waits until all executors are idle and switch jenkins to quiet mode. If it takes to long that all executors are idle because in the mean time other jobs are executed the timeout ensure that the quiet mode is forced. But if timeout is set to -1, it will never force jenkins to quiet mode.- Parameters:
timeout
- specifies when a quiet mode is forced. 0 = no timeout; -1 = disable timer, never force jenkins to quiet mode.unit
- specifies the time unit for the value of timeout.- Throws:
IOException
- ?
-
getDateFromBackupDirectory
- Parameters:
directory
- directory to get the date from- Returns:
- the date component of a directory name formatted in the thinBackup standard
-
getDateFromBackupDirectoryName
- Parameters:
directoryName
- directory name to get the date from- Returns:
- the date component of a directory name formatted in the thinBackup standard
-
convertToDirectoryNameDateFormat
public static String convertToDirectoryNameDateFormat(String displayFormattedDate) throws ParseException - Parameters:
displayFormattedDate
- a String in the display format date- Returns:
- the string formatted in the directory names' date format
- Throws:
ParseException
- if the beginning of the specified parameter cannot be parsed.
-
getFormattedDirectory
public static File getFormattedDirectory(File parent, ThinBackupPeriodicWork.BackupType backupType, Date date) - Parameters:
parent
- root directory of all backupsbackupType
- type of backupdate
- date of backup- Returns:
- a reference to a file in the given parent directory with a name formatted like "<BACKUP_TYPE>-yyyy-MM-dd_HH-mm".
-
getBackupTypeDirectories
public static List<File> getBackupTypeDirectories(File parentDir, ThinBackupPeriodicWork.BackupType backupType) - Parameters:
parentDir
- root directory of all backupsbackupType
- type of backup- Returns:
- an unordered list of backup directories of the given backup type.
-
getBackupSetZipFiles
- Parameters:
parentDir
- root directory of all backups- Returns:
- an unordered list of zipped backupsets in the given directory.
-
getReferencedFullBackup
- Parameters:
diffBackup
- diff backup- Returns:
- the full backup referenced by the given diff backup, or null if none can be found.
-
getReferencingDiffBackups
- Parameters:
fullBackup
- fill backup- Returns:
- a list of all diff backups which reference the given full backup.
-
getBackupsAsDates
- Parameters:
directory
- root directory of all backups- Returns:
- a list of backups in the given directory (both FULL and DIFF), displayed as the respective backup date, from both directories and ZIP files, ordered descending by the date encoded in the backups' name.
-
getValidBackupSetsFromDirectories
- Parameters:
directory
- root directory of all backups- Returns:
- a list of valid (@see BackupSet#isValid) backup sets that exists as directories (not as ZIP files) in the given directory, ordered ascending by the backup date of the BackupSets' full backup.
-
getValidBackupSetsFromZips
- Parameters:
directory
- root directory of all backups- Returns:
- a list of valid (@see BackupSet#isValid) backup sets that exists as ZIP files (not as directories) in the given directory, ordered ascending by the backup date of the BackupSets' full backup.
-
getValidBackupSets
- Parameters:
directory
- root directory of all backups- Returns:
- a list of valid (@see BackupSet#isValid) backup sets in the given directory, ordered ascending by the backup date of the BackupSets' full backup.
-
moveOldBackupsToZipFile
Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.- Parameters:
backupRoot
- root directory of all backupscurrentBackup
- specified which backup should be omitted from being moved. If null, all backups are moved to ZIP files.
-
expandEnvironmentVariables
public static String expandEnvironmentVariables(String path) throws EnvironmentVariableNotDefinedException -
internalExpandEnvironmentVariables
-
waitUntilFileCanBeRead
-