Class BackupSet
- java.lang.Object
-
- org.jvnet.hudson.plugins.thinbackup.backup.BackupSet
-
- All Implemented Interfaces:
Comparable<BackupSet>
public class BackupSet extends Object implements 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
Fields Modifier and Type Field Description static String
BACKUPSET_ZIPFILE_PREFIX
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(BackupSet other)
Compares the backup sets by using the sets' associated full backups' backup date.boolean
containsBackupForDate(Date date)
boolean
containsDirectory(File directory)
void
delete()
void
deleteUnzipDir()
Deletes the directory used for unzipping this BackupSet.boolean
equals(Object o)
List<File>
getDiffBackups()
List<String>
getDiffBackupsNames()
File
getFullBackup()
String
getFullBackupName()
File
getUnzipDir()
int
hashCode()
boolean
isInZipFile()
boolean
isValid()
String
toString()
BackupSet
unzip()
Unzips this backup set if it was initialized from a ZIP file.BackupSet
unzipTo(File directory)
Unzips this backup set into a directory within the specified directory if it was initialized from a ZIP file.File
zipTo(File directory)
-
-
-
Field Detail
-
BACKUPSET_ZIPFILE_PREFIX
public static final String BACKUPSET_ZIPFILE_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BackupSet
public BackupSet(File initial)
- Parameters:
initial
- either a FULL or DIFF backup directory, or a BackupSet ZIP file.
-
-
Method Detail
-
isValid
public boolean isValid()
- Returns:
- true if this backup set has a referenced full backup.
-
delete
public void delete() throws IOException
- 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.
-
unzip
public BackupSet unzip() throws IOException
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
public BackupSet unzipTo(File directory) throws IOException
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
public File zipTo(File directory)
- 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.
-
compareTo
public int compareTo(BackupSet other)
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
public boolean containsDirectory(File directory)
- 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
public boolean containsBackupForDate(Date date)
- 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
public File getFullBackup()
- Returns:
- the full backup directory reference, or null if this BackupSet is in a ZIP file.
-
getFullBackupName
public String getFullBackupName()
- Returns:
- the name of full backup directory.
-
getDiffBackups
public List<File> getDiffBackups()
- Returns:
- a List of diff backup directory references, or null if this BackupSet is in a ZIP file.
-
getDiffBackupsNames
public List<String> getDiffBackupsNames()
- Returns:
- a List of diff backup directory names.
-
getUnzipDir
public File 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.
-
-