Package net.solarnetwork.node.backup
Class FileSystemBackupService
java.lang.Object
net.solarnetwork.node.backup.BackupServiceSupport
net.solarnetwork.node.backup.FileSystemBackupService
- All Implemented Interfaces:
BackupService,net.solarnetwork.settings.SettingSpecifierProvider
public class FileSystemBackupService
extends BackupServiceSupport
implements net.solarnetwork.settings.SettingSpecifierProvider
BackupService implementation that copies files to another location in
the file system.- Version:
- 2.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA format for turning aBackupIdentity.getKey()value into a zip file name.static final StringThe value returned bygetKey().Fields inherited from class net.solarnetwork.node.backup.BackupServiceSupport
BACKUP_KEY_DATE_FORMAT, NODE_AND_DATE_BACKUP_KEY_PATTERN, OBJECT_MAPPER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackupForKey(String key) Get a backup for a given backup key.intGet the number of additional backups to maintain.Get a collection of Backup instances known by this service.Get the directory to backup to.getBackupResources(Backup backup) Get the resources for a specific backup.net.solarnetwork.service.OptionalService<IdentityService> Get the identity service.getInfo()Get general status information about the service.getKey()Get a unique key for this service.org.springframework.context.MessageSourcenet.solarnetwork.settings.SettingSpecifierProviderGet aSettingSpecifierProviderfor this service.net.solarnetwork.settings.SettingSpecifierProviderGet aSettingSpecifierProviderfor this service, when restoring from an existing backup.List<net.solarnetwork.settings.SettingSpecifier> importBackup(Date date, BackupResourceIterable resources, Map<String, String> props) Import a set of backup resources as a newBackup.performBackup(Iterable<BackupResource> resources) Execute a backup now.voidDelete any existing backups.voidsetAdditionalBackupCount(int additionalBackupCount) Set the number of additional backups to maintain.voidsetBackupDir(File backupDir) Set the directory to backup to.voidsetIdentityService(net.solarnetwork.service.OptionalService<IdentityService> identityService) Set the identity service.voidsetMessageSource(org.springframework.context.MessageSource messageSource) Set the message source.Methods inherited from class net.solarnetwork.node.backup.BackupServiceSupport
backupDateFromProps, backupDateFromProps, backupNodeIdFromProps, backupNodeIdFromProps, defaultBackuprDir, identityFromBackupKey, identityFromBackupKey, markBackupForRestore, markedBackupForRestore, markedBackupForRestoreFileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider
templateSettingSpecifiers
-
Field Details
-
KEY
The value returned bygetKey(). -
ARCHIVE_KEY_NAME_FORMAT
A format for turning aBackupIdentity.getKey()value into a zip file name.- See Also:
-
-
Constructor Details
-
FileSystemBackupService
public FileSystemBackupService()Default constructor.
-
-
Method Details
-
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
-
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource) Set the message source.- Parameters:
messageSource- the message source to set
-
getSettingSpecifiers
- Specified by:
getSettingSpecifiersin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getKey
Description copied from interface:BackupServiceGet a unique key for this service.This key should be unique among all possible implementations of BackupService.
- Specified by:
getKeyin interfaceBackupService- Returns:
- a unique key
-
getInfo
Description copied from interface:BackupServiceGet general status information about the service.- Specified by:
getInfoin interfaceBackupService- Returns:
- status info (never null)
-
backupForKey
Description copied from interface:BackupServiceGet a backup for a given backup key.- Specified by:
backupForKeyin interfaceBackupService- Parameters:
key- the key- Returns:
- the backup
-
performBackup
Description copied from interface:BackupServiceExecute a backup now.This method may block until the backup completes.
- Specified by:
performBackupin interfaceBackupService- Parameters:
resources- the resources to include in the backup- Returns:
- backup instance
-
getBackupResources
Description copied from interface:BackupServiceGet the resources for a specific backup.- Specified by:
getBackupResourcesin interfaceBackupService- Parameters:
backup- the backup to get the resources for- Returns:
- an
Iterablefor the backup resources
-
importBackup
Description copied from interface:BackupServiceImport a set of backup resources as a newBackup.- Specified by:
importBackupin interfaceBackupService- Parameters:
date- The backup date, or null if not known.resources- The resources to include in the backup.props- An optional map of properties to pass to the import process. TheBackupManager.BACKUP_KEYproperty can be used to provide a proposed backup key.- Returns:
- A backup instance for the imported resources.
-
removeAllBackups
public void removeAllBackups()Delete any existing backups. -
getAvailableBackups
Description copied from interface:BackupServiceGet a collection of Backup instances known by this service.These should be ideally ordered in newest to oldest order.
- Specified by:
getAvailableBackupsin interfaceBackupService- Returns:
- the available backups, never null
-
getSettingSpecifierProvider
public net.solarnetwork.settings.SettingSpecifierProvider getSettingSpecifierProvider()Description copied from interface:BackupServiceGet aSettingSpecifierProviderfor this service.- Specified by:
getSettingSpecifierProviderin interfaceBackupService- Returns:
- provider, or null if not supported
-
getSettingSpecifierProviderForRestore
public net.solarnetwork.settings.SettingSpecifierProvider getSettingSpecifierProviderForRestore()Description copied from interface:BackupServiceGet aSettingSpecifierProviderfor this service, when restoring from an existing backup.- Specified by:
getSettingSpecifierProviderForRestorein interfaceBackupService- Returns:
- provider, or null if not supported
-
getBackupDir
Get the directory to backup to.- Returns:
- the backup directory
-
setBackupDir
Set the directory to backup to.- Parameters:
backupDir- the directory to use
-
getAdditionalBackupCount
public int getAdditionalBackupCount()Get the number of additional backups to maintain.- Returns:
- the additional backup count
-
setAdditionalBackupCount
public void setAdditionalBackupCount(int additionalBackupCount) Set the number of additional backups to maintain.If greater than zero, then this service will maintain this many copies of past backups.
- Parameters:
additionalBackupCount- the additional backup count to use
-
getIdentityService
Get the identity service.- Returns:
- the service
-
setIdentityService
public void setIdentityService(net.solarnetwork.service.OptionalService<IdentityService> identityService) Set the identity service.- Parameters:
identityService- the service to use
-