CN117370078A - Database backup management method, device, computer equipment and storage medium - Google Patents

Database backup management method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN117370078A
CN117370078A CN202311424738.6A CN202311424738A CN117370078A CN 117370078 A CN117370078 A CN 117370078A CN 202311424738 A CN202311424738 A CN 202311424738A CN 117370078 A CN117370078 A CN 117370078A
Authority
CN
China
Prior art keywords
database
copy
availability
backup
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311424738.6A
Other languages
Chinese (zh)
Other versions
CN117370078B (en
Inventor
洪清钦
王贤达
马立珂
王子骏
杨海锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Dingjia Computer Technology Co ltd
Original Assignee
Guangzhou Dingjia Computer Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Dingjia Computer Technology Co ltd filed Critical Guangzhou Dingjia Computer Technology Co ltd
Priority to CN202311424738.6A priority Critical patent/CN117370078B/en
Publication of CN117370078A publication Critical patent/CN117370078A/en
Application granted granted Critical
Publication of CN117370078B publication Critical patent/CN117370078B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • G06F11/1451Management of the data involved in backup or backup restore by selection of backup contents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a database backup management method, a database backup management device, computer equipment and a storage medium. The method comprises the following steps: responding to a backup instruction, and determining a target database to be backed up corresponding to the backup instruction; traversing each availability copy corresponding to the database cluster based on the target database, and determining a master copy in each availability copy; the availability copies are identified based on copy identification rules; and backing up the target database in the primary copy based on the primary copy and backup software corresponding to the primary copy. By adopting the method, the backup can be avoided by manually switching the available copies of the backup software, so that the backup efficiency of the database is improved.

Description

Database backup management method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of data backup technologies, and in particular, to a database backup management method, apparatus, computer device, storage medium, and computer program product.
Background
With the development of data storage technology, the availability group can be used as a solution for disaster recovery backup of a database. The availability group contains availability copies and an availability database, each of which may act as a primary copy and backup data via the primary copy. When the primary copy fails, the availability database is transferred to the auxiliary copy, so that the auxiliary copy replaces the primary copy, and the high availability of the database is ensured.
In the related art, a server cluster includes a plurality of availability groups, when a user needs to backup data from the availability groups to a storage space outside the availability groups, if an original primary copy changes during backup of current backup software, only a new primary copy can be determined manually, so that the backup efficiency of the backup software is lower.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a database backup management method, apparatus, computer device, computer readable storage medium, and computer program product.
In a first aspect, the present application provides a database backup management method. The method comprises the following steps:
responding to a backup instruction, and determining a target database to be backed up corresponding to the backup instruction;
traversing each availability copy corresponding to the database cluster based on the target database, and determining a master copy in each availability copy; the availability copies are identified based on copy identification rules;
and backing up the target database in the primary copy based on the primary copy and backup software corresponding to the primary copy.
In one embodiment, the traversing each availability copy corresponding to the database cluster based on the target database, determining a master copy in each availability copy includes:
determining a type value containing the availability copy of the target database for each availability copy corresponding to the database cluster;
determining that the availability copy is a primary copy if the type value is a primary type;
or in the case that the type value is the auxiliary type, determining that the availability copy is an auxiliary copy.
In one embodiment, before the determining, in response to the backup instruction, the target database to be backed up corresponding to the backup instruction, the method further includes:
determining a database list of a database cluster based on each availability copy corresponding to the database cluster, wherein the database list is used for enabling a user terminal to determine a target database to be backed up;
and generating a backup instruction containing the identification information of the target database based on the identification information of the target database.
In one embodiment, the determining the database list of the database cluster based on each availability copy corresponding to the database cluster includes:
generating a service list acquisition statement based on a preset service name prefix and the copy identification rule;
executing the service list acquisition statement through a command line framework to obtain availability copies corresponding to the availability components contained in the database cluster;
determining a database group in which the availability copies are locally stored according to a database group query statement aiming at each availability copy contained in each availability group, and obtaining a database list corresponding to the availability copies according to the database query statement and identifiers respectively corresponding to the database groups;
and obtaining a database list corresponding to the database cluster based on the database list corresponding to each availability copy contained in each availability group.
In one embodiment, before determining the database list of the database cluster based on each availability copy corresponding to the database cluster, the method further includes:
and receiving database login information sent by the user terminal, and sending the database login information to the backup software, wherein the database login information is used for enabling the backup software to log in the availability copy corresponding to the database cluster.
In one embodiment, the method further comprises:
and in response to a deployment instruction, deploying the backup software to each availability copy contained in the database cluster, wherein the backup software is used for backing up the target database.
In a second aspect, the present application further provides a database backup management apparatus. The device comprises:
the database determining module is used for responding to the backup instruction and determining a target database to be backed up corresponding to the backup instruction;
the master copy determining module is used for traversing each availability copy corresponding to the database cluster based on the target database and determining master copies in the availability copies; the availability copies are identified based on copy identification rules;
and the backup module is used for backing up the target database in the primary copy based on the primary copy and backup software corresponding to the primary copy.
In one embodiment, the primary copy determining module is specifically configured to:
determining a type value containing the availability copy of the target database for each availability copy corresponding to the database cluster;
determining that the availability copy is a primary copy if the type value is a primary type;
or in the case that the type value is the auxiliary type, determining that the availability copy is an auxiliary copy.
In one embodiment, the apparatus further includes a backup instruction generation module, specifically configured to:
determining a database list of a database cluster based on each availability copy corresponding to the database cluster, wherein the database list is used for enabling a user terminal to determine a target database to be backed up;
and generating a backup instruction containing the identification information of the target database based on the identification information of the target database.
In one embodiment, the backup instruction generation module is specifically further configured to:
generating a service list acquisition statement based on a preset service name prefix and the copy identification rule;
executing the service list acquisition statement through a command line framework to obtain availability copies corresponding to the availability components contained in the database cluster;
determining a database group in which the availability copies are locally stored according to a database group query statement aiming at each availability copy contained in each availability group, and obtaining a database list corresponding to the availability copies according to the database query statement and identifiers respectively corresponding to the database groups;
and obtaining a database list corresponding to the database cluster based on the database list corresponding to each availability copy contained in each availability group.
In one embodiment, the device further includes a login module, specifically configured to: and receiving database login information sent by the user terminal, and sending the database login information to the backup software, wherein the database login information is used for enabling the backup software to log in the availability copy corresponding to the database cluster.
In one embodiment, the apparatus further comprises a deployment module, specifically configured to: and in response to a deployment instruction, deploying the backup software to each availability copy contained in the database cluster, wherein the backup software is used for backing up the target database.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the method according to the first aspect when the processor executes the computer program.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method according to the first aspect.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprising a computer program which, when executed by a processor, implements the steps of the method according to the first aspect.
The database backup management method, the device, the computer equipment, the storage medium and the computer program product determine the target database to be backed up by responding to the backup instruction, determine the main copy containing the target database in the availability copies corresponding to the database clusters, and finally back up the target database based on backup software on the main copy. The primary copy corresponding to the availability copy is constantly changing due to the failover condition of the availability copy. Based on the above, after determining the target database to be backed up, each available copy containing the target database needs to be traversed, and whether the current available copy is the primary copy is confirmed, if so, the backup can be performed through the primary copy, and the backup is prevented from being performed manually by switching the available copy of the backup software, so that the backup efficiency of the database is improved.
Drawings
FIG. 1 is an application environment diagram of a database backup management method in one embodiment;
FIG. 2 is a flow diagram of a database backup management method in one embodiment;
FIG. 3 is a flow diagram of the primary replica determination step in one embodiment;
FIG. 4 is a flow chart illustrating steps for generating backup instructions in one embodiment;
FIG. 5 is a flow diagram of a process for determining a database listing in one embodiment;
FIG. 6 is a flow chart of a database backup management method according to another embodiment;
FIG. 7 is a block diagram of a database backup management apparatus in one embodiment;
fig. 8 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The database backup management method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. The user terminal 102 communicates with the server 104 through a network, the user terminal 102 is configured to receive data information about the database cluster 106 sent by the server, and the user terminal 102 may send a user operation to the server 104 in response to the user operation, so that the server 104 generates an operation instruction and performs data backup on the database cluster 106 based on the operation instruction. The data storage system may store the data to be backed up determined by the server 104, and backup the corresponding data to be backed up in the database cluster 106 to the data storage system. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The user terminal 102 may be, but not limited to, various personal computers, notebook computers, smartphones, and tablet computers, and the server 104 may be implemented as a stand-alone server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, a database backup management method is provided, and the method is applied to the server 104 in fig. 1 for illustration, and includes the following steps:
step S202, in response to the backup instruction, determining a target database to be backed up corresponding to the backup instruction.
The backup instruction is used for enabling the backup software to copy the target database to be backed up, and storing copied contents to a preset storage medium. The target databases to be backed up are databases selected by the user terminal and needed to be backed up.
Specifically, the server may determine the target database to be backed up according to the selection operation of the user terminal on the target database, and encapsulate the identification information of the target database to obtain the backup instruction. The server may parse the pre-generated backup instruction, obtain the identification information of the target database to be backed up in the backup instruction, and determine a storage medium storing the data of the target database.
Step S204, traversing each availability copy corresponding to the database cluster based on the target database, and determining a master copy in each availability copy.
The availability copies are identified based on copy identification rules, which can identify the various copies contained in the database cluster. The availability copy comprises a main copy and an auxiliary copy, wherein the main copy is a copy capable of reading and writing data, and the server can realize the backup of the target database corresponding to the main copy through the reading and writing operation on the data of the target database; the auxiliary copy is a copy that can only be read of data. The data cluster may comprise a plurality of servers, each comprising at least one availability group, each availability group comprising a plurality of availability copies.
Specifically, the server traverses each available copy included in the database cluster according to a preset traversing order of the database cluster, determines an available copy including a target database, and in the case that the current available copy is determined to include the target database, the server can determine a copy type of the current available copy, where the copy type includes a primary copy type and an auxiliary copy type; if the current availability copy is an auxiliary copy, continuing to traverse the database cluster according to a preset traversing order of the database cluster until a main copy corresponding to the target database is determined.
Step S206, backing up the target database in the primary copy based on the primary copy and the backup software corresponding to the primary copy.
The backup software corresponding to the primary copy is the backup software deployed on each available copy, and when the data on a certain primary copy needs to be backed up, the server can call the backup software corresponding to the primary copy for backup.
Specifically, the server sends a backup instruction to the backup software corresponding to the primary copy, and the backup software can backup the target database in the primary copy to the storage medium corresponding to the backup instruction based on the received backup instruction.
In one example, the server may parse the backup instruction, determine a target database and a backup storage location included in the backup instruction, and the backup software obtains data of the target database based on the read-write operation, and copies the data to the backup storage location.
According to the database backup management method, the target database to be backed up is determined by responding to the backup instruction, the main copy containing the target database is determined in the available copies corresponding to the database clusters, and finally the target database is backed up based on backup software on the main copy. The primary copy corresponding to the availability copy is constantly changing due to the failover condition of the availability copy. Based on the above, after determining the target database to be backed up, each available copy containing the target database needs to be traversed, and whether the current available copy is the primary copy is confirmed, if so, the backup can be performed through the primary copy, and the backup is prevented from being performed manually by switching the available copy of the backup software, so that the backup efficiency of the database is improved.
In one embodiment, as shown in fig. 3, the step of traversing each availability copy corresponding to a database cluster based on a target database, determining a specific implementation of a master copy in each availability copy includes:
step S302, determining a type value containing the availability copy of the target database for each availability copy corresponding to the database cluster.
The type value of the availability copy may be type identification information of the availability copy, where the type identification information may indicate that the availability copy is a primary copy type, or may indicate that the availability copy is a secondary copy type.
Specifically, the server traverses each availability copy contained in the database cluster according to a preset traversing order of the database cluster, and determines whether the current availability copy contains the target database by querying identification information of the target database aiming at each availability copy contained in the database cluster. Under the condition that the current availability copy comprises the target database, the type value of the current availability copy can be inquired and obtained through SQL inquiry sentences and identifiers of the database groups corresponding to the availability copy, so that the type values of all the availability copies in the database cluster are obtained. The database group is a plurality of database groups contained in the current availability copy, each database group can contain a plurality of databases, the identifier of the database group is a unique identifier which can be universal in the plurality of availability copies, and the server can find the unique database group in the database cluster based on the identifier.
Step S304, in the case that the type value is the main type, determining that the availability copy is the main copy.
In step S306, in the case that the type value is the auxiliary type, the availability copy is determined to be the auxiliary copy.
The type value may include a primary type for indicating that the availability copy is a primary copy and a secondary type for indicating that the availability copy is a secondary copy.
Specifically, if the server determines that the type value of the current availability copy is the main type, determining that the availability copy is the main copy; and if the server determines that the type value of the current availability copy is the auxiliary type, determining that the availability copy is the auxiliary copy. The server may determine the type of each availability copy separately by traversing each availability copy corresponding to the database cluster.
In one example, in the case of traversing each availability copy contained in the database cluster according to a preset traversal order of the database cluster, the server may obtain the type value of the current availability copy by using the type value query statement and defining the type value query statement by using the identifier of the database group corresponding to the current availability copy.
In this embodiment, the type value of the availability copy including the target database is obtained through a traversal manner, and whether the availability copy is the primary copy or the auxiliary copy is determined, so that the primary copy including the target database can be automatically determined, and the efficiency of determining the primary copy is improved.
In one embodiment, as shown in fig. 4, before step "determining, in response to a backup instruction, a target database to be backed up corresponding to the backup instruction", the database backup management method further includes:
step S402, determining a database list of the database cluster based on each availability copy corresponding to the database cluster.
The database list is used for enabling the user terminal to determine a target database to be backed up. The database cluster comprises a plurality of availability groups, the availability groups comprise a plurality of availability copies, the availability copies comprise a plurality of database groups, and the database groups comprise a database list formed by a plurality of databases.
Specifically, the server may traverse the database cluster according to a preset traversal order of the database cluster, obtain each availability copy of the plurality of availability groups in the database cluster, determine, for each availability copy, a database group of each availability copy, and obtain a plurality of databases included in each database group. And the server merges the databases to obtain a database list corresponding to each database group. And the server obtains the database list of the database cluster by merging the database lists of each database group to obtain the database list of the plurality of availability copies.
Step S404, based on the identification information of the target database, generating a backup instruction containing the identification information of the target database.
Wherein the identification information of the target database represents a unique identifier of the target database.
Specifically, after determining a target database to be backed up based on a database list of a database cluster, the server acquires identification information of the target database, takes the identification information of the target database as a unique identifier representing the target database, and encapsulates the identification information of the target database to obtain a backup instruction. The server can analyze the backup instruction, obtain the identification information of the target database to be backed up in the backup instruction, and store the storage medium of the data of the target database, so that the backup instruction only backs up the target database.
In this embodiment, the target database to be backed up is obtained by determining all database lists of the database cluster and screening the user. And then the identification information of the target data is packaged into a backup instruction, so that the backup software can automatically backup the target database dynamically determined by a user, thereby improving the flexibility of backup.
In one embodiment, as shown in fig. 5, the specific implementation of the step of determining the database list of the database cluster based on each availability copy corresponding to the database cluster includes:
step S502, a service list acquisition statement is generated based on a preset service name prefix and a copy identification rule.
Wherein the service name prefix is used to match the duplicate name of the availability duplicate. The replica identification rule is used to generate a replica name for an availability replica contained by the database cluster.
Specifically, the server takes the service name prefix as a field to be matched, and merges the service name prefix into a copy identification rule to obtain a service list acquisition statement capable of inquiring the copy name.
In one example, MSSQL $can be used as a service name prefix, which is added to the duplicate recognition rule to obtain a service list acquisition statement. For example, the service list acquisition statement is as follows:
Get-Service | Select Name | findstr.exe /I MSSQL\$。
step S504, executing the service list acquisition statement through the command line framework to obtain availability copies corresponding to the availability components contained in the database cluster.
The command line framework is used for executing various command line sentences, the command line can be a service list acquisition sentence, and the command line framework can be PowerShell, python, perl and other languages.
Specifically, the server executes a service list acquisition statement on the command line framework to obtain the copy names of the availability copies corresponding to the availability components in the database cluster, thereby obtaining all the availability copies.
In one example, if the database cluster contains an availability copy with a copy name REPL1, the output of the command line framework may be: MSSQL $REPL1. Where mssql$ is the service name prefix and REPL1 is the copy name of the availability copy, which is one example of this disclosure, in an actual production environment, the copy name may be determined as needed by those skilled in the art.
Step S506, for each availability copy contained in each availability group, determining the database group in which the availability copy is locally stored through the database group query statement, and obtaining a database list corresponding to the availability copy through the database query statement and identifiers respectively corresponding to the database groups.
Specifically, the server traverses each availability copy contained in each availability group, inputs a database group query statement to the command line framework for each availability copy contained in each availability group, and sets up a database group in which the query availability copy is locally stored, resulting in a database group contained in the availability copy. Based on this, the server inputs a database query statement containing identifiers of the database groups to the command line frame, resulting in a database list corresponding to each database group. After the traversal is completed, a database list corresponding to a plurality of database groups in each availability copy can be obtained.
In one example, the server inputs a database group query statement into the command line framework and adds a definition of the query local store in the database group query statement, e.g., the database group query statement is as follows:
where group_name is the name of the database group, group_id is an identifier of the database group, is_local indicates a storage location of the database group, and if is_local=1 indicates that the storage location of the database group is local.
Step S508, based on the database list corresponding to each availability copy contained in each availability group, obtaining a database list corresponding to the database cluster.
Specifically, according to the database list corresponding to each availability copy contained in each availability group, the database lists are arranged according to the traversal sequence, and the database list corresponding to the database cluster is obtained. And displaying the database list on the user terminal so that the user can select the database list to be backed up from the database lists.
In one example, the server inputs a database query statement into the command line framework, e.g., the database query statement is as follows:
where group_id is the identifier of the database group.
In this embodiment, the server may automatically identify and query all database lists included in the database cluster through the command line frame and the command line statement, so that the user terminal may automatically obtain all database lists, and efficiency of the user terminal in obtaining the database lists is improved.
In one embodiment, before the step of determining the database list of the database cluster based on each availability copy corresponding to the database cluster, the database backup management method further includes:
and receiving the database login information sent by the user terminal, and sending the database login information to the backup software.
The database login information is used for enabling the backup software to log in the availability copy corresponding to the database cluster, and the login information can comprise information such as a database name, a database address, a database password and the like.
Specifically, the user terminal sends the database login information to the server, and after receiving the database login information, the server sends the database login information to each piece of backup software, so that each piece of backup software uses the database login information to login the corresponding availability copy, and thus the query authority and the copy authority of the database list for querying the availability copy are obtained.
In this embodiment, by sending the database login information to the backup software, the backup software can automatically log in the availability copy, thereby achieving the effect of improving the speed of querying and backing up the availability copy.
In one embodiment, the database backup management method further includes: in response to the deployment instruction, the backup software is deployed to each availability copy contained in the database cluster.
The backup software is used for backing up the target database. The deployment instruction contains software information of the backup software and an availability copy of the backup software needs to be deployed.
Specifically, before performing the backup operation, the server generates a deployment instruction based on the software information of the backup software and the availability copy of the backup software to be deployed. The server sends the deployment instruction to each server corresponding to the database cluster, so that the server of the database cluster deploys backup software based on the deployment instruction.
In this embodiment, the backup software is installed for each availability copy through the deployment instruction, so that when any availability copy fails, the backup software can still operate normally, and the backup stability is improved.
As shown in fig. 6, a specific implementation procedure of the database backup management method is described in detail below in connection with a specific embodiment.
First, the server deploys the backup software to all MS SQL servers and obtains the availability copy list containing REPL0 and REPL1 through PowerShell. The server logs the backup software into REPL0 and REPL1 through the database login information. And acquiring database groups corresponding to the REPL0 availability copy and the REPL1 availability copy respectively through the SQL command line. The user can select the database group to be backed up based on the database group, the server can display a plurality of databases in the database group to the user through the user terminal after the selection, and the user selects the database to be backed up through the user terminal. And finally, after the server determines the database to be backed up, determining whether the availability copy corresponding to the database is a master copy, and if so, backing up the database through backup software corresponding to the master copy.
In one example, one availability group includes one primary copy, one secondary copy, and a total of two availability copies, named REPL1 and REPL2, respectively. Wherein REPL1 is a primary copy, REPL2 is an auxiliary copy, and backup is only performed in the primary copy. Two sets of availability databases AG1, AG2 are hosted on the two availability copies, and AG1 includes databases DB1, DB2, AG2 includes databases DB3, DB4.
Step 1: in order to identify the availability copy, the server serves the directory through the PowerShell list during the backup software installation phase, and identifies its landmark prefix mssql$:
Get-Service | Select Name | findstr.exe /I MSSQL\$
REPL1 copy output is exemplified as follows:
MSSQL$ REPL1
MSSQL$ in output is the MSSQL service name marker prefix, REPL1 is the copy name in the example, and in the actual production environment, the copy name is usually irregular and circulated.
Step 2: after the backup software user provides MS SQL login credentials, the backup software logs in MS SQL, queries and identifies all database groups in the database cluster by SQL query statements, where a filter condition ars.is_local=1 is necessary, which specifies that the query only lists the availability groups local to the replica:
the server selects and displays two fields, namely a group_name and a group_id, from sys.availability_groups_cluster agc, and selects and displays data with the value of is_local being 1.
Examples of outputs of availability groups corresponding to REPL1 copies are shown in Table 1:
TABLE 1
Examples of outputs of the availability group corresponding to the REPL2 copy are shown in Table 2:
TABLE 2
All availability groups can be listed through the group_name column; the group_id is used to uniquely identify a database group, and the group_id remains consistent among the copies.
Step 3: all databases specifying the availability group are listed for the user, the SQL query statement is as follows, and its filter condition { group_id } can be obtained by the SQL query statement in step 2:
the server selects and displays a database_name field from sys.availability_databases_cluster, and determines data to be displayed according to a specific value of the group_id.
Databases within all available groups can be listed by the query statement.
An example of AG1 output on REPL1 is shown in table 3:
TABLE 3 Table 3
An example of AG2 output on REPL1 is shown in table 4:
TABLE 4 Table 4
Step 4: in order to ensure that the backup software can still normally operate when any one of the available copies fails, the backup software needs to be deployed on each available copy. Because of the unpredictability of the failure, the backup software checks whether the current copy is the primary copy before each backup, and queries as follows by SQL:
the server queries and displays the role_desc field from sys.dm_hadr_availability_reply_states, and only displays the data with the is_local of 1, and the group_id is an identifier of the database group to be queried, and may determine a value according to needs, for example, the group_id may be 0001.
Copy output of AG1 on REPL1 is shown in Table 5, for example:
TABLE 5
Copy output of AG2 on REPL2 is shown in table 6, for example:
TABLE 6
The PRIMARY copy (PRIMARY) of AG1 is REPL1, while the SECONDARY copy (SECONDARY) is REPL2 as known by the role_desc column. On the primary copy, the backup is performed normally, and the secondary copy needs to skip the backup.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a database backup management device for realizing the above related database backup management method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the database backup management device or devices provided below may refer to the limitation of the database backup management method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 7, there is provided a database backup management apparatus 700 comprising: a database determination module 701, a primary copy determination module 702, and a backup module 703, wherein:
the database determining module 701 is configured to determine a target database to be backed up corresponding to the backup instruction in response to the backup instruction;
the master copy determining module 702 is configured to traverse each availability copy corresponding to the database cluster based on the target database, and determine a master copy in each availability copy; the availability copies are identified based on copy identification rules;
and the backup module 703 is configured to backup the target database in the primary copy based on the primary copy and backup software corresponding to the primary copy.
Further, the primary copy determining module 702 is specifically configured to:
determining a type value containing the availability copy of the target database for each availability copy corresponding to the database cluster;
in the case that the type value is the primary type, determining that the availability copy is the primary copy;
alternatively, in the case where the type value is a secondary type, the availability copy is determined to be a secondary copy.
Further, the device further comprises a backup instruction generation module, which is specifically configured to:
determining a database list of the database cluster based on each availability copy corresponding to the database cluster, wherein the database list is used for enabling the user terminal to determine a target database to be backed up;
based on the identification information of the target database, a backup instruction containing the identification information of the target database is generated.
Further, the backup instruction generation module is specifically further configured to:
generating a service list acquisition statement based on a preset service name prefix and a copy identification rule;
executing a service list acquisition statement through a command line framework to obtain availability copies corresponding to each availability component contained in the database cluster;
determining a database group in which the availability copies are locally stored according to the database group query statement aiming at each availability copy contained in each availability group, and obtaining a database list corresponding to the availability copies according to the database query statement and identifiers respectively corresponding to the databases;
and obtaining a database list corresponding to the database cluster based on the database list corresponding to each availability copy contained in each availability group.
Further, the device also comprises a login module, which is specifically used for: and receiving database login information sent by the user terminal, and sending the database login information to the backup software, wherein the database login information is used for enabling the backup software to log in the availability copy corresponding to the database cluster.
Further, the device further comprises a deployment module, specifically configured to: and in response to the deployment instruction, deploying backup software to each availability copy contained in the database cluster, wherein the backup software is used for backing up the target database.
The modules in the database backup management apparatus may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 8. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing data of a target database to be backed up. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a database backup management method.
It will be appreciated by those skilled in the art that the structure shown in fig. 8 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. A database backup management method, the method comprising:
responding to a backup instruction, and determining a target database to be backed up corresponding to the backup instruction;
traversing each availability copy corresponding to the database cluster based on the target database, and determining a master copy in each availability copy; the availability copies are identified based on copy identification rules;
and backing up the target database in the primary copy based on the primary copy and backup software corresponding to the primary copy.
2. The method of claim 1, wherein traversing each availability copy for a database cluster based on the target database, determining a master copy in each availability copy comprises:
determining a type value containing the availability copy of the target database for each availability copy corresponding to the database cluster;
determining that the availability copy is a primary copy if the type value is a primary type;
or in the case that the type value is the auxiliary type, determining that the availability copy is an auxiliary copy.
3. The method of claim 1, wherein before determining, in response to a backup instruction, a target database to be backed up corresponding to the backup instruction, the method further comprises:
determining a database list of a database cluster based on each availability copy corresponding to the database cluster, wherein the database list is used for enabling a user terminal to determine a target database to be backed up;
and generating a backup instruction containing the identification information of the target database based on the identification information of the target database.
4. A method according to claim 3, wherein said determining a database list for a database cluster based on respective availability copies for said database cluster comprises:
generating a service list acquisition statement based on a preset service name prefix and the copy identification rule;
executing the service list acquisition statement through a command line framework to obtain availability copies corresponding to the availability components contained in the database cluster;
determining a database group in which the availability copies are locally stored according to a database group query statement aiming at each availability copy contained in each availability group, and obtaining a database list corresponding to the availability copies according to the database query statement and identifiers respectively corresponding to the database groups;
and obtaining a database list corresponding to the database cluster based on the database list corresponding to each availability copy contained in each availability group.
5. A method according to claim 3, wherein before determining the database list of the database cluster based on the respective availability copies for the database cluster, the method further comprises:
and receiving database login information sent by the user terminal, and sending the database login information to the backup software, wherein the database login information is used for enabling the backup software to log in the availability copy corresponding to the database cluster.
6. The method according to claim 1, wherein the method further comprises:
and in response to a deployment instruction, deploying the backup software to each availability copy contained in the database cluster, wherein the backup software is used for backing up the target database.
7. A database backup management apparatus, the apparatus comprising:
the database determining module is used for responding to the backup instruction and determining a target database to be backed up corresponding to the backup instruction;
the master copy determining module is used for traversing each availability copy corresponding to the database cluster based on the target database and determining master copies in the availability copies; the availability copies are identified based on copy identification rules;
and the backup module is used for backing up the target database in the primary copy based on the primary copy and backup software corresponding to the primary copy.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202311424738.6A 2023-10-31 2023-10-31 Database backup management method, device, computer equipment and storage medium Active CN117370078B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311424738.6A CN117370078B (en) 2023-10-31 2023-10-31 Database backup management method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311424738.6A CN117370078B (en) 2023-10-31 2023-10-31 Database backup management method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117370078A true CN117370078A (en) 2024-01-09
CN117370078B CN117370078B (en) 2024-05-28

Family

ID=89407542

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311424738.6A Active CN117370078B (en) 2023-10-31 2023-10-31 Database backup management method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117370078B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9934107B1 (en) * 2015-03-30 2018-04-03 EMC IP Holding Company LLC Designating backup nodes and backing up in parallel in a high-availability environment
CN109408280A (en) * 2017-08-17 2019-03-01 北京金山云网络技术有限公司 Data back up method, apparatus and system
US10235250B1 (en) * 2014-06-27 2019-03-19 EMC IP Holding Company LLC Identifying preferred nodes for backing up availability groups
CN109871295A (en) * 2017-12-01 2019-06-11 北京金山云网络技术有限公司 A kind of data back up method, back-up device, electronic equipment and storage medium
US10719407B1 (en) * 2017-06-05 2020-07-21 EMC IP Holding Company LLC Backing up availability group databases configured on multi-node virtual servers
CN111813760A (en) * 2020-05-29 2020-10-23 阿里巴巴集团控股有限公司 Data migration method and device
CN113064760A (en) * 2021-04-06 2021-07-02 广州鼎甲计算机科技有限公司 Database synthesis backup method and device, computer equipment and storage medium
CN113254536A (en) * 2021-06-09 2021-08-13 蚂蚁金服(杭州)网络技术有限公司 Database transaction processing method, system, electronic device and storage medium
CN115098229A (en) * 2022-04-25 2022-09-23 深圳市腾讯计算机系统有限公司 Transaction processing method, device, node equipment and storage medium
CN115495130A (en) * 2022-10-13 2022-12-20 中电云数智科技有限公司 Updating strategy method for improving service availability in kubernets
CN116680256A (en) * 2023-07-21 2023-09-01 腾讯科技(深圳)有限公司 Database node upgrading method and device and computer equipment
CN116954863A (en) * 2023-07-28 2023-10-27 中国联合网络通信集团有限公司 Database scheduling method, device, equipment and storage medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10235250B1 (en) * 2014-06-27 2019-03-19 EMC IP Holding Company LLC Identifying preferred nodes for backing up availability groups
US9934107B1 (en) * 2015-03-30 2018-04-03 EMC IP Holding Company LLC Designating backup nodes and backing up in parallel in a high-availability environment
US10719407B1 (en) * 2017-06-05 2020-07-21 EMC IP Holding Company LLC Backing up availability group databases configured on multi-node virtual servers
CN109408280A (en) * 2017-08-17 2019-03-01 北京金山云网络技术有限公司 Data back up method, apparatus and system
CN109871295A (en) * 2017-12-01 2019-06-11 北京金山云网络技术有限公司 A kind of data back up method, back-up device, electronic equipment and storage medium
CN111813760A (en) * 2020-05-29 2020-10-23 阿里巴巴集团控股有限公司 Data migration method and device
CN113064760A (en) * 2021-04-06 2021-07-02 广州鼎甲计算机科技有限公司 Database synthesis backup method and device, computer equipment and storage medium
CN113254536A (en) * 2021-06-09 2021-08-13 蚂蚁金服(杭州)网络技术有限公司 Database transaction processing method, system, electronic device and storage medium
CN115098229A (en) * 2022-04-25 2022-09-23 深圳市腾讯计算机系统有限公司 Transaction processing method, device, node equipment and storage medium
CN115495130A (en) * 2022-10-13 2022-12-20 中电云数智科技有限公司 Updating strategy method for improving service availability in kubernets
CN116680256A (en) * 2023-07-21 2023-09-01 腾讯科技(深圳)有限公司 Database node upgrading method and device and computer equipment
CN116954863A (en) * 2023-07-28 2023-10-27 中国联合网络通信集团有限公司 Database scheduling method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN117370078B (en) 2024-05-28

Similar Documents

Publication Publication Date Title
US10496668B1 (en) Optimized tender processing of hash-based replicated data
US10114580B1 (en) Data backup management on distributed storage systems
US11880284B2 (en) Storage restore system, storage restore method, and storage medium
CN102142032A (en) Method and system for reading and writing data of distributed file system
JP2015528957A (en) Distributed file system, file access method, and client device
CN106776795B (en) Data writing method and device based on Hbase database
CN109325026B (en) Data processing method, device, equipment and medium based on big data platform
CN114238495A (en) Method and device for switching main cluster and standby cluster of database, computer equipment and storage medium
CN111488124A (en) Data updating method and device, electronic equipment and storage medium
CN112860412B (en) Service data processing method and device, electronic equipment and storage medium
CN117370078B (en) Database backup management method, device, computer equipment and storage medium
CN116303789A (en) Parallel synchronization method and device for multi-fragment multi-copy database and readable medium
CN114756293A (en) Service processing method, device, computer equipment and storage medium
CN115730016B (en) Data synchronization method, system, device, computer equipment and storage medium
CN117539690B (en) Method, device, equipment, medium and product for merging and recovering multi-disk data
CN114036171B (en) Application data management method, device, computer equipment and storage medium
CN117555679A (en) Service data processing method, device, computer equipment and storage medium
CN116257531B (en) Database space recovery method
CN118152185A (en) Method, system, device, computer equipment and medium for recovering backup of fragmented clusters
CN116880927A (en) Rule management method, device, computer equipment and storage medium
CN113553329A (en) Data integration system and method
CN117130704A (en) Page generation method, page generation device, computer equipment and storage medium
CN117632009A (en) Data storage method and device based on business application and computer equipment
CN116483532A (en) Scheduling processing method, device, computer equipment and storage medium
CN117075951A (en) Program maintenance method, program maintenance device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant