A database backup method, device, equipment, storage medium and product

By identifying and recording the mapping relationship between external storage media and nodes in a distributed database, generating a backup directory, and directly writing data to external storage media, the problem of low efficiency and difficulty in ensuring consistency in existing technologies is solved, achieving efficient and reliable data backup and recovery.

CN121092370BActive Publication Date: 2026-03-03TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511632114.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-03-03
Estimated Expiration
2045-11-10

AI Technical Summary

Technical Problem

In existing technologies, data backup of distributed databases to external storage media is inefficient, the backup process is lengthy, data consistency is difficult to guarantee, and the automation of data recovery is insufficient.

Method used

By identifying the external storage media corresponding to each database node in the distributed database, recording the mapping relationship, generating a backup directory, and directly writing data to the external storage media, the data backup and recovery can be automated.

Benefits of technology

It improves the efficiency of data backup and recovery, and ensures the reliability of data backup and recovery results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121092370B_ABST
    Figure CN121092370B_ABST
Patent Text Reader

Abstract

The application discloses a database backup method, device, equipment, storage medium and product, and comprises the following steps: identifying external storage media corresponding to each database node in a distributed database, and recording the mapping relationship between each external storage media and the corresponding database node; according to the mapping relationship, mounting the path of each external storage media to the storage directory of the corresponding database node to obtain the backup directory corresponding to each database node; and in response to a data backup request, backing up the target data corresponding to each database node to the corresponding backup directory. The technical scheme of the embodiment of the application can improve the data backup and recovery efficiency in the distributed database, and ensure the reliability of the data backup result and the data recovery result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database technology, and in particular to a database backup method, apparatus, device, storage medium, and product. Background Technology

[0002] A distributed database is a data storage system that distributes data across multiple nodes and manages it collaboratively through a network. It is suitable for application scenarios such as high-concurrency business, massive data storage, and cross-regional deployment.

[0003] In existing technologies, when backing up stored data in a distributed database to external storage media, the data in the database needs to be backed up to the local disk first, and then the data in the local disk needs to be migrated to the external storage media. The transmission link is lengthy, resulting in low backup efficiency and flexibility. Furthermore, when multiple database nodes back up data to external storage media simultaneously in existing distributed databases, data consistency is difficult to guarantee. When restoring data from external storage media, the name of the external storage media needs to be manually located, which is not automated enough and results in low data recovery efficiency. Summary of the Invention

[0004] This invention provides a database backup method, apparatus, device, storage medium, and product, which can improve the efficiency of data backup and recovery in distributed databases and ensure the reliability of data backup and recovery results.

[0005] According to one aspect of the present invention, a database backup method is provided, applied to a distributed database, the method comprising:

[0006] Identify the external storage media corresponding to each database node in the distributed database, and record the mapping relationship between each external storage media and the corresponding database node;

[0007] Based on the mapping relationship, the paths of each external storage medium are mounted to the storage directory of the corresponding database node to obtain the backup directory corresponding to each database node;

[0008] In response to a data backup request, the target data for each database node is backed up to the corresponding backup directory.

[0009] Optionally, identify the external storage media corresponding to each database node in the distributed database, including:

[0010] The metadata service tool corresponding to the distributed database identifies the external storage media corresponding to each database node in the distributed database based on the list blockdevices (lsblk) command.

[0011] Optionally, the mapping relationship between each external storage medium and the corresponding database node is recorded, including:

[0012] Write the media parameters corresponding to each external storage medium into the storage directory of the corresponding database node;

[0013] The media parameters include at least the media type and the media name.

[0014] Optionally, based on the mapping relationship, the paths of each external storage medium are mounted to the storage directory of the corresponding database node to obtain the backup directory corresponding to each database node, including:

[0015] Obtain the media types recorded in the storage directory of each database node, and generate a mount command that matches the media type;

[0016] According to the mount command matched to each of the media types, the path of each external storage media is mounted to the storage directory of the corresponding database node, thus obtaining the backup directory corresponding to each database node.

[0017] Optionally, the target data for each database node can be backed up to the corresponding backup directory, including:

[0018] Based on the IP address, timestamp, and backup task identifier of each database node, generate at least one subdirectory in the backup directory corresponding to each database node;

