Database file backup and recovery method and file backup and recovery device

By using backup nodes to connect to shared areas in database backup for data backup, the problems of database backup synchronization and waste of storage space are solved, real-time backup and efficient recovery of data are realized, and data security and reliability are ensured.

CN119166418AActive Publication Date: 2024-12-20GUANGDONG YUEDIAN INFORMATION TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411207472.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-20
Estimated Expiration
2044-08-30

AI Technical Summary

Technical Problem

Existing database backup technology cannot guarantee the synchronization of backups when switching primary and backup nodes, and the primary and backup nodes require independent storage space, which leads to waste of storage and data recovery time-consuming and labor-intensive, and may cause data when the primary node hard disk fails. Lost.

Method used

By connecting to the shared area in the backup node, obtaining and sharing the file saving path, the files to be backed up of the master node are sent to the shared area, avoiding the storage space of the master node or backup node, and building sharing services between nodes to achieve real-time data Backup and restore.

Benefits of technology

Save storage space, improve backup timeliness and recovery efficiency, ensure that data is not lost when the master node fails, and facilitate the search for reasons when the backup is wrong.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166418A_ABST
    Figure CN119166418A_ABST
Patent Text Reader

Abstract

The invention discloses a database file backup and recovery method and device, and the method comprises the steps: enabling a standby node to be connected with a preset sharing region, and obtaining a file storage path corresponding to the sharing region; the standby node shares the file saving path to a main node and a management node, so that the main node sends an obtained file to be backed up to the sharing area; the main node starts a file backup service and obtains a file to be backed up based on a pre-created backup path; the main node receives a file saving path shared by the standby node; and the main node sends the to-be-backed-up file to a shared area connected with the standby node based on the file saving path, so that the shared area stores the to-be-backed-up file, and the storage space of the node is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a database file backup and recovery method and a file backup and recovery device. Background Art

[0002] With the popularization of computers, using databases to back up and restore data has become increasingly important. In the prior art, when using a database to back up data, the three nodes of the database cluster, namely the master / backup / management node, are used to back up data to a local hard disk. When recovery is required, the backup file in the local hard disk is copied to the management node or other test environment to restore the data.

[0003] However, the technical means of using nodes to back up data cannot guarantee the synchronization of backup when switching between the primary and backup nodes. In addition, the primary node, backup node, and management node all require independent storage space, resulting in storage waste. When using hard disks for data recovery, it is necessary to copy the complete backup, which is time-consuming and labor-intensive. Moreover, the backup is a dynamic increase process, and the most recent and complete backup cannot be copied. In addition, when the primary node hard disk fails, if the backup data is not copied in time, the data will be lost. Summary of the invention

[0004] In order to solve the above technical problems, the present invention discloses a database file backup and recovery method and a file backup and recovery device for saving storage space.

[0005] In order to achieve the above object, in a first aspect, the present invention discloses a database file backup method, comprising:

[0006] The standby node connects to the preset shared area and obtains the file saving path corresponding to the shared area;

[0007] The standby node shares the file storage path with the master node and the management node, so that the master node sends the acquired files to be backed up to the shared area.

[0008] The present invention discloses a method for backing up a database file, which connects a shared area at a standby node so that the shared area stores the files to be backed up uploaded by the master node, thereby no longer occupying the space of the master node or the standby node for data storage, thereby saving storage space. Furthermore, in order to send the files to be backed up of the master node to the shared area, the standby node first shares the file saving path of the shared area with the master node, so that the master node uploads the files to be backed up according to the file saving path, thereby completing the backup of the files.

[0009] As a preferred example, the database file backup method further includes: the standby node shares the file save path with a test node and a development node.

[0010] The present invention saves the file saving path of the shared area to different nodes, so that when the main node executes the backup task, the backup process can be viewed from any node, which is convenient for finding the cause when a backup error occurs later.

[0011] As a preferred example, the standby node connects to a preset shared area and obtains a file storage path corresponding to the shared area, including:

[0012] The standby node mounts the server of the preset server and obtains the shared directory of the server;

[0013] The present invention mounts a server end for storing data on the standby node, so that when a failure occurs in the primary node, the data will not be lost, thereby ensuring the backup effect.

[0014] As a preferred example, the standby node shares the file saving path with the master node and the management node, including:

[0015] The standby node respectively sets permissions for the master node, management node, test node and development node on the shared directory, and shares the permissions and the shared directory to the master node, management node, test node and development node; wherein the master node has read and write permissions; the management node, test node and development node have read-only permissions.

[0016] In the present invention, the shared directory is sent to each node through the standby node to complete the upload of data backup. Further, the authority of different nodes to the server is set to ensure the security of data backup upload.

[0017] In a second aspect, the present invention discloses a database file backup method, comprising:

[0018] The master node starts the file backup service and obtains the files to be backed up based on the pre-created backup path;

[0019] The master node receives a file storage path shared by the standby node;

[0020] The master node sends the file to be backed up to the shared area connected to the backup node based on the file storage path, so that the shared area stores the file to be backed up.

[0021] In a database file backup method disclosed in the present invention, the master node uploads the backup file to the shared area connected to the standby node using the file storage path shared by the standby node, ensuring that the space of the master node is not occupied for data storage, thus saving storage space. Furthermore, the present invention ensures real-time backup of data and improves the timeliness of backup by constructing a sharing service in the master and standby nodes.

[0022] As a preferred example, the primary node receives the file storage path shared by the backup node, including:

[0023] The master node mounts a client of a preset server to obtain a shared directory of the server through the client.

[0024] The present invention mounts the client of the server on the main node, and can timely interact with the service end of the server to ensure the timeliness of data backup.

[0025] As a preferred example, the step of obtaining the files to be backed up based on the pre-created backup path includes:

[0026] The master node outputs the files to be backed up according to a preset backup directory format.

[0027] The present invention uses a unified backup directory format to upload backup files to adapt to different nodes and facilitate user viewing.

[0028] In a third aspect, the present invention discloses a database file recovery method, comprising:

[0029] The management node receives the file storage path shared by the standby node;

[0030] The management node obtains the pre-backed-up backup file from the shared area connected to the standby node based on the file storage path;

[0031] The management node sends the backup file to the master node.

[0032] In a database file recovery method disclosed by the present invention, the management node can directly obtain the data to be recovered from the shared area connected to the standby node through the data sharing service between the master node and the standby node, without the need to recover the data in the form of hardware, thereby improving the efficiency of data recovery.

[0033] In a fourth aspect, the present invention discloses a database file backup device, comprising a primary node and a backup node;

[0034] The standby node is used to connect to a preset shared area and obtain a file storage path corresponding to the shared area; the file storage path is shared with the master node and the management node, so that the master node sends the obtained files to be backed up to the shared area;

[0035] The master node is used to start a file backup service and obtain the file to be backed up based on a pre-created backup path; receive a file storage path shared by a standby node; and based on the file storage path, send the file to be backed up to a shared area connected to the standby node so that the shared area stores the file to be backed up.

[0036] In a database file backup device disclosed in the present invention, the primary node and the backup node upload the backup file to the shared area connected to the backup node through a shared file storage path, ensuring that the space of the primary node and the backup node is not occupied for data storage, thus saving storage space. Furthermore, the present invention ensures real-time backup of data and improves the timeliness of backup by constructing a shared service in the primary and backup nodes.

[0037] In a fifth aspect, the present invention discloses a database file recovery device, including a master node, a backup node and a management node;

[0038] The standby node is used to share the file storage path to the management node;

[0039] The management node is used to receive the file storage path, and based on the file storage path, obtain the pre-backed-up backup file from the shared area connected to the standby node, and send the backup file to the master node;

[0040] The master node is used to receive the backup file.

[0041] In a database file recovery device disclosed in the present invention, the management node can directly obtain the data to be recovered from the shared area connected to the standby node through the data sharing service between the master node and the standby node, without the need to recover the data in the form of hardware, thereby improving the efficiency of data recovery. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 : is a flowchart of a database file backup method disclosed in an embodiment of the present application;

