Class FBNBackupManager
- java.lang.Object
-
- org.firebirdsql.management.FBServiceManager
-
- org.firebirdsql.management.FBNBackupManager
-
- All Implemented Interfaces:
AttachmentProperties
,BaseProperties
,ServiceConnectionProperties
,NBackupManager
,ServiceManager
public class FBNBackupManager extends FBServiceManager implements NBackupManager
Implements the incremental backup and restore functionality of NBackup via the Firebird Services API.- Author:
- Thomas Steinmaurer, Mark Rotteveel
-
-
Field Summary
-
Fields inherited from class org.firebirdsql.management.FBServiceManager
BUFFER_SIZE
-
-
Constructor Summary
Constructors Constructor Description FBNBackupManager()
Create a new instance ofFBNBackupManager
based on the default GDSType.FBNBackupManager(java.lang.String gdsType)
Create a new instance ofFBNBackupManager
based on a given GDSType name.FBNBackupManager(GDSType gdsType)
Create a new instance ofFBNBackupManager
based on a given GDSType.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBackupFile(java.lang.String backupFile)
Add additional backup files.void
backupDatabase()
Perform the backup operation.void
clearBackupFiles()
Clear the information about backup files.void
fixupDatabase()
Perform the nbackup fixup operation.void
restoreDatabase()
Perform the restore operation.void
setBackupFile(java.lang.String backupFile)
Sets the location of the backup file.void
setBackupGuid(java.lang.String guid)
Sets the backup GUID (Firebird 4 and higher only).void
setBackupLevel(int backupLevel)
Sets the backup level (0 = full, 1..n = incremental)void
setCleanHistory(boolean cleanHistory)
Enables clean history on backup.void
setInPlaceRestore(boolean inPlaceRestore)
Enables in-place restore.void
setKeepDays(int days)
Sets the number of days of backup history to keep.void
setKeepRows(int rows)
Sets the number of rows of backup history to keep (this includes the row created by the backup).void
setNoDBTriggers(boolean noDBTriggers)
Sets the option no database triggers when connecting at backup or in-place restore.void
setPreserveSequence(boolean preserveSequence)
Enables preserve sequence (for fixup or restore).-
Methods inherited from class org.firebirdsql.management.FBServiceManager
attachDatabase, attachServiceManager, connectionPropertyValues, createRequestBuffer, executeServicesOperation, executeServicesOperation, getAuthPlugins, getBooleanProperty, getCharSet, getDatabase, getDbCryptConfig, getExpectedDb, getHost, getIntProperty, getLogger, getPassword, getPort, getPortNumber, getProperty, getServerName, getServerVersion, getServiceName, getUser, getWireCrypt, getWireCryptAsEnum, isWireCompression, queueService, setAuthPlugins, setBooleanProperty, setCharSet, setDatabase, setDbCryptConfig, setExpectedDb, setHost, setIntProperty, setLogger, setPassword, setPort, setPortNumber, setProperty, setServerName, setServiceName, setType, setUser, setWireCompression, setWireCryptAsEnum
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentProperties
getAuthPlugins, getCharSet, getConnectTimeout, getDbCryptConfig, getEncoding, getParallelWorkers, getPassword, getPortNumber, getProcessId, getProcessName, getRoleName, getServerName, getSocketBufferSize, getSoTimeout, getType, getUser, getWireCrypt, isWireCompression, setAuthPlugins, setCharSet, setConnectTimeout, setDbCryptConfig, setEncoding, setParallelWorkers, setPassword, setPortNumber, setProcessId, setProcessName, setRoleName, setServerName, setSocketBufferSize, setSoTimeout, setType, setUser, setWireCompression, setWireCrypt
-
Methods inherited from interface org.firebirdsql.jaybird.props.BaseProperties
connectionPropertyValues, getBooleanProperty, getBooleanProperty, getIntProperty, getIntProperty, getProperty, getProperty, setBooleanProperty, setIntProperty, setProperty
-
Methods inherited from interface org.firebirdsql.management.NBackupManager
setDatabase
-
Methods inherited from interface org.firebirdsql.jaybird.props.ServiceConnectionProperties
getExpectedDb, getServiceName, setExpectedDb, setServiceName
-
Methods inherited from interface org.firebirdsql.management.ServiceManager
getDatabase, getHost, getLogger, getPort, getServerVersion, getWireCryptAsEnum, setHost, setLogger, setPort, setWireCryptAsEnum
-
-
-
-
Constructor Detail
-
FBNBackupManager
public FBNBackupManager()
Create a new instance ofFBNBackupManager
based on the default GDSType.
-
FBNBackupManager
public FBNBackupManager(java.lang.String gdsType)
Create a new instance ofFBNBackupManager
based on a given GDSType name.- Parameters:
gdsType
- type must be PURE_JAVA, EMBEDDED, or NATIVE
-
FBNBackupManager
public FBNBackupManager(GDSType gdsType)
Create a new instance ofFBNBackupManager
based on a given GDSType.- Parameters:
gdsType
- type must be PURE_JAVA, EMBEDDED, or NATIVE
-
-
Method Detail
-
setBackupFile
public void setBackupFile(java.lang.String backupFile)
Description copied from interface:NBackupManager
Sets the location of the backup file.Warning: this method behaves identical to
NBackupManager.addBackupFile(String)
.- Specified by:
setBackupFile
in interfaceNBackupManager
- Parameters:
backupFile
- the location of the backup file.
-
addBackupFile
public void addBackupFile(java.lang.String backupFile)
Description copied from interface:NBackupManager
Add additional backup files.Specifying multiple backup files is only valid for restore, for backup only the first file is used.
Use
NBackupManager.clearBackupFiles()
to clear earlier backup files.- Specified by:
addBackupFile
in interfaceNBackupManager
- Parameters:
backupFile
- the location of the backup file.
-
clearBackupFiles
public void clearBackupFiles()
Description copied from interface:NBackupManager
Clear the information about backup files. This method undoes all parameters set in theNBackupManager.addBackupFile(String)
method.- Specified by:
clearBackupFiles
in interfaceNBackupManager
-
backupDatabase
public void backupDatabase() throws java.sql.SQLException
Description copied from interface:NBackupManager
Perform the backup operation.- Specified by:
backupDatabase
in interfaceNBackupManager
- Throws:
java.sql.SQLException
- if a database error occurs during the backup
-
restoreDatabase
public void restoreDatabase() throws java.sql.SQLException
Description copied from interface:NBackupManager
Perform the restore operation.Set
NBackupManager.setPreserveSequence(boolean)
to preserve the original database GUID and replication sequence.- Specified by:
restoreDatabase
in interfaceNBackupManager
- Throws:
java.sql.SQLException
- if a database error occurs during the restore- See Also:
NBackupManager.restoreDatabase()
-
fixupDatabase
public void fixupDatabase() throws java.sql.SQLException
Description copied from interface:NBackupManager
Perform the nbackup fixup operation.A fixup will switch a locked database to 'normal' state without merging the delta, so this is a potentially destructive action. The normal use-case of this option is to unlock a copy of a database file where the source database file was locked with
nbackup -L
orALTER DATABASE BEGIN BACKUP
.Set
NBackupManager.setPreserveSequence(boolean)
to preserve the original database GUID and replication sequence.- Specified by:
fixupDatabase
in interfaceNBackupManager
- Throws:
java.sql.SQLException
- if a database error occurs during the fixup
-
setBackupLevel
public void setBackupLevel(int backupLevel)
Description copied from interface:NBackupManager
Sets the backup level (0 = full, 1..n = incremental)- Specified by:
setBackupLevel
in interfaceNBackupManager
- Parameters:
backupLevel
- backup level (e.g. 0 = full backup, 1 = level 1 incremental backup based on level 0 backup
-
setBackupGuid
public void setBackupGuid(java.lang.String guid)
Description copied from interface:NBackupManager
Sets the backup GUID (Firebird 4 and higher only).The backup GUID is the GUID of a previous backup of the (source) database. This is used by Firebird to backup the pages modified since that backup.
This setting is mutually exclusive with
NBackupManager.setBackupLevel(int)
, but this is only checked server-side.- Specified by:
setBackupGuid
in interfaceNBackupManager
- Parameters:
guid
- A GUID string of a previous backup, enclosed in braces.
-
setNoDBTriggers
public void setNoDBTriggers(boolean noDBTriggers)
Description copied from interface:NBackupManager
Sets the option no database triggers when connecting at backup or in-place restore.- Specified by:
setNoDBTriggers
in interfaceNBackupManager
- Parameters:
noDBTriggers
-true
disable db triggers during backup or in-place restore.
-
setInPlaceRestore
public void setInPlaceRestore(boolean inPlaceRestore)
Description copied from interface:NBackupManager
Enables in-place restore.- Specified by:
setInPlaceRestore
in interfaceNBackupManager
- Parameters:
inPlaceRestore
-true
to enable in-place restore
-
setPreserveSequence
public void setPreserveSequence(boolean preserveSequence)
Description copied from interface:NBackupManager
Enables preserve sequence (for fixup or restore).This preserves the existing GUID and replication sequence of the original database (they are reset otherwise).
- Specified by:
setPreserveSequence
in interfaceNBackupManager
- Parameters:
preserveSequence
-true
to enable preserve sequence
-
setCleanHistory
public void setCleanHistory(boolean cleanHistory)
Description copied from interface:NBackupManager
Enables clean history on backup.The backup will fail if
NBackupManager.setKeepDays(int)
orNBackupManager.setKeepRows(int)
has not been called.- Specified by:
setCleanHistory
in interfaceNBackupManager
- Parameters:
cleanHistory
-true
to enable clean history
-
setKeepDays
public void setKeepDays(int days)
Description copied from interface:NBackupManager
Sets the number of days of backup history to keep.Server-side, this option is mutually exclusive with
NBackupManager.setKeepRows(int)
, this is not enforced by the Java code.This option only has effect when
setCleanHistory(true)
has been called.- Specified by:
setKeepDays
in interfaceNBackupManager
- Parameters:
days
- number of days to keep history when cleaning, or-1
to clear current value- See Also:
NBackupManager.setCleanHistory(boolean)
,NBackupManager.setKeepRows(int)
-
setKeepRows
public void setKeepRows(int rows)
Description copied from interface:NBackupManager
Sets the number of rows of backup history to keep (this includes the row created by the backup).Server-side, this option is mutually exclusive with
NBackupManager.setKeepDays(int)
, this is not enforced by the Java code.This option only has effect when
setCleanHistory(true)
has been called.- Specified by:
setKeepRows
in interfaceNBackupManager
- Parameters:
rows
- number of rows to keep history when cleaning, or-1
to clear current value- See Also:
NBackupManager.setCleanHistory(boolean)
,NBackupManager.setKeepDays(int)
-
-