[0019] Based on the directory name corresponding to each subdirectory, the target data corresponding to each database node is backed up to the subdirectory.

[0020] Optionally, after backing up the target data corresponding to each database node to the subdirectory, the method further includes:

[0021] In response to a data recovery request, the target data is read from the subdirectory by each database node based on the corresponding IP address, timestamp, and backup task identifier.

[0022] According to another aspect of the present invention, a database backup apparatus is provided, applied to a distributed database, the apparatus comprising:

[0023] The identification module is used to identify the external storage media corresponding to each database node in the distributed database and record the mapping relationship between each external storage media and the corresponding database node.

[0024] The mounting module is used to mount the paths of each of the external storage media to the storage directory of the corresponding database node according to the mapping relationship, so as to obtain the backup directory corresponding to each database node.

[0025] The backup module is used to respond to data backup requests and back up the target data for each database node to the corresponding backup directory.

[0026] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0027] At least one processor; and

[0028] A memory communicatively connected to the at least one processor; wherein,

[0029] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the database backup method according to any embodiment of the present invention.

[0030] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the database backup method according to any embodiment of the present invention.

[0031] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the database backup method described in any embodiment of the present invention.

[0032] The technical solution provided by this invention identifies the external storage media corresponding to each database node in a distributed database, records the mapping relationship between each external storage media and the corresponding database node, and mounts the path of each external storage media to the storage directory of the corresponding database node according to the mapping relationship, thereby obtaining the backup directory corresponding to each database node. In response to a data backup request, the target data corresponding to each database node is backed up to the corresponding backup directory. This technical means can improve the efficiency of data backup and recovery and ensure the reliability of data backup and recovery results.

[0033] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0035] Figure 1 This is a flowchart of a database backup method provided according to an embodiment of the present invention;

[0036] Figure 2 This is a flowchart of another database backup method provided according to an embodiment of the present invention;

[0037] Figure 3 This is a schematic diagram of the structure of a database backup device according to an embodiment of the present invention;

[0038] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the database backup method of this invention. Detailed Implementation

[0039] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0040] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0041] Figure 1This is a flowchart illustrating a database backup method provided in an embodiment of the present invention. This embodiment is applicable to situations where data from multiple database nodes in a distributed database is backed up to external storage media. The method can be executed by a database backup device, which can be implemented in hardware and / or software and configured in an electronic device (e.g., a server or terminal). Figure 1 As shown, the method includes:

[0042] Step 110: Identify the external storage media corresponding to each database node in the distributed database, and record the mapping relationship between each external storage media and the corresponding database node.

[0043] In this embodiment, optionally, before backing up the data in the distributed database, it is possible to predefine which database nodes in the distributed database need to back up their data to external storage media and record the IP addresses of these nodes. Then, external storage media, such as a removable hard drive or optical disc, can be connected to these nodes. The optical disc may include a Digital Versatile Disc (DVD) or a Rewritable (Rw) optical disc, etc., and this embodiment does not impose any limitations on this.

[0044] In this database, the IP addresses of multiple database nodes can be separated by spaces. Each database node is an independent computing unit that constitutes a distributed database. It possesses autonomy, communication capabilities, and distributed storage functions, and collaborates to achieve core mechanisms such as data sharding, load balancing, and fault tolerance.

[0045] In a specific embodiment, the above-mentioned nodes can be defined according to the storage space corresponding to each database node in the distributed database. For example, if some nodes have insufficient storage space or limited storage resources, the IP addresses of such nodes can be recorded.

[0046] After connecting external storage media to the distributed database in the above manner, the external storage media information corresponding to each database node can be monitored in real time, and the external storage media information can be bound to the corresponding database node to generate a mapping relationship between each external storage media and the corresponding database node.

[0047] The advantage of this setup is that by binding external storage media information to the corresponding database nodes, the consistency of backup data can be guaranteed and the reliability of backup results can be improved when multiple database nodes simultaneously back up data to external storage media.

[0048] Step 120: Based on the mapping relationship, mount the path of each external storage medium to the storage directory of the corresponding database node to obtain the backup directory corresponding to each database node.