[0043] Figure 2 : is another flow chart of a database file backup method disclosed in an embodiment of the present application;

[0044] Figure 3 : A flowchart of a database file recovery method disclosed in an embodiment of the present application;

[0045] Figure 4 : is a structural diagram of a database file backup device disclosed in an embodiment of the present application;

[0046] Figure 5: is another structural schematic diagram of a database file backup device disclosed in an embodiment of the present application;

[0047] Figure 6 : A schematic diagram of the interaction between a database and Nfs disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0049] Example

[0050] Reference Figure 1 , is a database file backup method disclosed in an embodiment of the present application, and the specific implementation process of the method includes steps 101 to 102, and the steps are mainly:

[0051] Step 101: The standby node connects to a preset shared area and obtains a file storage path corresponding to the shared area.

[0052] In this embodiment, the step mainly includes: the standby node mounts the server of a preset server and obtains the shared directory of the server.

[0053] Specifically, in this embodiment, when backing up and restoring files of a database cluster, such as a Jincang database cluster, a variety of servers capable of storing data can be used as the shared area to store the backup files uploaded by the database cluster. In some implementations of this embodiment, an nfs server is used as the shared area to store the backup files in the Jincang database cluster. Optionally, refer to Figure 6 , is a schematic diagram of the interaction between the nfs server and the database cluster. Install the nfs server on the standby node and set it to start automatically at boot, and obtain the shared directory of the nfs server. Among them, the Jincang database cluster includes the master node / standby node / management node, and the test / development environment.

[0054] In this embodiment, this step mounts a server for storing data on the standby node, so that when a failure occurs in the primary node, data will not be lost, thereby ensuring the backup effect.

[0055] Step 102: The standby node shares the file storage path with the master node and the management node, so that the master node sends the acquired files to be backed up to the shared area.

[0056] In this embodiment, the steps are mainly as follows: the standby node shares the file save path to the test node and the development node; the standby node sets the permissions of the main node, management node, test node and development node to the shared directory respectively, and shares the permissions and the shared directory to the main node, management node, test node and development node; wherein the main node has read and write permissions; the management node, test node and development node have read-only permissions.

[0057] Specifically, in some implementations of this embodiment, taking the connected shared area as an nfs server as an example, the standby node can set it to start automatically when installing the nfs server, and share the shared directory of the nfs server with the master node, and set the permission of the master node to read and write permission, share it with the management node and set the permission of the management node to read-only permission, share it with the test / development environment and set the permission of the test node or development node corresponding to the test / development environment to read-only permission. The process of sharing the directory and the process of allocating the permissions are as follows:

[0058] yuminstall rpcbind nfs-utils–y

[0059] systemctl start rpcbind

[0060] systemctl enable rpcbind

[0061] systemctl status rpcbind

[0062] systemctl start nfs

[0063] systemctl enable nfs

[0064] systemctl status nfs.

[0065] Edit / etc / exports to share the shared directory. If it is shared with the master node, it has write permission. If it is shared with the management or test node, it only has read permission.

[0066] #more / etc / exports

[0067] / ** / backup<master node IP> / 32(sync,no_subtree_check,rw,no_root_squash)

[0068] / ** / backup<standby node IP> / 32(sync,no_subtree_check,ro,no_root_squash)

[0069] / ** / backup<test node> / 32(sync,no_subtree_check,ro,no_root_squash).

[0070] In this embodiment, the step sends the shared directory to each node through the standby node to complete the upload of the data backup. Further, the permissions of different nodes to the server are set to ensure the security of the data backup upload.

[0071] Further, in the standby node such as Figure 1 After the shared file is saved in the master node, the master node executes the following file backup method: Figure 2 The method mainly includes steps 201 to 203, wherein the steps are mainly:

[0072] Step 201: The master node starts the file backup service and obtains the files to be backed up based on the pre-created backup path.

[0073] In this embodiment, this step mainly includes: the master node outputs the files to be backed up according to a preset backup directory format.

[0074] Specifically, in some implementations of this embodiment, the backup directory of all nodes is set to the same directory / *** / backup (or a soft link is created). Specifically:

