Class DefaultBackupManager

java.lang.Object
net.solarnetwork.node.backup.DefaultBackupManager
All Implemented Interfaces:
BackupManager, net.solarnetwork.settings.SettingSpecifierProvider

public class DefaultBackupManager extends Object implements BackupManager
Default implementation of BackupManager.
Version:
2.0
Author:
matt
  • Constructor Details

    • DefaultBackupManager

      public DefaultBackupManager()
  • Method Details

    • init

      public void init()
      Initialize after all properties set.
    • getSettingUid

      public String getSettingUid()
      Specified by:
      getSettingUid in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getMessageSource

      public org.springframework.context.MessageSource getMessageSource()
      Specified by:
      getMessageSource in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getSettingSpecifiers

      public List<net.solarnetwork.settings.SettingSpecifier> getSettingSpecifiers()
      Specified by:
      getSettingSpecifiers in interface net.solarnetwork.settings.SettingSpecifierProvider
    • activeBackupService

      public BackupService activeBackupService()
      Description copied from interface: BackupManager
      Get the active BackupService.
      Specified by:
      activeBackupService in interface BackupManager
      Returns:
      the BackupService, or null if none configured
    • resourcesForBackup

      public Iterable<BackupResource> resourcesForBackup()
      Description copied from interface: BackupManager
      Get a Iterator of BackupResource needing to be backed up.
      Specified by:
      resourcesForBackup in interface BackupManager
      Returns:
      the backup resources
    • createBackup

      public Backup createBackup()
      Description copied from interface: BackupManager
      Create a new Backup, using the active backup service.
      Specified by:
      createBackup in interface BackupManager
      Returns:
      the backup, or null if none could be created
    • createBackup

      public Backup createBackup(Map<String,String> props)
      Description copied from interface: BackupManager
      Create a new Backup, using the active backup service.
      Specified by:
      createBackup in interface BackupManager
      Parameters:
      props - An optional set of properties to customize the backup with.
      Returns:
      the backup, or null if none could be created
    • createAsynchronousBackup

      public Future<Backup> createAsynchronousBackup()
      Description copied from interface: BackupManager
      Create a new Backup, using the active backup service, in the background. This method will immediately return a Future where you can track the status of the background backup, if desired.
      Specified by:
      createAsynchronousBackup in interface BackupManager
      Returns:
      the backup, or null if none could be created
    • createAsynchronousBackup

      public Future<Backup> createAsynchronousBackup(Map<String,String> props)
      Description copied from interface: BackupManager
      Create a new Backup, using the active backup service, in the background. This method will immediately return a Future where you can track the status of the background backup, if desired.
      Specified by:
      createAsynchronousBackup in interface BackupManager
      Parameters:
      props - An optional set of properties to customize the backup with.
      Returns:
      the backup, or null if none could be created
    • exportBackupArchive

      public void exportBackupArchive(String backupKey, OutputStream out) throws IOException
      Description copied from interface: BackupManager
      Export a backup zip archive.
      Specified by:
      exportBackupArchive in interface BackupManager
      Parameters:
      backupKey - the backup to export
      out - the output stream to export to
      Throws:
      IOException - if any IO error occurs
    • exportBackupArchive

      public void exportBackupArchive(String backupKey, OutputStream out, Map<String,String> props) throws IOException
      Description copied from interface: BackupManager
      Export a backup zip archive.
      Specified by:
      exportBackupArchive in interface BackupManager
      Parameters:
      backupKey - the backup to export
      out - the output stream to export to
      props - An optional set of properties to customize the backup with.
      Throws:
      IOException - if any IO error occurs
    • importBackupArchive

      public Future<Backup> importBackupArchive(InputStream archive) throws IOException
      Description copied from interface: BackupManager
      Import a backup archive into the active backup service. This method can import an archive exported via BackupManager.exportBackupArchive(String, OutputStream). Once imported, the backup will appear as a new backup in the active backup service.
      Specified by:
      importBackupArchive in interface BackupManager
      Parameters:
      archive - the archive input stream to import
      Returns:
      the backup future
      Throws:
      IOException - if any IO error occurs
    • importBackupArchive

      public Future<Backup> importBackupArchive(InputStream archive, Map<String,String> props) throws IOException
      Description copied from interface: BackupManager
      Import a backup archive with properties. This method can import an archive exported via BackupManager.exportBackupArchive(String, OutputStream). The BackupManager.RESOURCE_PROVIDER_FILTER property can be used to filter which provider resources are included in the imported backup. The BackupManager.BACKUP_KEY can be used to provide a hint of the original backup key (and possibly date). Once imported, the backup will appear as a new backup in the active backup service.
      Specified by:
      importBackupArchive in interface BackupManager
      Parameters:
      archive - the archive input stream to import
      props - An optional set of properties to customize the backup with.
      Returns:
      the backup future
      Throws:
      IOException - if any IO error occurs
    • restoreBackup

      public void restoreBackup(Backup backup)
      Description copied from interface: BackupManager
      Restore all resources from a given backup.
      Specified by:
      restoreBackup in interface BackupManager
      Parameters:
      backup - the backup to restore
    • restoreBackup

      public void restoreBackup(Backup backup, Map<String,String> props)
      Description copied from interface: BackupManager
      Restore all resources from a given backup.
      Specified by:
      restoreBackup in interface BackupManager
      Parameters:
      backup - the backup to restore
      props - An optional set of properties to customize the backup with.
    • infoForBackup

      public BackupInfo infoForBackup(String key, Locale locale)
      Description copied from interface: BackupManager
      Get metadata about a particular backup.
      Specified by:
      infoForBackup in interface BackupManager
      Parameters:
      key - The key of the backup to get the information for.
      locale - The desired locale of the information, or null for the system locale.
      Returns:
      The backup info, or null if no backup is available for the given key.
    • setBackupServices

      public void setBackupServices(Collection<BackupService> backupServices)
      Set a collection of BackupService instances to allow backing up and restoring with.
      Parameters:
      backupServices - the backup services to use
    • setResourceProviders

      public void setResourceProviders(Collection<BackupResourceProvider> resourceProviders)
      Set a collection of BackupResourceProvider instances that provide the resources to be backed up.
      Parameters:
      resourceProviders - the resource providers to backup resources from
    • setExecutorService

      public void setExecutorService(ExecutorService executorService)
      Set the executor service to use for tasks.
      Parameters:
      executorService - the service to use
    • setBackupRestoreDelaySeconds

      public void setBackupRestoreDelaySeconds(int backupRestoreDelaySeconds)
      Set a number of seconds to delay the attempt of restoring a backup, when a backup has been previously marked for restoration. This delay gives the platform time to boot up and register the backup resource providers and other services required to perform the restore.
      Parameters:
      backupRestoreDelaySeconds - The number of seconds to delay attempting to restore from backup.
      Since:
      1.1
    • setPreferredBackupServiceKey

      public void setPreferredBackupServiceKey(String preferredBackupServiceKey)
      Set the key of the preferred backup service to use.
      Parameters:
      preferredBackupServiceKey - the service key to set
      Since:
      1.4