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 Details

  • Constructor Details

    • BackupSet

      public BackupSet(File initial)
      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

      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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(BackupSet other)
      Compares the backup sets by using the sets' associated full backups' backup date.
      Specified by:
      compareTo in interface Comparable<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.