[0075] $ more sys_backup.conf

[0076] #! ! ! ! dir to store the backup files

[0077] #should be accessible for the OS user

[0078] _repo_path=" / *** / backup / rman".

[0079] In this embodiment, this step uses a unified backup directory format to upload backup files to adapt to different nodes and facilitate user viewing.

[0080] Step 202: The primary node receives the file storage path shared by the backup node.

[0081] In this embodiment, this step mainly includes: the master node mounts the client of the preset server to obtain the shared directory of the server through the client.

[0082] Specifically, in some implementations of this embodiment, taking the nfs server as an example, nfs clients are installed on the master node, management node, and test node, and are set to start automatically when the nodes are powered on; and the nfs shared directory of the standby node is mounted to the local machine.

[0083] yuminstall nfs-utils–y

[0084] systemctl start nfs

[0085] systemctl enable nfs

[0086] systemctl status nfs

[0087] Edit / etc / fstab and mount the nfs shared directory locally at startup.

[0088] #more / etc / fstab

[0089] <Standby node IP>: / *** / backup / *** / backup nfs defaults,_netdev 0 0.

[0090] In this embodiment, this step mounts the client of the server on the master node, which can interact with the server's service end in a timely manner to ensure the timeliness of data backup.

[0091] Step 203: The primary node sends the file to be backed up to the shared area connected to the backup node based on the file storage path, so that the shared area stores the file to be backed up.

[0092] Specifically, in some implementations of this embodiment, after the primary node (or the backup node switches to the primary node) performs backup, other nodes are immediately visible and can be used immediately.

[0093] #more KINGBASECRON

[0094] 02**4kingbase / kdb_data / kingbase / cluster / kdbcluster / kingbase / bin / sys_rman

[0095] --config= / kdb_data / kingbase / backup / rman / sys_rman.conf

[0096] --stanza=kingbase

[0097] --archive-copy

[0098] --type=fullbackup>> / kdb_data / kingbase / cluster / kdbcluster / kingbase / log / sys_rman_backup_full.log 2>&1;

[0099] 04**0,1,2,3,5,6kingbase / kdb_data / kingbase / cluster / kdbcluster / kingbase / bin / sys_rman

[0100] --config= / kdb_data / kingbase / backup / rman / sys_rman.conf

[0101] --stanza=kingbase

[0102] --archive-copy

[0103] --type=incrbackup>> / kdb_data / kingbase / cluster / kdbcluster / kingbase / log / sys_rman_backup_incr.log 2>&1.

[0104] Reference Figure 3 After the data is backed up by the master node and the backup node, the method for restoring the database file when restoring the data includes steps 301 to 303, specifically:

[0105] Step 301: The management node receives the file storage path shared by the standby node.

[0106] Step 302: The management node obtains the pre-backed-up backup file from the shared area to which the standby node is connected based on the file storage path.

[0107] Step 303: The management node sends the backup file to the master node.

[0108] Specifically, in this embodiment, refer to Figure 3 When the data recovery operation is performed on the management node or the test node, the specific data recovery process is as follows:

[0109] / *** / kingbase / bin / sys_rman\

[0110] --config= / *** / backup / rman / sys_rman.conf\

[0111] --stanza=kingbase--kb1-path= / *** / test / data\

[0112] --type=time--target='2023-06-07 12:30:00'--archive-mode=offrestore.

[0113] Reference Figure 4 This embodiment also discloses a database file backup device, the specific structure of which mainly consists of a master node 401 and a backup node 402.

[0114] The standby node 402 is used to connect to a preset shared area and obtain a file storage path corresponding to the shared area; the file storage path is shared with the master node 401 and the management node, so that the master node 401 sends the obtained files to be backed up to the shared area;

[0115] The master node 401 is used to start the file backup service and obtain the file to be backed up based on the pre-created backup path; receive the file saving path shared by the standby node 402; based on the file saving path, send the file to be backed up to the shared area connected to the standby node 402, so that the shared area stores the file to be backed up.