[0049] In this embodiment, specifically, after generating the mapping relationship between each external storage medium and the corresponding database node, the path of each external storage medium can be mapped to the local storage or configuration directory of the corresponding database node through Docker container mounting or Linux system mounting commands, thereby obtaining the backup directory corresponding to each database node.

[0050] The advantages of this setup are twofold: First, by mounting the external storage media to the local directory of the database node, the data stored on the database node can be directly written to the external storage media during the data backup process. Compared to the existing technology that first backs up the data in the database node to the local disk and then migrates the data from the local disk to the external storage media, this shortens the data backup chain and improves data backup efficiency and flexibility. Second, when restoring data from the external storage media to the database node, data recovery can be performed directly based on the mounting status of the external storage media, thereby automating the data recovery process, improving data recovery efficiency, and ensuring the reliability of the data recovery results.

[0051] Step 130: In response to the data backup request, back up the target data for each database node to the corresponding backup directory.

[0052] In this embodiment, the data backup request can be triggered by the user. After receiving the data backup request, the data specified by the user for each database node can be used as the target data, and then the target data can be written to the corresponding backup directory.

[0053] The technical solution provided by this invention identifies the external storage media corresponding to each database node in a distributed database, records the mapping relationship between each external storage media and the corresponding database node, and mounts the path of each external storage media to the storage directory of the corresponding database node according to the mapping relationship, thereby obtaining the backup directory corresponding to each database node. In response to a data backup request, the target data corresponding to each database node is backed up to the corresponding backup directory. This technical means can improve the efficiency of data backup and recovery and ensure the reliability of data backup and recovery results.

[0054] Figure 2 A flowchart of another database backup method provided in an embodiment of the present invention is shown below. Figure 2 As shown, the method includes:

[0055] Step 210: Using the metadata service tool corresponding to the distributed database, identify the external storage media corresponding to each database node in the distributed database based on the lsblk command.

[0056] In this embodiment, metadata service tools refer to systems or platforms responsible for collecting, storing, managing, querying, and maintaining metadata. Their core function is to improve the manageability, discoverability, and usability of data through descriptive information (metadata).

[0057] In this step, the metadata service tool can use the lsblk command to identify the external storage media corresponding to each database node in the distributed database. If the device name of the external storage media begins with " / dev / sdb", then this external storage media is confirmed to be a removable hard drive. If the device name of the external storage media begins with " / dev / sr", then this external storage media is confirmed to be an optical disc.

[0058] The lsblk command is a Linux command used to view block device information. It is mainly used to display the hierarchical relationship (tree structure) of block devices such as disks, partitions, and optical drives, and provides key parameters such as device size, mount point, and file system type.

[0059] Step 220: Write the media parameters corresponding to each external storage media into the storage directory of the corresponding database node; the media parameters include at least the media type and the media name.

[0060] In one specific embodiment, the media parameters may also include the device path of the external storage media, user-defined function (UDF) option information, burning speed, and buffer size, etc., but this embodiment does not limit these.

[0061] Step 230: Obtain the media types recorded in the storage directory of each database node, and generate a mount command that matches the media type.

[0062] In this embodiment, after identifying the media type corresponding to the external storage media through step 210, a mount command matching the media type can be generated.

[0063] In one specific embodiment, if the external storage media is a removable hard drive, a database management node (dbauser) with sudo (superuser do) privileges can generate a mount command matching the removable hard drive, i.e.:

[0064] sudo mount -t vfat / dev / sdb1 / home / gbase / backup -w -o uid=1000,gid=1000,umask=000,fmask=000,dmask=000;

[0065] This enables the database management node to have read and write permissions for the mounted storage directory.

[0066] In another specific embodiment, if the external storage medium is an optical disc, the disc can be erased using the `wodim` command (i.e., `wodim -v / dev / sr1 blank=fast`), and then formatted using the `mkudffs` command to obtain a UDF file system (`mkudffs --media-type=dvdrw --blocksize=2048 / dev / sr1`). This generates a mount command matching the disc, i.e.:

[0067] mount -t udf -o rw / dev / sr1 / home / gbase / backup;

[0068] Finally, grant the database management node read and write permissions to the mounted storage directory.

