Class BackupSet
java.lang.Object
org.jvnet.hudson.plugins.thinbackup.backup.BackupSet
- All Implemented Interfaces:
Comparable<BackupSet>
A BackupSet contains references to a full and zero or more diff backups. It can be created from either a reference to
a full or diff backup directory or from a reference to a ZIP file. If it is created from a ZIP file, the BackupSet
must be unzipped before the data contained can be actually accessed (it is never unzipped automatically).
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Compares the backup sets by using the sets' associated full backups' backup date.boolean
containsBackupForDate
(Date date) boolean
containsDirectory
(File directory) void
delete()
void
Deletes the directory used for unzipping this BackupSet.boolean
int
hashCode()
boolean
boolean
isValid()
toString()
unzip()
Unzips this backup set if it was initialized from a ZIP file.Unzips this backup set into a directory within the specified directory if it was initialized from a ZIP file.
-
Field Details
-
BACKUPSET_ZIPFILE_PREFIX
- See Also:
-
-
Constructor Details
-
BackupSet
- Parameters:
initial
- either a FULL or DIFF backup directory, or a BackupSet ZIP file.
-
-
Method Details
-
isValid
public boolean isValid()- Returns:
- true if this backup set has a referenced full backup.
-
delete
- Throws:
IOException
-
deleteUnzipDir
public void deleteUnzipDir()Deletes the directory used for unzipping this BackupSet. Note that this will make BackupSets created from that directory no longer usable. -
toString
-
unzip
Unzips this backup set if it was initialized from a ZIP file. Does does NOT change this. Unzip location is Utils.THINBACKUP_TMP_DIR. deleteUnzipDir() may be called if the unzipped BackupSet is no longer needed. Before using the returned BackupSet, it should be checked if it is valid.- Returns:
- a new BackupSet referencing the unzipped directories, or the current BackupSet if it was either not created from a ZIP file or is invalid. In case of an error an invalid BackupSet is returned.
- Throws:
IOException
- - if an I/O error occurs.
-
unzipTo
Unzips this backup set into a directory within the specified directory if it was initialized from a ZIP file. Does NOT change this. deleteUnzipDir() may be called if the unzipped BackupSet is no longer needed. The directory the BackupSet was unzipped to can be retrieved with getUnzipDir(). Before using the returned BackupSet, it should be checked if it is valid.- Parameters:
directory
- target directory- Returns:
- a new BackupSet referencing the unzipped directories, or the current BackupSet if it was either not created from a ZIP file or is invalid. In case of an error an invalid BackupSet is returned.
- Throws:
IOException
- - if an I/O error occurs.
-
zipTo
- Parameters:
directory
- target directory- Returns:
- a reference to the created ZIP file, the current ZIP file if the BackupSet was created from one (because no zipping is performed in this case), or null if this BackupSet is invalid.
-
equals
-
hashCode
public int hashCode() -
compareTo
Compares the backup sets by using the sets' associated full backups' backup date.- Specified by:
compareTo
in interfaceComparable<BackupSet>
- Returns:
- -1 if this BackupSet's full backup date is before the other's, 0 if they are equal, 1 if is after the other's.
-
containsDirectory
- Parameters:
directory
- directory to search for- Returns:
- true if this BackupSet contains a backup directory with the same name or if directory is null. Note that only the top level backup directories are checked, not any other contents of the BackupSet.
-
containsBackupForDate
- Parameters:
date
- date to search for- Returns:
- true if a backup for the given date exists in this BackupSet.
-
isInZipFile
public boolean isInZipFile()- Returns:
- true if this BackupSet was constructed from a ZIP file.
-
getFullBackup
- Returns:
- the full backup directory reference, or null if this BackupSet is in a ZIP file.
-
getFullBackupName
- Returns:
- the name of full backup directory.
-
getDiffBackups
- Returns:
- a List of diff backup directory references, or null if this BackupSet is in a ZIP file.
-
getDiffBackupsNames
- Returns:
- a List of diff backup directory names.
-
getUnzipDir
- Returns:
- a reference to the directory where this BackupSet was unzipped, or null if it either was not yet unzipped or if this BackupSet is not in a ZIP file.
-