[0116] Further, refer to Figure 5 , is a database file recovery device provided in this embodiment, and the specific structure of the file recovery device includes a master node 401, a backup node 402 and a management node 501.

[0117] The standby node 402 is used to share the file storage path to the management node 501;

[0118] The management node 501 is used to receive the file storage path, and based on the file storage path, obtain the pre-backed-up backup file from the shared area connected to the standby node 402, and send the backup file to the master node 401;

[0119] The master node 401 is used to receive the backup file.

[0120] The database file backup and recovery method and file backup and recovery device disclosed in this embodiment do not need to occupy the storage space of each node to save data, thereby saving storage space of approximately (backup data size)*(total number of nodes-1); further, due to the shared service between each node, when performing data recovery, data can be directly obtained from the shared area, saving copying time, which ranges from tens of minutes to several hours. In addition, this embodiment only needs to configure the server once, and no additional operation is required; and due to external storage, in the case of a crash of one machine in the primary and standby nodes, data will not be lost; and in the case of primary and standby switching, the backup data is continuous and will not be broken due to switching.

[0121] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A database file backup method, characterized in that: include: The standby node connects to the preset shared area and obtains the file saving path corresponding to the shared area; The standby node shares the file storage path with the master node and the management node, so that the master node sends the acquired files to be backed up to the shared area.

2. A database file backup method according to claim 1, characterized in that: The method also includes: the standby node shares the file save path with the test node and the development node.

3. A database file backup method according to claim 1, characterized in that: The standby node connects to a preset shared area and obtains a file storage path corresponding to the shared area, including: The standby node mounts the server of a preset server and obtains the shared directory of the server.

4. A database file backup method according to any one of claims 2 to 3, characterized in that: The standby node shares the file storage path with the master node and the management node, including: The standby node respectively sets permissions for the master node, management node, test node and development node on the shared directory, and shares the permissions and the shared directory to the master node, management node, test node and development node; wherein the master node has read and write permissions; the management node, test node and development node have read-only permissions.

5. A database file backup method, characterized in that: include: The master node starts the file backup service and obtains the files to be backed up based on the pre-created backup path; The master node receives a file storage path shared by the standby node; The master node sends the file to be backed up to the shared area connected to the backup node based on the file storage path, so that the shared area stores the file to be backed up.

6. A database file backup method according to claim 5, characterized in that: The primary node receives the file storage path shared by the backup node, including: The master node mounts a client of a preset server to obtain a shared directory of the server through the client.

7. A database file backup method according to claim 5, characterized in that: The step of obtaining the file to be backed up based on the pre-created backup path includes: The master node outputs the files to be backed up according to a preset backup directory format.

8. A method for restoring a database file, characterized in that: include: The management node receives the file storage path shared by the standby node; The management node obtains the pre-backed-up backup file from the shared area connected to the standby node based on the file storage path; The management node sends the backup file to the master node.

9. A database file backup device, characterized in that: Includes master node and standby node; The standby node is used to connect to a preset shared area and obtain a file storage path corresponding to the shared area; the file storage path is shared with the master node and the management node, so that the master node sends the obtained files to be backed up to the shared area; The master node is used to start the file backup service and obtain the files to be backed up based on the pre-created backup path; Receive the file storage path shared by the standby node; Based on the file storage path, the file to be backed up is sent to a shared area connected to the standby node, so that the shared area stores the file to be backed up.

10. A database file recovery device, characterized in that: Includes master node, standby node and management node; The standby node is used to share the file storage path to the management node; The management node is used to receive the file storage path, and based on the file storage path, obtain the pre-backed-up backup file from the shared area connected to the standby node, and send the backup file to the master node; The master node is used to receive the backup file.

Citation Information

Patent Citations

  • Network backup method, device and system without proxy

    CN101841425A

  • Method and device for sharing file among multiple devices

    CN104519109A

  • Distributed database backup method, device and system

    CN111651302A

  • Decentralized data backup method and device, equipment and medium

    CN117608926A

  • Fragmented cluster backup recovery method, system and device, computer equipment and medium

    CN118152185A