Package DE_EPAGES::Database::API::BackupMySQL
Functions
- BackupBinLogs
- CheckLogFullArguments
- DataDirDefault
- DeleteOldLogs
- GetBackupCredentials
- GetBinLogFiles
- GetConnectionArgs
- GetConnectionData
- IgnoreDumpsNewerThan
- MyCnfDefault
- RestoreBinLogs
BackupBinLogs
Copies binary log files to backup location; this location is
created in $DumpDir/binlog/
Syntax |
BackupBinLogs($MySQLConfigFile, $LogDirName, $NoOutput, $User, $Password);
|
Example |
BackupBinLogs("/etc/my.cnf", "/tmp");
|
Input |
- $MySQLConfigFile (string)
- location of my.cnf/my.ini
- $DumpDir (string)
- destination where dumps are copied to
- $Verbose (string)
- print messages to stdout
- $User (string)
- Database user or login name (optional)
- $Password (string)
- Database user password (optional)
- $MySqlArgs (string)
- Additional mysql arguments (optional)
|
CheckLogFullArguments
Checks, if all necessary parameters are set and determines the backup
type from them. Returns 1 for full backup or 0 for an incremental one.
Syntax |
$isFullBackup = CheckLogFullArguments( $Full, $Log, $DelLog, $MvOld );
|
Example |
my $isFullBackup = CheckLogFullArguments( $Full, $Log, $DelLog, $MvOld );
|
Input |
- $Full (string)
- value of -full script parameter
- $Log (string)
- value of -log script parameter
- $DelLog (string)
- value of -dellog script parameter
- $MvOld (string)
- value of -mvold script parameter
|
Return |
- $isFullBackup (boolean)
- 1 for full backup or 0 for an incremental one
|
DataDirDefault
Returns the default data directory not reading (my.cnf/my.ini).
Syntax |
my $DataDir = DataDirDefault();
|
Return |
- $DataDir (string)
- MySQL data directory
|
DeleteOldLogs
Deletes binary logfiles which are older than $Days days.
Syntax |
DeleteOldLogs($LogDirName, $Days, $Verbose);
|
Example |
DeleteOldLogs("/tmp", 14, 1);
|
Input |
- $LogDirName (string)
- destination where logfiles were backed up to
- $Days (integer)
- number of days to keep old binlog files
- $Verbose (string)
- print messages to stdout
|
GetBackupCredentials
Returns the user and password for a database from
Database.d/$Store.conf.
Syntax |
($User, $Password, $StoreDBName) = GetBackupCredentials($Storename);
|
Example |
($User, $Password, $StoreDBName) = GetBackupCredentials('Store');
|
Input |
- $Storename (string)
- name of the store to get the credentials from
|
Return |
- $User (string)
- login name
- $Password (string)
- password
- $StoreDBName (string)
- store database name
|
GetBinLogFiles
Returns all binlog files contained in the binlog index file
Syntax |
my $aBinLogFiles = GetBinLogFiles($MySQLConfigFile);
|
Example |
my $aBinLogFiles = GetBinLogFiles("/etc/my.cnf");
|
Input |
- $MySQLConfigFile (string)
- location of my.cnf/my.ini
|
Return |
- $aBinLogFiles (ref.array)
- array whith absolute filenames
|
GetConnectionArgs
Creates the connection arguments and mysql arguments used for native MySQL
script calls based on the passed connection data.
Syntax |
($ConnectionArgs, $MySqlArgs) = GetConnectionArgs( $hConnectionData );
|
Example |
my ($ConnectionArgs, $MySqlArgs) = GetConnectionArgs( $hConnectionData );
|
Input |
- $hConnectionData (hash)
- collected connection data (see GetConnectionData)
|
Return |
- ($ConnectionArgs, $MySqlArgs) (array of two strings)
- connection and mysql arguments
|
GetConnectionData
Returns hash of connection data, which is extracted from the MySQL config
file, the Database.conf file, system defaults and the parameters of this function.
Syntax |
$hConnectionData = GetConnectionData( $StoreName, $MySQLConfigFile, $DumpDir, $Connection );
|
Example |
my $hConnectionData = GetConnectionData( $StoreName, $MySQLConfigFile, $DumpDir, $Connection );
|
Input |
- $StoreName (string)
- name of the store which should be used (optional)
- $MySQLConfigFile (string)
- location of my.cnf/my.ini (optional)
- $DumpDir (string)
- directory where files were backed up to (optional)
- $Connecton (string)
- database connection name (optional)
|
Return |
- $hConnectionData (hash)
- hash with the collected data:
- DumpDir - dump directory
- DBName - database name from the .conf file
- Datasource - databsource string from the .conf file
- User - database user name
- Password - database user password
|
IgnoreDumpsNewerThan
Renames files newer than $DumpDate in $hConnectionData->{DumpDir}
Syntax |
IgnoreDumpsNewerThan($DumpDate, $hConnectionData, $LVM);
|
Example |
IgnoreDumpsNewerThan($DumpDate, $hConnectionData);
|
Input |
- $DumpDate (string)
- date with format YYYYMMDDHHMMSS
- $hConnectionData (hash ref)
- hash as returned by GetConnectionData
- $LVM (string)
- LVM device (VG-LV) (optional)
|
MyCnfDefault
Returns the default MySQL config file name (my.cnf/my.ini)
Syntax |
my $ConfigFileName = MyCnfDefault();
|
Return |
- $ConfigFileName (string)
- MySQL config file name
|
RestoreBinLogs
Restores backed up log files at start position from the directory
$DumpDir/binlog/.
Does nothing if the directory $DumpDir/binlog/ does not exist.
Syntax |
RestoreBinLogs($StartLogFile, $StartPosition, $EndLogFile, $EndPosition,
$DumpDir, $DBName, $User, $Password, $Verbose);
|
Input |
- $StartLogFile (string)
- name of first log file to apply
- $StartPosition (integer)
- number of first log position to apply
- $EndLogFile (string)
- name of last log file to apply (optional)
- $EndPosition (integer)
- number of last log position to apply (optional)
- $DumpDir (string)
- directory where files were backed up to
- $DBName (string)
- database name to restore (empty for all databases)
- $User (string)
- Database user or login name (optional)
- $Password (string)
- Database user password (optional)
- $Verbose (string)
- print messages to stdout
- $MySqlArgs (string)
- Additional mysql arguments (optional)
|