[0069] The `wodim` command's erase function is designed for rewritable optical discs (such as CD-RW and DVD-RW). It clears existing data using specific parameters, preparing the disc for re-burning. The `mkudffs` command is used to create a UDF file system in Linux systems, enabling users to modify data on the optical disc in real-time during cross-platform data operations.

[0070] Step 240: According to the mount command matched for each of the media types, mount the path of each of the external storage media to the storage directory of the corresponding database node to obtain the backup directory corresponding to each database node.

[0071] Step 250: In response to the data backup request, generate at least one subdirectory in the backup directory corresponding to each database node based on the IP address, timestamp, and backup task identifier of each database node.

[0072] Step 260: Back up the target data corresponding to each database node to the subdirectory according to the directory name corresponding to each subdirectory.

[0073] Step 270: In response to the data recovery request, each database node reads the target data from the subdirectory based on the corresponding IP address, timestamp, and backup task identifier.

[0074] The advantage of this setup is that by creating different subdirectories based on different database node IP addresses, timestamps, and backup task identifiers, data consistency during backup and recovery can be ensured, thus improving the reliability of backup and recovery results.

[0075] The technical solution provided by this invention utilizes a metadata service tool corresponding to a distributed database. Based on the lsblk command, it identifies the external storage media corresponding to each database node in the distributed database. The media parameters corresponding to each external storage media are written into the storage directory of the corresponding database node. The media types recorded in the storage directory of each database node are obtained, and a mount command matching the media type is generated. Based on the mount commands matching each media type, the paths of each external storage media are mounted to the storage directory of the corresponding database node, resulting in a backup directory for each database node. In response to a data backup request, at least one subdirectory is generated in the backup directory corresponding to each database node based on the IP address, timestamp, and backup task identifier of each database node. The target data corresponding to each database node is backed up to the subdirectory based on the directory name of each subdirectory. In response to a data recovery request, the target data is read from the subdirectory by each database node based on its corresponding IP address, timestamp, and backup task identifier. This technical means can improve data backup and recovery efficiency and ensure the reliability of data backup and recovery results.

[0076] Figure 3 This is a schematic diagram of a database backup device provided in an embodiment of the present invention. The device is applied to a distributed database, such as... Figure 3 As shown, the device includes: an identification module 310, a mounting module 320, and a backup module 330.

[0077] The identification module 310 is used to identify the external storage media corresponding to each database node in the distributed database and record the mapping relationship between each external storage media and the corresponding database node.

[0078] Mounting module 320 is used to mount the paths of each external storage medium to the storage directory of the corresponding database node according to the mapping relationship, so as to obtain the backup directory corresponding to each database node;

[0079] Backup module 330 is used to back up the target data corresponding to each database node to the corresponding backup directory in response to a data backup request.

[0080] The technical solution provided by this invention identifies the external storage media corresponding to each database node in a distributed database, records the mapping relationship between each external storage media and the corresponding database node, and mounts the path of each external storage media to the storage directory of the corresponding database node according to the mapping relationship, thereby obtaining the backup directory corresponding to each database node. In response to a data backup request, the target data corresponding to each database node is backed up to the corresponding backup directory. This technical means can improve the efficiency of data backup and recovery and ensure the reliability of data backup and recovery results.

[0081] Based on the above embodiments, the identification module 310 includes:

[0082] The metadata service unit is used to identify the external storage media corresponding to each database node in the distributed database based on the lsblk command using the metadata service tool corresponding to the distributed database.

[0083] The parameter writing unit is used to write the media parameters corresponding to each external storage medium into the storage directory of the corresponding database node; wherein the media parameters include at least the media type and the media name.

[0084] Mounting module 320 includes:

[0085] The mount command generation unit is used to obtain the media types recorded in the storage directory of each database node and generate a mount command that matches the media type.

[0086] The mount command execution unit is used to mount the path of each external storage media to the storage directory of the corresponding database node according to the mount command matched for each media type, so as to obtain the backup directory corresponding to each database node.

[0087] Backup module 330 includes:

[0088] The subdirectory generation unit is used to generate at least one subdirectory in the backup directory corresponding to each database node based on the IP address, timestamp, and backup task identifier of each database node; and to back up the target data corresponding to each database node to the subdirectory according to the directory name of each subdirectory.

