Package net.solarnetwork.node.backup
Class DefaultBackupManager
java.lang.Object
net.solarnetwork.node.backup.DefaultBackupManager
- All Implemented Interfaces:
BackupManager,net.solarnetwork.settings.SettingSpecifierProvider
Default implementation of
BackupManager.- Version:
- 2.0
- Author:
- matt
-
Field Summary
Fields inherited from interface net.solarnetwork.node.backup.BackupManager
BACKUP_KEY, RESOURCE_PROVIDER_FILTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the activeBackupService.Create a new Backup, using the active backup service, in the background.createAsynchronousBackup(Map<String, String> props) Create a new Backup, using the active backup service, in the background.Create a new Backup, using the active backup service.createBackup(Map<String, String> props) Create a new Backup, using the active backup service.voidexportBackupArchive(String backupKey, OutputStream out) Export a backup zip archive.voidexportBackupArchive(String backupKey, OutputStream out, Map<String, String> props) Export a backup zip archive.org.springframework.context.MessageSourceList<net.solarnetwork.settings.SettingSpecifier>importBackupArchive(InputStream archive) Import a backup archive into the active backup service.importBackupArchive(InputStream archive, Map<String, String> props) Import a backup archive with properties.infoForBackup(String key, Locale locale) Get metadata about a particular backup.voidinit()Initialize after all properties set.Get aIteratorofBackupResourceneeding to be backed up.voidrestoreBackup(Backup backup) Restore all resources from a given backup.voidrestoreBackup(Backup backup, Map<String, String> props) Restore all resources from a given backup.voidsetBackupRestoreDelaySeconds(int backupRestoreDelaySeconds) Set a number of seconds to delay the attempt of restoring a backup, when a backup has been previously marked for restoration.voidsetBackupServices(Collection<BackupService> backupServices) Set a collection ofBackupServiceinstances to allow backing up and restoring with.voidsetExecutorService(ExecutorService executorService) Set the executor service to use for tasks.voidsetPreferredBackupServiceKey(String preferredBackupServiceKey) Set the key of the preferred backup service to use.voidsetResourceProviders(Collection<BackupResourceProvider> resourceProviders) Set a collection ofBackupResourceProviderinstances that provide the resources to be backed up.
-
Constructor Details
-
DefaultBackupManager
public DefaultBackupManager()
-
-
Method Details
-
init
public void init()Initialize after all properties set. -
getSettingUid
- Specified by:
getSettingUidin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getDisplayName
- Specified by:
getDisplayNamein interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getMessageSource
public org.springframework.context.MessageSource getMessageSource()- Specified by:
getMessageSourcein interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getSettingSpecifiers
- Specified by:
getSettingSpecifiersin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
activeBackupService
Description copied from interface:BackupManagerGet the activeBackupService.- Specified by:
activeBackupServicein interfaceBackupManager- Returns:
- the BackupService, or null if none configured
-
resourcesForBackup
Description copied from interface:BackupManagerGet aIteratorofBackupResourceneeding to be backed up.- Specified by:
resourcesForBackupin interfaceBackupManager- Returns:
- the backup resources
-
createBackup
Description copied from interface:BackupManagerCreate a new Backup, using the active backup service.- Specified by:
createBackupin interfaceBackupManager- Returns:
- the backup, or null if none could be created
-
createBackup
Description copied from interface:BackupManagerCreate a new Backup, using the active backup service.- Specified by:
createBackupin interfaceBackupManager- Parameters:
props- An optional set of properties to customize the backup with.- Returns:
- the backup, or null if none could be created
-
createAsynchronousBackup
Description copied from interface:BackupManagerCreate 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:
createAsynchronousBackupin interfaceBackupManager- Returns:
- the backup, or null if none could be created
-
createAsynchronousBackup
Description copied from interface:BackupManagerCreate 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:
createAsynchronousBackupin interfaceBackupManager- Parameters:
props- An optional set of properties to customize the backup with.- Returns:
- the backup, or null if none could be created
-
exportBackupArchive
Description copied from interface:BackupManagerExport a backup zip archive.- Specified by:
exportBackupArchivein interfaceBackupManager- Parameters:
backupKey- the backup to exportout- 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 IOExceptionDescription copied from interface:BackupManagerExport a backup zip archive.- Specified by:
exportBackupArchivein interfaceBackupManager- Parameters:
backupKey- the backup to exportout- the output stream to export toprops- An optional set of properties to customize the backup with.- Throws:
IOException- if any IO error occurs
-
importBackupArchive
Description copied from interface:BackupManagerImport a backup archive into the active backup service. This method can import an archive exported viaBackupManager.exportBackupArchive(String, OutputStream). Once imported, the backup will appear as a new backup in the active backup service.- Specified by:
importBackupArchivein interfaceBackupManager- 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 IOExceptionDescription copied from interface:BackupManagerImport a backup archive with properties. This method can import an archive exported viaBackupManager.exportBackupArchive(String, OutputStream). TheBackupManager.RESOURCE_PROVIDER_FILTERproperty can be used to filter which provider resources are included in the imported backup. TheBackupManager.BACKUP_KEYcan 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:
importBackupArchivein interfaceBackupManager- Parameters:
archive- the archive input stream to importprops- An optional set of properties to customize the backup with.- Returns:
- the backup future
- Throws:
IOException- if any IO error occurs
-
restoreBackup
Description copied from interface:BackupManagerRestore all resources from a given backup.- Specified by:
restoreBackupin interfaceBackupManager- Parameters:
backup- the backup to restore
-
restoreBackup
Description copied from interface:BackupManagerRestore all resources from a given backup.- Specified by:
restoreBackupin interfaceBackupManager- Parameters:
backup- the backup to restoreprops- An optional set of properties to customize the backup with.
-
infoForBackup
Description copied from interface:BackupManagerGet metadata about a particular backup.- Specified by:
infoForBackupin interfaceBackupManager- 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
Set a collection ofBackupServiceinstances to allow backing up and restoring with.- Parameters:
backupServices- the backup services to use
-
setResourceProviders
Set a collection ofBackupResourceProviderinstances that provide the resources to be backed up.- Parameters:
resourceProviders- the resource providers to backup resources from
-
setExecutorService
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
Set the key of the preferred backup service to use.- Parameters:
preferredBackupServiceKey- the service key to set- Since:
- 1.4
-