Database file backup and recovery method, file backup and recovery device
By connecting to the shared area and sharing the file path in the backup node, the main node sends the backup file to the shared area, solving the problem of wasted storage and time-consuming data recovery of database file backup, and achieving efficient data backup and recovery.
Patent Information
- Application Number
- CN202411207472.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2044-08-30
AI Technical Summary
In the prior art, there are problems such as wasting storage, discontinuous backup, time-consuming and labor-intensive data recovery, and easy data loss when the master node fails.
By connecting to the shared area in the backup node, obtaining and sharing the file saving path, the master node sends the files to be backed up to the shared area to avoid occupying local storage space and recovering data directly from the shared area at the management node.
It realizes saving storage space, ensuring the timeliness and continuity of data backup, improving data recovery efficiency, and avoiding data loss.
Smart Images

Figure CN119166418B_ABST
Abstract
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 widespread use of computers, using databases for data backup and recovery has become increasingly important. Conventional database backup involves backing up data to local hard drives using the master, backup, and management nodes in a database cluster. When recovery is needed, the backup files on the local hard drives are copied to the management node or another test environment for data recovery.
[0003] However, using nodes for data backup not only fails to guarantee backup synchronization when switching between primary and backup nodes, but also requires independent storage space for the primary, backup, and management nodes, resulting in wasted storage. Data recovery using hard drives requires copying complete backups, which is time-consuming and labor-intensive. Furthermore, backups are dynamically added, making it impossible to copy the most recent and complete backup. Furthermore, if the primary node's hard drive fails, data will be lost if the backup data is not copied promptly. 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 objectives, 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 storage path corresponding to the shared area;
[0007] The backup node shares the file storage path with the primary node and the management node, so that the primary node sends the acquired files to be backed up to the shared area.
[0008] The present invention discloses a database file backup method that connects a shared area to a backup node, allowing the shared area to store files uploaded by the primary node to be backed up. This method eliminates the need to occupy space on either the primary or backup node for data storage, thereby conserving storage space. Furthermore, to send the primary node's files to be backed up to the shared area, the backup node first shares the shared area's file storage path with the primary node, allowing the primary node to upload the files to be backed up according to the file storage path, completing the file backup.
[0009] As a preferred example, the database file backup method further includes: the standby node sharing 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 fault 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 save path with the master node and the management node, including:
[0015] The standby node sets permissions for the master node, management node, test node, and development node on the shared directory, respectively, and shares the permissions and the shared directory with the master node, management node, test node, and development node; wherein the master node has read and write permissions; and 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. Furthermore, the permissions of different nodes to the server are 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 the 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 herein, the primary node uses a file storage path shared by the backup node to upload the backup file to a shared area connected to the backup node, ensuring that data storage does not occupy the primary node's space, thereby saving storage space. Furthermore, by establishing a shared service between the primary and backup nodes, the present invention ensures real-time data backup and improves the timeliness of backup.
[0022] As a preferred example, the master 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 utilizes 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, a 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, eliminating the need to recover the data through hardware, thereby improving the efficiency of data recovery.
[0033] In a fourth aspect, the present invention discloses a database file backup device, comprising a master 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; share the file storage path 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 the file backup service and obtain the file 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, send the file to be backed up to the 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 and backup nodes upload backup files to a shared area connected to the backup node via a shared file storage path, ensuring that data storage does not occupy space on the primary or backup nodes, thereby saving storage space. Furthermore, by establishing a shared service between the primary and backup nodes, the present invention ensures real-time data backup and improves the timeliness of backup.
[0037] In a fifth aspect, the present invention discloses a database file recovery device, comprising a master node, a backup node, and a management node;
[0038] The standby node is used to share the file storage path with the management node;
[0039] The management node is configured to receive the file storage path, and based on the file storage path, obtain a pre-backed-up backup file from a 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 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 through hardware, thereby improving the efficiency of data recovery. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 : A flowchart of a database file backup method disclosed in an embodiment of the present application;
[0043] Figure 2 : is another flowchart 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 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 provide a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall 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. 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, this 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 plurality 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 , a diagram illustrating the interaction between the NFS server and the database cluster. Install the NFS server on the backup node and set it to automatically start at startup, then obtain the shared directory of the NFS server. The Jincang database cluster includes a master node, backup nodes, management nodes, and a 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 backup 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 master node, management node, test node and development node to the shared directory respectively, 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.
[0057] Specifically, in certain 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 the nfs server is installed, and share the shared directory of the nfs server with the master node, and set the master node's permissions to read and write permissions, share it with the management node and set the management node's permissions to read-only permissions, and share it with the test / development environment and set the permissions of the test node or development node corresponding to the test / development environment to read-only permissions. The directory sharing process and the permission allocation process 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<backup 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 data backup upload. Furthermore, the permissions of different nodes to the server are set to ensure the security of data backup upload.
[0071] Furthermore, in the standby node, Figure 1 After the shared file is saved in the master node, the master node performs the following file backup method: Figure 2 The method mainly includes steps 201 to 203, which are:
[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 master node receives the file storage path shared by the backup node.
[0081] In this embodiment, this step mainly includes: the master node mounts a client of a preset server to obtain a 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 at boot; 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 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.
[0092] Specifically, in some implementations of this embodiment, after the master node (or the backup node switches to the master 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 connected to the standby node 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, referring 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 backup node 402 is used to connect to a preset shared area and obtain a file storage path corresponding to the shared area; share the file storage path 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 storage path shared by the standby node 402; based on the file storage 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 configured 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 backup 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 disclosed database file backup and recovery method and device do not require the storage space of each node to save data, thereby saving storage space equivalent to approximately (backup data size) * (total number of nodes - 1). Furthermore, due to the shared services between nodes, data can be directly retrieved from the shared area during data recovery, eliminating copying time, which can range from tens of minutes to several hours. Furthermore, this embodiment only requires a single server configuration, requiring no additional operations. Furthermore, due to the external storage, data will not be lost if one of the primary and backup nodes crashes. Furthermore, in the event of a primary-backup failover, the backup data remains continuous, without any interruptions due to the failover.
[0121] The specific embodiments described above further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A database file backup method, characterized in that: include: The standby node connects to a preset shared area and obtains a file save path corresponding to the shared area; wherein, when a preset server is used as the shared area, the standby node mounts the server end of the server and obtains a shared directory of the server end; The standby node shares the file save path 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; wherein, the standby node shares the shared directory with the master node and the management node; the master node mounts the client of the server to obtain the shared directory through the client; the standby node sets the permissions of the master node, management node, test node and development node to the shared directory respectively, and shares the permissions and the shared directory with 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.
2. A database file backup method according to claim 1, characterized in that: The method further includes: the standby node sharing the file save path with the test node and the development node.
3. 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; wherein the master node mounts the client of the preset server to obtain the shared directory of the server through the client; The master node receives the file storage path shared by the standby node; wherein, when the server is used as the shared area, the standby node mounts the server end of the server and obtains the shared directory of the server end, and sends the shared directory to the master node; The master node sends the file to be backed up to the shared area connected to the standby node based on the file save path, so that the shared area stores the file to be backed up; wherein, the master node receives the permission to the shared directory sent by the standby node; the master node has read and write permissions.
4. A database file backup method according to claim 3, characterized in that: The step of obtaining the files 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.
5. A database file recovery method, characterized in that: include: The management node receives the file storage path shared by the standby node; wherein, when a preset server is used as the shared area, the standby node mounts the server end of the server and obtains the shared directory of the server end, so as to share the shared directory with the management 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 primary node; wherein the backup node sets the management node's authority to the shared directory and shares the authority with the management node; wherein the management node has read-only authority.
6. A database file backup device, characterized in that: Includes master node and backup 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; wherein, when a preset server is used as the shared area, the standby node mounts the server end of the server and obtains the shared directory of the server end; the standby node shares the shared directory with the master node and the management node; the standby node sets the permissions of the master node, management node, test node and development node on the shared directory respectively, and shares the permissions and the shared directory with 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; The master node is used to start a file backup service and obtain the files to be backed up based on a pre-created backup path; receive the file storage path shared by the standby node; based on the file storage path, send the files to be backed up to the shared area connected to the standby node, so that the shared area stores the files to be backed up; wherein, the master node mounts the client of the server to obtain the shared directory through the client.
7. A database file recovery device, characterized in that: Including master node, backup node and management node; The standby node is used to share a file storage path with the management node; wherein the standby node connects to a preset shared area and obtains the file storage path corresponding to the shared area; wherein, when a preset server is used as the shared area, the standby node mounts the server end of the server and obtains the shared directory of the server end; the standby node 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 with the master node, management node, test node, and development node; the management node, test node, and development node have read-only permissions; The management node is configured to receive the file storage path, and based on the file storage path, obtain a pre-backed-up backup file from a 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
Distributed database backup method, device and system
CN111651302A
Decentralized data backup method and device, equipment and medium
CN117608926A