[0089] The device further includes:

[0090] The data recovery module is used to respond to data recovery requests by reading target data from the subdirectory through each database node based on the corresponding IP address, timestamp, and backup task identifier.

[0091] The above-described apparatus can execute the methods provided in all the foregoing embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the above methods. Technical details not described in detail in the embodiments of the present invention can be found in the methods provided in all the foregoing embodiments of the present invention.

[0092] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement embodiments of the present invention is shown. For example... Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded into the RAM 13 from storage unit 18. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0093] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0094] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing electronics, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as database backup methods.

[0095] In some embodiments, the database backup method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the database backup method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the database backup method by any other suitable means (e.g., by means of firmware).

[0096] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-electronic devices (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0097] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0098] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0099] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0100] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0101] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0102] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0103] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A database backup method characterized by, The method is applied to a distributed database, and the method comprises: According to the storage space corresponding to each database node in the distributed database, part of the database nodes are selected to access external storage media; Each external storage medium corresponding to each database node in the distributed database is identified, and a mapping relationship between each external storage medium and the corresponding database node is recorded; the external storage medium comprises a removable hard disk or an optical disk; According to the mapping relationship, the path of each external storage medium is mounted into the storage directory of the corresponding database node, and a backup directory corresponding to each database node is obtained; In response to a data backup request, at least one subdirectory is generated in the backup directory corresponding to each database node according to the IP address, the timestamp and the backup task identifier corresponding to each database node; target data corresponding to each database node is backed up into the subdirectory according to the directory name corresponding to each subdirectory; In response to a data recovery request, target data is read from the subdirectory by each database node according to the corresponding IP address, timestamp and backup task identifier; The IP address, timestamp and backup task identifier correspond to the directory name of the subdirectory.

2. The method of claim 1, wherein, The external storage medium corresponding to each database node in the distributed database is identified, comprising: The external storage medium corresponding to each database node in the distributed database is identified through a metadata service tool corresponding to the distributed database based on an lsblk command.

3. The method of claim 1, wherein, The mapping relationship between each external storage medium and the corresponding database node is recorded, comprising: The media parameters corresponding to each external storage medium are written into the storage directory of the corresponding database node; The media parameters at least comprise a media type and a media name.

4. The method of claim 3, wherein, According to the mapping relationship, the path of each external storage medium is mounted into the storage directory of the corresponding database node, and a backup directory corresponding to each database node is obtained, comprising: The media type recorded in the storage directory of each database node is obtained, and a mounting command matched with the media type is generated; According to the mounting command matched with each media type, the path of each external storage medium is mounted into the storage directory of the corresponding database node, and a backup directory corresponding to each database node is obtained.

5. A database backup apparatus characterized by comprising: The device is applied to a distributed database, and the device comprises: An identification module is configured to identify each external storage medium corresponding to each database node in the distributed database, and record a mapping relationship between each external storage medium and the corresponding database node; the external storage medium comprises a removable hard disk or an optical disk; A mounting module is configured to mount the path of each external storage medium into the storage directory of the corresponding database node according to the mapping relationship, and obtain a backup directory corresponding to each database node; A backup module is configured to generate at least one subdirectory in the backup directory corresponding to each database node in response to a data backup request according to the IP address, timestamp and backup task identifier corresponding to each database node; target data corresponding to each database node is backed up into the subdirectory according to the directory name corresponding to each subdirectory. The data recovery module is configured to read target data from the subdirectory according to the corresponding IP address, timestamp, and backup task identifier through each database node in response to a data recovery request. Before identifying the external storage media corresponding to each database node in the distributed database, the method further includes selecting part of the database nodes to access the external storage media according to the storage spaces corresponding to each database node in the distributed database. The IP address, timestamp, and backup task identifier correspond to the directory name of the subdirectory.

6. An electronic device, comprising: The electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the database backup method of any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for causing the processor to execute when the database backup method of any one of claims 1-4 is implemented.

8. A computer program product, characterised in that, The computer program product includes a computer program that, when executed by a processor, implements the database backup method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Backup recovery method and device of application system and computer readable storage medium

    CN109766220A

  • Data recovery method and device, electronic equipment and computer readable storage medium

    CN116149902A