[go: up one dir, main page]

CN116302688A - Database processing method, device, electronic device and storage medium - Google Patents

Database processing method, device, electronic device and storage medium Download PDF

Info

Publication number
CN116302688A
CN116302688A CN202310146372.4A CN202310146372A CN116302688A CN 116302688 A CN116302688 A CN 116302688A CN 202310146372 A CN202310146372 A CN 202310146372A CN 116302688 A CN116302688 A CN 116302688A
Authority
CN
China
Prior art keywords
database
backup
processed
command
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310146372.4A
Other languages
Chinese (zh)
Inventor
骆振源
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Secworld Information Technology Beijing Co Ltd
Qax Technology Group Inc
Original Assignee
Secworld Information Technology Beijing Co Ltd
Qax Technology Group Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Secworld Information Technology Beijing Co Ltd, Qax Technology Group Inc filed Critical Secworld Information Technology Beijing Co Ltd
Priority to CN202310146372.4A priority Critical patent/CN116302688A/en
Publication of CN116302688A publication Critical patent/CN116302688A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention provides a database processing method, a device, electronic equipment and a storage medium, which are applied to a server, wherein the server comprises a database to be processed, and the method comprises the following steps: acquiring a database to be processed; creating a file backup script corresponding to the database to be processed under the condition that the system service of the server is running, and carrying out backup operation on the database to be processed based on the file backup script to obtain a backup file; and under the condition that the data of the database to be processed is lost, creating a database recovery script corresponding to the backup file based on the backup file, and constructing a recovery database corresponding to the database to be processed based on the database recovery script and the backup file, so that the server is recovered to obtain the recovery database under the condition that the system service is operated. On the premise of not suspending the operation of the server, the database can be backed up and restored, so that the experience and satisfaction of the user in the use process can be improved.

Description

数据库处理方法、装置、电子设备及存储介质Database processing method, device, electronic device and storage medium

技术领域technical field

本发明涉及数据处理技术领域,尤其涉及一种数据库处理方法、装置、电子设备及存储介质。The present invention relates to the technical field of data processing, in particular to a database processing method, device, electronic equipment and storage medium.

背景技术Background technique

随着计算机技术的普及和发展,使得各行各业借助计算机得到了生产效率的大幅提升,其中,对数据的存储起到支柱作用的便是数据库。With the popularization and development of computer technology, all walks of life have greatly improved production efficiency with the help of computers. Among them, the database plays a pillar role in data storage.

相关技术可知,在对数据库进行备份与恢复的过程中,往往需要暂停服务器的运行,这将影响用户在使用过程中的体验感。当前寻找一种在不暂停服务器运行的前提下,能够对数据库进行备份与恢复操作成为研究热点。It is known in the related art that during the process of backing up and restoring the database, it is often necessary to suspend the operation of the server, which will affect the experience of the user during use. Currently, finding a way to back up and restore the database without suspending the operation of the server has become a research hotspot.

发明内容Contents of the invention

本发明提供一种数据库处理方法、装置、电子设备及存储介质,实现了在不暂停服务器运行的前提下,能够对数据库进行备份与恢复操作。The invention provides a database processing method, device, electronic equipment and storage medium, which realize backup and recovery operations on the database without suspending the operation of the server.

本发明提供一种数据库处理方法,应用于服务器,所述服务器包括待处理数据库,所述数据库处理方法包括:获取所述待处理数据库;在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。The present invention provides a database processing method, which is applied to a server. The server includes a database to be processed, and the database processing method includes: obtaining the database to be processed; when the system service of the server is running, creating and The file backup script corresponding to the database to be processed, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file; in the case of data loss in the database to be processed, based on the backup file , creating a database recovery script corresponding to the backup file, and constructing a recovery database corresponding to the database to be processed based on the database recovery script and the backup file, so that the server is running when the system service is running In case of recovery get the recovery database.

根据本发明提供的一种数据库处理方法,所述基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件,具体包括:基于所述文件备份脚本,确定与所述待处理数据库对应的备份命令;基于所述备份命令,对所述待处理数据库进行备份操作,得到备份文件。According to a database processing method provided by the present invention, performing a backup operation on the database to be processed based on the file backup script to obtain a backup file specifically includes: determining the database to be processed based on the file backup script A corresponding backup command; based on the backup command, perform a backup operation on the database to be processed to obtain a backup file.

根据本发明提供的一种数据库处理方法,所述基于所述备份命令,对所述待处理数据库进行备份操作,得到备份文件,具体包括:基于所述备份命令,对所述待处理数据库进行备份操作,得到不同备份时刻的备份文件;将所述备份时刻为最新备份时刻的备份文件,作为构建所述恢复数据库的备份文件。According to a database processing method provided by the present invention, performing a backup operation on the database to be processed based on the backup command to obtain a backup file specifically includes: performing backup on the database to be processed based on the backup command operation to obtain backup files at different backup times; and use the backup files whose backup time is the latest backup time as the backup files for constructing the recovery database.

根据本发明提供的一种数据库处理方法,在所述基于所述备份命令,对所述待处理数据库进行备份操作,得到备份文件之后,所述方法还包括:基于所述文件备份脚本,确定与所述备份文件对应的压缩命令;基于所述压缩命令,对所述备份文件进行压缩处理,得到压缩后备份文件;在所述基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本之前,所述方法还包括:对所述压缩后备份文件进行解压操作,得到所述备份文件。According to a database processing method provided by the present invention, after the backup operation is performed on the database to be processed based on the backup command to obtain the backup file, the method further includes: based on the file backup script, determining and A compression command corresponding to the backup file; based on the compression command, compress the backup file to obtain a compressed backup file; create a database recovery script corresponding to the backup file based on the backup file Before, the method further includes: decompressing the compressed backup file to obtain the backup file.

根据本发明提供的一种数据库处理方法,所述基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,具体包括:基于所述数据库恢复脚本,确定第一命令,其中,所述第一命令为关闭用户对所述待处理数据库的访问权限的命令;在基于所述第一命令成功关闭用户对所述待处理数据库的访问权限的情况下,基于所述数据库恢复脚本,确定第二命令,其中,所述第二命令为对所述待处理数据库进行更名操作的命令;在基于所述第二命令成功对所述待处理数据库进行更名操作的情况下,基于所述数据库恢复脚本,确定第三命令,其中,所述第三命令为创建空白数据库的命令,所述空白数据库用于承接所述备份文件;在基于所述第三命令成功创建所述空白数据库的情况下,基于所述数据库恢复脚本,确定第四命令,其中,所述第四命令为将所述备份文件导入至所述空白数据库的命令;在基于所述第四命令成功将所述备份文件导入至所述空白数据库的情况下,得到包含所述备份文件的所述空白数据库,并将所述包含所述备份文件的所述空白数据库作为所述恢复数据库。According to a database processing method provided by the present invention, the constructing a recovery database corresponding to the database to be processed based on the database recovery script and the backup file specifically includes: based on the database recovery script, determining the first command, wherein the first command is a command to close the user's access authority to the database to be processed; if the user's access authority to the database to be processed is successfully closed based on the first command, based on the The database recovery script is used to determine a second command, wherein the second command is a command for performing a rename operation on the database to be processed; in the case of successfully performing a rename operation on the database to be processed based on the second command, Based on the database recovery script, determine a third command, wherein the third command is a command to create a blank database, and the blank database is used to undertake the backup file; when the blank is successfully created based on the third command In the case of a database, a fourth command is determined based on the database recovery script, wherein the fourth command is a command for importing the backup file into the blank database; When the backup file is imported into the blank database, the blank database containing the backup file is obtained, and the blank database containing the backup file is used as the restoration database.

根据本发明提供的一种数据库处理方法,在所述得到包含所述备份文件的所述空白数据库之后,所述方法还包括:基于所述数据库恢复脚本,确定第五命令,其中,所述第五命令为删除所述待处理数据库和\或所述备份文件的命令;基于所述第五命令,删除所述待处理数据库和\或所述备份文件。According to a database processing method provided by the present invention, after the blank database containing the backup file is obtained, the method further includes: determining a fifth command based on the database recovery script, wherein the first The fifth command is a command to delete the database to be processed and/or the backup file; based on the fifth command, delete the database to be processed and/or the backup file.

根据本发明提供的一种数据库处理方法,在所述基于所述数据库恢复脚本,确定第二命令之后,所述方法还包括:在基于所述第二命令未成功对所述待处理数据库进行更名操作的情况下,重新开启用户对所述待处理数据库的访问权限,并停止确定第三命令的操作。According to a database processing method provided by the present invention, after the second command is determined based on the database recovery script, the method further includes: renaming the database to be processed based on the second command unsuccessfully In the case of an operation, re-enable the user's access right to the database to be processed, and stop the operation of determining the third command.

根据本发明提供的一种数据库处理方法,在所述基于所述数据库恢复脚本,确定第三命令之后,所述方法还包括:在基于所述第三命令未成功创建所述空白数据库的情况下,将所述待处理数据库的名称更改至原名称,以及重新开启用户对所述待处理数据库的访问权限,并停止确定第四命令的操作。According to a database processing method provided by the present invention, after the third command is determined based on the database recovery script, the method further includes: if the blank database is not successfully created based on the third command , changing the name of the database to be processed to the original name, re-enabling the user’s access right to the database to be processed, and stopping the operation of determining the fourth command.

根据本发明提供的一种数据库处理方法,在所述基于所述数据库恢复脚本,确定第四命令之后,所述方法还包括:在基于所述第四命令未成功将所述备份文件导入至所述空白数据库的情况下,将所述待处理数据库的名称更改至原名称、重新开启用户对所述待处理数据库的访问权限,以及删除所述空白数据库。According to a database processing method provided by the present invention, after the fourth command is determined based on the database recovery script, the method further includes: after unsuccessfully importing the backup file to the In the case of the blank database, change the name of the database to be processed to the original name, re-enable the user’s access authority to the database to be processed, and delete the blank database.

根据本发明提供的一种数据库处理方法,所述待处理数据库为集群模式的数据库。According to a database processing method provided by the present invention, the database to be processed is a cluster mode database.

根据本发明提供的一种数据库处理方法,所述服务器的系统服务由单体应用提供,或者由微服务提供。According to a database processing method provided by the present invention, the system service of the server is provided by a single application, or provided by a microservice.

本发明还提供一种数据库处理装置,应用于服务器,所述服务器包括待处理数据库,所述数据库处理装置包括:第一模块,用于获取所述待处理数据库;第二模块,用于在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;第三模块,用于在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。The present invention also provides a database processing device, which is applied to a server, the server includes a database to be processed, and the database processing device includes: a first module, used to acquire the database to be processed; a second module, used to When the system service of the server is running, create a file backup script corresponding to the database to be processed, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file; the third module uses In the case of data loss in the database to be processed, based on the backup file, create a database recovery script corresponding to the backup file, and based on the database recovery script and the backup file, construct a Processing the restoration database corresponding to the database, so that the server restores and obtains the restoration database when the system service is running.

本发明还提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如上述任一种所述的数据库处理方法。The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and operable on the processor. When the processor executes the program, the database processing described in any one of the above is realized. method.

本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述任一种所述的数据库处理方法。The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the database processing method described in any one of the above-mentioned methods is realized.

本发明还提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时实现如上述任一种所述的数据库处理方法。The present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the database processing method described in any one of the above is implemented.

本发明提供的数据库处理方法、装置、电子设备及存储介质,通过在服务器的系统服务处于运行的情况下,创建与待处理数据库对应的文件备份脚本,并基于文件备份脚本对待处理数据库进行备份操作以得到备份文件;在待处理数据库存在数据丢失的情况下,创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库,以使服务器在不暂停系统服务的情况下恢复得到恢复数据库。确保在不暂停服务器运行的前提下,能够对数据库进行备份与恢复操作,从而可以提高用户在使用过程中的体验感和满意度。The database processing method, device, electronic equipment and storage medium provided by the present invention create a file backup script corresponding to the database to be processed when the system service of the server is running, and perform a backup operation on the database to be processed based on the file backup script In order to obtain the backup file; in the case of data loss in the database to be processed, create a database recovery script corresponding to the backup file, and build a recovery database corresponding to the database to be processed based on the database recovery script and backup file, so that the server will Resume to restore the database in case of suspension of system services. Ensure that the database can be backed up and restored without suspending the operation of the server, so as to improve the user experience and satisfaction during use.

附图说明Description of drawings

为了更清楚地说明本发明或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the present invention or the technical solutions in the prior art, the accompanying drawings that need to be used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings in the following description are the present invention. For some embodiments of the invention, those skilled in the art can also obtain other drawings based on these drawings without creative effort.

图1是本发明提供的数据库处理方法的流程示意图之一;Fig. 1 is one of the flow diagrams of the database processing method provided by the present invention;

图2是本发明提供的基于文件备份脚本对待处理数据库进行备份操作,得到备份文件的流程示意图;Fig. 2 is that the database to be processed is carried out backup operation based on file backup script provided by the present invention, obtains the schematic flow chart of backup file;

图3是本发明提供的基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库的流程示意图;Fig. 3 is the schematic flow chart of constructing the recovery database corresponding to the database to be processed based on the database recovery script and the backup file provided by the present invention;

图4是本发明提供的数据库处理方法的流程示意图之二;Fig. 4 is the second schematic flow chart of the database processing method provided by the present invention;

图5是本发明提供的数据库处理装置的结构示意图;Fig. 5 is a schematic structural diagram of a database processing device provided by the present invention;

图6是本发明提供的电子设备的结构示意图。Fig. 6 is a schematic structural diagram of an electronic device provided by the present invention.

具体实施方式Detailed ways

为使本发明的目的、技术方案和优点更加清楚,下面将结合本发明中的附图,对本发明中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention , but not all examples. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

当前在对数据库进行备份与恢复的过程中,往往需要暂停服务器的运行,另外也不支持服务器为集群模式的数据库进行备份与恢复操作,这将影响用户在使用过程中的体验感。Currently, in the process of backing up and restoring the database, it is often necessary to suspend the operation of the server. In addition, the server does not support the backup and restoration of the database in cluster mode, which will affect the user experience during use.

本发明提供的数据库处理方法,可以在服务器正常运行的情况下,支持数据库的备份与恢复操作,服务器的系统服务由单体应用提供,或者由微服务提供。其中,单体应用是指系统中所有的功能、模块耦合在一个应用中的架构方式。也就是将所有的代码及功能都包含在一个WAR包中的项目组织方式。它的组成就是由多个模块(所有资源)打成一个war包,运行在一个服务器上,也就是一个进程去运行。微服务是将一个大的应用拆分成多个小的应用,这些小的应用相对独立,每个小的应用都有自己的容器,有自己的运行进程,这些小的应用通过网络协议(HTTP Rest)进行相互通信,所有的应用一起工作完成整个项目的业务。可以理解的是,一个系统服务可以由一个单体应用提供,也可以由多个微服务提供。The database processing method provided by the present invention can support backup and recovery operations of the database when the server is running normally, and the system service of the server is provided by a single application or microservice. Among them, the monolithic application refers to the architecture in which all the functions and modules in the system are coupled in one application. That is, the project organization method that includes all codes and functions in a WAR package. Its composition is that multiple modules (all resources) are packaged into a war package and run on a server, that is, a process to run. Microservice is to split a large application into multiple small applications. These small applications are relatively independent. Each small application has its own container and its own running process. These small applications communicate through the network protocol (HTTP Rest) communicate with each other, and all applications work together to complete the business of the entire project. It is understandable that a system service can be provided by a monolithic application or by multiple microservices.

图1是本发明提供的数据库处理方法的流程示意图之一。Fig. 1 is one of the schematic flowcharts of the database processing method provided by the present invention.

为了进一步介绍本发明提供的数据库处理方法,下面将结合图1进行说明。In order to further introduce the database processing method provided by the present invention, it will be described below in conjunction with FIG. 1 .

在本发明一示例性实施例中,数据库处理方法可以应用于服务器,在一示例中,服务器的系统服务由单体应用提供,或者由微服务提供。在应用过程中,服务器还可以对应有待处理数据库。结合图1可知,数据库处理方法可以包括步骤110至步骤130,下面将分别介绍各步骤。In an exemplary embodiment of the present invention, the database processing method may be applied to a server. In an example, the system service of the server is provided by a monolithic application or a microservice. During the application process, the server may also correspond to a database to be processed. It can be seen from FIG. 1 that the database processing method may include step 110 to step 130, and each step will be introduced below.

在步骤110中,获取待处理数据库。In step 110, the database to be processed is obtained.

在一种实施例中,待处理数据库可以认为是需要进行数据备份和恢复的数据库。其中,待处理数据库中可以包括多个数据。In an embodiment, the database to be processed may be considered as a database that needs to be backed up and restored. Wherein, the database to be processed may include multiple data.

在又一种实施例中,可以获取各个数据库的信息,例如数据库服务地址、数据库端口编号、数据库用户名等。进一步的,可以基于数据库的信息,自动找到需要进行备份与恢复处理的待处理数据库。In yet another embodiment, the information of each database may be acquired, such as database service address, database port number, database user name, and the like. Further, based on the information of the database, the database to be processed that needs to be backed up and restored can be automatically found.

在一示例中,待处理数据库可以是集群模式的数据库。在应用过程中,当服务器为与微服务对应的服务器的情况下,服务器可以是集群式的服务器,其中,集群式的服务器中的各服务器可以分别与集群模式的数据库中的各数据库对应。In an example, the database to be processed may be a cluster mode database. In the application process, when the server is a server corresponding to microservices, the server may be a clustered server, wherein each server in the clustered server may correspond to each database in the clustered database.

在步骤120中,在服务器的系统服务处于运行的情况下,创建与待处理数据库对应的文件备份脚本,并基于文件备份脚本对待处理数据库进行备份操作,得到备份文件。In step 120, when the system service of the server is running, a file backup script corresponding to the database to be processed is created, and a backup operation is performed on the database to be processed based on the file backup script to obtain a backup file.

在一种实施例中,在服务器的系统服务处于运行的情况下,可以创建与待处理数据库对应的文件备份脚本,进一步的,可以通过执行文件备份脚本对待处理数据库进行备份操作,以得到备份文件。In one embodiment, when the system service of the server is running, a file backup script corresponding to the database to be processed can be created, and further, the database to be processed can be backed up by executing the file backup script to obtain the backup file .

需要说明的是,可以在待处理数据库中没有丢掉数据的情况下,进行备份操作,从而可以得到数据完整的备份文件。It should be noted that the backup operation can be performed without losing data in the database to be processed, so that a backup file with complete data can be obtained.

其中,文件备份脚本的作用为执行数据库备份操作与压缩备份好的数据库文件。下面将基于文件备份脚本的作用对本发明提供的数据库处理方法进行说明。Wherein, the function of the file backup script is to execute the database backup operation and compress the backed up database file. The database processing method provided by the present invention will be described below based on the function of the file backup script.

在本发明一示例性实施例中,结合图2可知,基于文件备份脚本对待处理数据库进行备份操作,得到备份文件可以包括步骤210和步骤220,下面将分别介绍各步骤。In an exemplary embodiment of the present invention, referring to FIG. 2 , it can be known that performing a backup operation on the database to be processed based on the file backup script to obtain the backup file may include Step 210 and Step 220 , and each step will be introduced below.

在步骤210中,基于文件备份脚本,确定与待处理数据库对应的备份命令;In step 210, based on the file backup script, determine the backup command corresponding to the database to be processed;

在步骤220中,基于备份命令,对待处理数据库进行备份操作,得到备份文件。In step 220, based on the backup command, the database to be processed is backed up to obtain a backup file.

在一种实施例中,可以基于文件备份脚本,确定与待处理数据库对应的备份命令。其中,不同的待处理数据库对应的备份命令各不相同。进一步的,可以基于备份命令,对待处理数据库进行备份操作,得到备份文件。在本实施中,基于文件备份脚本可以在不影响服务器运行的情况下,自动得到备份文件,为对待处理数据库进行恢复操作打下基础。In an embodiment, the backup command corresponding to the database to be processed may be determined based on the file backup script. Wherein, the backup commands corresponding to different databases to be processed are different. Further, based on the backup command, the database to be processed can be backed up to obtain the backup file. In this implementation, the file-based backup script can automatically obtain the backup file without affecting the operation of the server, laying a foundation for the recovery operation of the database to be processed.

在本发明又一示例性实施例中,基于备份命令,对待处理数据库进行备份操作,得到备份文件还可以采用以下方式实现:In yet another exemplary embodiment of the present invention, based on the backup command, the database to be processed is backed up, and the backup file can also be obtained in the following manner:

基于备份命令,对待处理数据库进行备份操作,得到不同备份时刻的备份文件;Based on the backup command, the database to be processed is backed up to obtain backup files at different backup times;

将备份时刻为最新备份时刻的备份文件,作为构建恢复数据库的备份文件。The backup file whose backup time is the latest backup time is used as the backup file for constructing the recovery database.

在一种实施例中,可以基于备份命令,按照预设时间间隔多次对待处理数据库进行备份操作。由于随着时间的推移,不同备份时刻的待处理数据库中包含的数据可以是不相同的,可以理解的是,最新备份时刻的待处理数据库中包含的数据可以认为是最全面的。因此,在应用过程中,可以基于备份命令,对待处理数据库进行备份操作,得到不同备份时刻的备份文件;并将将备份时刻为最新备份时刻的备份文件,作为构建恢复数据库的备份文件。通过本实施例,可以确保备份文件是待处理数据库中包含的最新且最全面的数据,从而为准确对待处理数据库进行恢复打下基础。In an embodiment, based on the backup command, the database to be processed can be backed up multiple times at preset time intervals. Since the data contained in the database to be processed at different backup times may be different as time goes by, it can be understood that the data contained in the database to be processed at the latest backup time can be considered to be the most comprehensive. Therefore, in the application process, the database to be processed can be backed up based on the backup command to obtain backup files at different backup times; and the backup file whose backup time is the latest backup time can be used as the backup file for building the restored database. Through this embodiment, it can be ensured that the backup file is the latest and most comprehensive data contained in the database to be processed, thereby laying a foundation for accurate restoration of the database to be processed.

在又一种实施例中,还可以确认备份文件的版本与待处理数据库中数据所对应的版本是否相同,在备份文件的版本与待处理数据库中数据所对应的版本相同的情况下,基于备份文件,构建与待处理数据库对应的恢复数据库。In yet another embodiment, it can also be confirmed whether the version of the backup file is the same as the version corresponding to the data in the database to be processed. file to build a recovery database corresponding to the pending database.

在本发明又一示例性实施例中,继续以图2所述的实施例为例进行说明,在基于备份命令,对待处理数据库进行备份操作,得到备份文件(对应步骤220)之后,数据库处理方法还可以包括以下步骤:In yet another exemplary embodiment of the present invention, continue to take the embodiment described in Fig. 2 as an example to illustrate, based on the backup command, the database to be processed is backed up, and after the backup file (corresponding to step 220) is obtained, the database processing method The following steps may also be included:

基于文件备份脚本,确定与备份文件对应的压缩命令;Based on the file backup script, determine the compression command corresponding to the backup file;

基于压缩命令,对备份文件进行压缩处理,得到压缩后备份文件;Based on the compression command, the backup file is compressed to obtain the compressed backup file;

在基于备份文件,构建与待处理数据库对应的恢复数据库之前,数据库处理方法还可以包括以下步骤:Before constructing a recovery database corresponding to the database to be processed based on the backup file, the database processing method may further include the following steps:

对压缩后备份文件进行解压操作,得到备份文件。Decompress the compressed backup file to obtain the backup file.

在一种实施例中,可以基于文件备份脚本,确定与备份文件对应的压缩命令,并基于压缩命令,对备份文件进行压缩处理,得到压缩后备份文件。在本实施例中,通过将与待处理数据库对应的备份文件进行压缩处理以得到压缩后备份文件,可以在存储的过程中节约存储空间。In one embodiment, the compression command corresponding to the backup file may be determined based on the file backup script, and the backup file may be compressed based on the compression command to obtain the compressed backup file. In this embodiment, by compressing the backup file corresponding to the database to be processed to obtain the compressed backup file, storage space can be saved during the storage process.

进一步的,当监测到待处理数据库的数据丢失,即需要对待处理数据库进行恢复时,可以将存储的压缩后备份文件进行解压操作,以得到备份文件,再基于解压得到的备份文件构建与待处理数据库对应的恢复数据库。通过本实施例,在确保对待处理数据库进行有效恢复的前提下,可以节省备份文件的存储空间。Further, when the data loss of the database to be processed is detected, that is, when the database to be processed needs to be restored, the stored compressed backup file can be decompressed to obtain the backup file, and then based on the decompressed backup file, the construction and processing The database corresponds to the recovery database. Through this embodiment, the storage space of the backup file can be saved under the premise of ensuring effective recovery of the database to be processed.

在步骤130中,在待处理数据库存在数据丢失的情况下,基于备份文件,创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库,以使服务器在系统服务处于运行的情况下恢复得到恢复数据库。In step 130, in the case of data loss in the database to be processed, create a database recovery script corresponding to the backup file based on the backup file, and build a recovery database corresponding to the database to be processed based on the database recovery script and the backup file, to Restoring the server with system services running gets the recovery database.

需要说明的是,对待处理数据库进行备份操作以得到备份文件可以是在待处理数据库未发生数据丢失的情况下进行的。在应用过程中,当监测到待处理数据库的数据丢失时,即需要对待处理数据库进行恢复操作时,在该场景下,可以基于备份文件,构建与待处理数据库对应的恢复数据库。其中,恢复数据库包含的数据为备份文件。通过本实施例,可以在不影响服务器运行的前提下,实现对待处理数据库的恢复操作。It should be noted that the backup operation of the database to be processed to obtain the backup file may be performed under the condition that no data loss occurs in the database to be processed. During the application process, when the data loss of the database to be processed is detected, that is, when the database to be processed needs to be restored, in this scenario, the recovery database corresponding to the database to be processed can be constructed based on the backup file. Wherein, the data included in the recovery database is a backup file. Through this embodiment, the recovery operation of the database to be processed can be realized without affecting the operation of the server.

在本发明又一示例性实施例中,可以创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库。In yet another exemplary embodiment of the present invention, a database recovery script corresponding to the backup file may be created, and a recovery database corresponding to the database to be processed may be constructed based on the database recovery script and the backup file.

在一种实施例中,可以获取压缩后数据库备份文件(对应压缩后备份文件),再解压压缩后数据库备份文件,以得到能够进行恢复数据库构建的备份文件。In one embodiment, the compressed database backup file (corresponding to the compressed backup file) may be obtained, and then the compressed database backup file may be decompressed to obtain a backup file capable of constructing a restored database.

进一步的,创建与备份文件对应的数据库恢复脚本,并执行数据库恢复脚本,从而可以构建与待处理数据库对应的恢复数据库。其中,数据库恢复脚本的主要作用包括关闭用户对待处理数据库的访问权限、将待处理数据库进行更名操作、创建空白数据库、基于空白数据库进行恢复得到恢复数据库,以及删除待处理数据库和备份文件等。Further, a database recovery script corresponding to the backup file is created and executed, so that a recovery database corresponding to the database to be processed can be constructed. Among them, the main functions of the database recovery script include closing the user’s access to the database to be processed, renaming the database to be processed, creating a blank database, restoring the database based on the blank database, and deleting the database to be processed and backup files.

本发明提供的本发明提供的数据库处理方法,通过在服务器的系统服务处于运行的情况下,创建与待处理数据库对应的文件备份脚本,并基于文件备份脚本对待处理数据库进行备份操作以得到备份文件;在待处理数据库存在数据丢失的情况下,创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库,以使服务器在不暂停系统服务的情况下恢复得到恢复数据库。确保在不暂停服务器运行的前提下,能够对数据库进行备份与恢复操作,从而可以提高用户在使用过程中的体验感和满意度。The database processing method provided by the present invention is to create a file backup script corresponding to the database to be processed when the system service of the server is running, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file ; In the case of data loss in the database to be processed, create a database recovery script corresponding to the backup file, and build a recovery database corresponding to the database to be processed based on the database recovery script and backup file, so that the server does not suspend system services. In case recovery gets the recovery database. Ensure that the database can be backed up and restored without suspending the operation of the server, so as to improve the user experience and satisfaction during use.

本发明将结合下述实施例对执行数据库恢复脚本的过程进行说明。The present invention will describe the process of executing a database recovery script in conjunction with the following embodiments.

图3是本发明提供的基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库的流程示意图。FIG. 3 is a schematic flowchart of constructing a recovery database corresponding to the database to be processed based on the database recovery script and backup files provided by the present invention.

在本发明一示例性实施例中,结合图3可知,基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库可以包括步骤310至步骤350,下面将分别介绍各步骤。In an exemplary embodiment of the present invention, referring to FIG. 3, it can be seen that based on the database recovery script and the backup file, constructing the recovery database corresponding to the database to be processed may include steps 310 to 350, and each step will be introduced below.

在步骤310中,基于数据库恢复脚本,确定第一命令,其中,第一命令为关闭用户对待处理数据库的访问权限的命令。In step 310, based on the database recovery script, a first command is determined, wherein the first command is a command to close the user's access right to the database to be processed.

在步骤320中,在基于第一命令成功关闭用户对所述待处理数据库的访问权限的情况下,基于数据库恢复脚本,确定第二命令,其中,第二命令为对待处理数据库进行更名操作的命令。In step 320, in the case that the user's access authority to the database to be processed is successfully closed based on the first command, a second command is determined based on the database recovery script, wherein the second command is a command for performing a rename operation on the database to be processed .

在一种实施例中,可以根据数据库恢复脚本,确定第一命令,其中,第一命令是关闭用户对待处理数据库的访问权限的命令。在应用过程中,通过第一命令成功关闭用户对待处理数据库的访问权限,可以确保用户暂时无法访问待处理数据库,为成功对待处理数据库进行恢复打下基础。In an embodiment, the first command may be determined according to the database recovery script, where the first command is a command for closing the user's access right to the database to be processed. During the application process, successfully closing the user's access authority to the database to be processed through the first command can ensure that the user cannot access the database to be processed temporarily, laying a foundation for successful recovery of the database to be processed.

进一步的,在基于第一命令成功关闭用户对待处理数据库的访问权限的情况下,可以基于数据库恢复脚本,确定第二命令,其中,第二命令为对待处理数据库进行更名操作的命令。可以理解的是,成功对待处理数据库进行更名操作也是实现对待处理数据库进行恢复操作的基础。Further, in the case that the user's access right to the database to be processed is successfully closed based on the first command, the second command may be determined based on the database recovery script, wherein the second command is a command for performing a rename operation on the database to be processed. It can be understood that the successful operation of renaming the database to be processed is also the basis for realizing the recovery operation of the database to be processed.

在步骤330中,在基于第二命令成功对待处理数据库进行更名操作的情况下,基于数据库恢复脚本,确定第三命令,其中,第三命令为创建空白数据库的命令,空白数据库用于承接备份文件。In step 330, in the case that the database to be processed is successfully renamed based on the second command, a third command is determined based on the database recovery script, wherein the third command is a command to create a blank database, and the blank database is used to carry backup files .

在步骤340中,在基于第三命令成功创建空白数据库的情况下,基于数据库恢复脚本,确定第四命令,其中,第四命令为将备份文件导入至空白数据库的命令。In step 340, if the blank database is successfully created based on the third command, a fourth command is determined based on the database recovery script, wherein the fourth command is a command for importing the backup file into the blank database.

在步骤350中,在基于第四命令成功将备份文件导入至空白数据库的情况下,得到包含备份文件的空白数据库,并将包含备份文件的空白数据库作为恢复数据库。In step 350, if the backup file is successfully imported into the blank database based on the fourth command, a blank database containing the backup file is obtained, and the blank database containing the backup file is used as a recovery database.

在一种实施例中,在基于第二命令成功对待处理数据库进行更名操作的情况下,可以基于数据库恢复脚本,确定第三命令,其中,第三命令为创建空白数据库的命令,空白数据库用于承接备份文件。In one embodiment, in the case that the database to be processed is successfully renamed based on the second command, the third command can be determined based on the database recovery script, wherein the third command is a command for creating a blank database, and the blank database is used for Undertake backup files.

在应用过程中,在成功对待处理数据库进行更名操作的前提下,可以新建一个空白数据库,其中,空白数据库中暂时不含有任何数据,而是用于承接备份文件,可以理解的是,包含备份文件的空白数据库可以作为恢复数据库。During the application process, under the premise of successfully renaming the database to be processed, a blank database can be created. The blank database does not contain any data temporarily, but is used to undertake the backup file. It is understandable that the backup file is included The blank database can be used as a recovery database.

进一步的,在基于第三命令成功创建空白数据库的情况下,可以基于数据库恢复脚本,确定第四命令,其中,第四命令为将备份文件导入至空白数据库的命令。在应用过程中,可以进行恢复数据库的操作,将备份文件导入至空白数据库,以得到包含备份文件的空白数据库,并将包含备份文件的空白数据库作为恢复数据库。通过本实施例可以得到与待处理数据库对应的恢复数据库,其中,恢复数据库中包含备份文件。Further, in the case that the blank database is successfully created based on the third command, the fourth command may be determined based on the database restoration script, wherein the fourth command is a command for importing the backup file into the blank database. During the application process, the operation of restoring the database can be performed, and the backup file can be imported into the blank database to obtain a blank database containing the backup file, and the blank database containing the backup file can be used as the recovery database. Through this embodiment, a recovery database corresponding to the database to be processed can be obtained, wherein the recovery database includes backup files.

在本发明又一示例性实施例中,继续以图3所述的实施例为例进行说明,在得到包含备份文件的空白数据库(对应步骤350)之后,数据库处理方法还可以包括以下步骤:In yet another exemplary embodiment of the present invention, continue to take the embodiment described in Figure 3 as an example to illustrate, after obtaining the blank database (corresponding to step 350) that contains the backup file, the database processing method may also include the following steps:

基于数据库恢复脚本,确定第五命令,其中,第五命令为删除待处理数据库和\或备份文件的命令;Based on the database recovery script, the fifth command is determined, wherein the fifth command is a command to delete the database to be processed and/or the backup file;

基于第五命令,删除待处理数据库和\或备份文件。Based on the fifth command, delete the pending database and/or backup file.

在一种实施例中,为了节约服务器系统的存储空间,在成功恢复待处理数据库后,还可以基于数据库恢复脚本,确定第五命令,并基于第五命令,删除待处理数据库和\或备份文件。其中,第五命令为删除待处理数据库和\或备份文件的命令。In one embodiment, in order to save the storage space of the server system, after successfully restoring the database to be processed, the fifth command can also be determined based on the database recovery script, and based on the fifth command, the database to be processed and/or the backup file can be deleted . Wherein, the fifth command is a command to delete the database to be processed and/or the backup file.

在本发明又一示例性实施例中,在基于数据库恢复脚本,确定第二命令(对应步骤320)之后,数据库处理方法还可以包括以下步骤:In yet another exemplary embodiment of the present invention, after determining the second command (corresponding to step 320) based on the database recovery script, the database processing method may further include the following steps:

在基于第二命令未成功对待处理数据库进行更名操作的情况下,重新开启用户对待处理数据库的访问权限,并停止确定第三命令的操作。In the case that the database to be processed is not successfully renamed based on the second command, the user's access right to the database to be processed is reopened, and the operation of determining the third command is stopped.

在一种实施例中,当未成功对待处理数据库进行更名操作时,需要重新开启用户对待处理数据库的访问权限,从而可以避免用户无法访问数据库,避免影响用户的体验感。进一步的,由于对待处理数据库进行更名操作是对待处理数据库进行恢复的首要条件,当未成功对待处理数据库进行更名操作时,则不再进行后续步骤的操作,例如停止确定第三命令的操作。In one embodiment, when the operation of renaming the database to be processed fails, the user's access right to the database to be processed needs to be re-enabled, so as to prevent the user from being unable to access the database and avoid affecting the user's experience. Further, since renaming the database to be processed is the primary condition for restoring the database to be processed, if the database to be processed is not successfully renamed, operations in subsequent steps will not be performed, such as stopping the operation of determining the third command.

在本发明又一示例性实施例中,在基于数据库恢复脚本,确定第三命令(对应步骤330)之后,数据库处理方法还可以包括以下步骤:In yet another exemplary embodiment of the present invention, after determining the third command (corresponding to step 330) based on the database recovery script, the database processing method may further include the following steps:

在基于第三命令未成功创建空白数据库的情况下,将待处理数据库的名称更改至原名称,以及重新开启用户对待处理数据库的访问权限,并停止确定第四命令的操作。If the blank database is not successfully created based on the third command, the name of the database to be processed is changed to the original name, and the user's access right to the database to be processed is reopened, and the operation of determining the fourth command is stopped.

在一种实施例中,当未成功创建空白数据库时,需要将待处理数据库的名称更改至原名称,以及重新开启用户对待处理数据库的访问权限,从而可以避免用户无法访问数据库,避免影响用户的体验感。进一步的,由于成功创建空白数据库是对待处理数据库进行恢复的必要条件,当未成功创建空白数据库时,则不再进行后续步骤的操作,例如停止确定第四命令的操作。In one embodiment, when the blank database is not successfully created, the name of the database to be processed needs to be changed to the original name, and the user's access authority to the database to be processed needs to be re-opened, thereby preventing the user from being unable to access the database and avoiding affecting the user's sense of experience. Further, since the successful creation of a blank database is a necessary condition for restoring the database to be processed, when the blank database is not successfully created, the operation of the subsequent steps is not performed, for example, the operation of determining the fourth command is stopped.

在本发明又一示例性实施例中,在基于数据库恢复脚本,确定第四命令(对应步骤340)之后,数据库处理方法还可以包括以下步骤:In yet another exemplary embodiment of the present invention, after determining the fourth command (corresponding to step 340) based on the database restoration script, the database processing method may further include the following steps:

在基于第四命令未成功将备份文件导入至空白数据库的情况下,将待处理数据库的名称更改至原名称、重新开启用户对待处理数据库的访问权限,以及删除空白数据库。In the event that the backup file is not successfully imported into the blank database based on the fourth command, the name of the database to be processed is changed to the original name, the user's access right to the database to be processed is reopened, and the blank database is deleted.

在一种实施例中,当未成功将备份文件导入至空白数据库时,需要将待处理数据库的名称更改至原名称、重新开启用户对待处理数据库的访问权限,以及删除空白数据库,从而可以避免用户无法访问数据库,避免影响用户的体验感。In one embodiment, when the backup file is not successfully imported into the blank database, it is necessary to change the name of the database to be processed to the original name, re-enable the user's access to the database to be processed, and delete the blank database, so that users can avoid Unable to access the database, so as not to affect the user experience.

图4是本发明提供的数据库处理方法的流程示意图之二。Fig. 4 is the second schematic flow diagram of the database processing method provided by the present invention.

为了进一步介绍本发明提供的数据库处理方法,下面将结合图4进行说明。In order to further introduce the database processing method provided by the present invention, it will be described below in conjunction with FIG. 4 .

在本发明一示例性实施例中,结合图4可知,数据库处理方法可以包括步骤401至步骤417,下面将分别介绍各步骤。In an exemplary embodiment of the present invention, it can be known with reference to FIG. 4 that the database processing method may include step 401 to step 417, and each step will be introduced respectively below.

在步骤401中,获取数据库备份文件。In step 401, a database backup file is acquired.

在一种实施例中,可以创建与待处理数据库对应的文件备份脚本,并基于文件备份脚本对待处理数据库进行备份操作,得到备份文件(对应数据库备份文件)。进一步的,还可以对数据库备份文件进行压缩,得到压缩后备份文件,从而可以在存储的过程中节约存储空间。In one embodiment, a file backup script corresponding to the database to be processed may be created, and a backup operation is performed on the database to be processed based on the file backup script to obtain a backup file (corresponding to a database backup file). Furthermore, the database backup file can also be compressed to obtain a compressed backup file, thereby saving storage space during storage.

在步骤402中,解压数据库备份文件。In step 402, the database backup file is decompressed.

在步骤403中,获取数据库备份信息。In step 403, database backup information is acquired.

在步骤404中,执行恢复脚本。In step 404, the restore script is executed.

在一种实施例中,当需要对待处理数据库进行恢复操作时,即监测到待处理数据库存在数据缺失的情况时,可以对压缩后备份文件进行解压处理,以得到数据库备份文件。进一步的,可以获取数据库备份信息,例如数据库备份文件的备份时间、版本等,在数据库备份文件的备份时间为最新时间且版本与待处理数据库对应的情况下,可以执行恢复脚本操作。其中,数恢复脚本的作用主要包含关闭用户对数据库(对应待处理数据库)访问权限,将现有数据库(对应待处理数据库)更名操作,创建恢复数据库(对应空白数据库),进行恢复数据库,删除现有数据库备份(对应备份文件)等。In one embodiment, when the database to be processed needs to be restored, that is, when data loss in the database to be processed is detected, the compressed backup file may be decompressed to obtain the database backup file. Further, the database backup information can be obtained, such as the backup time and version of the database backup file, and when the backup time of the database backup file is the latest time and the version corresponds to the database to be processed, the recovery script operation can be executed. Among them, the role of the data recovery script mainly includes closing the user’s access to the database (corresponding to the database to be processed), renaming the existing database (corresponding to the database to be processed), creating a recovery database (corresponding to a blank database), restoring the database, and deleting the existing database. There are database backups (corresponding to backup files), etc.

在步骤405中,关闭用户对数据库访问权限。In step 405, the user's access to the database is disabled.

在一种实施例中,可以关闭用户对数据库的访问权限,使得其他用户暂时无法访问数据库。从而可以确保待处理数据库恢复操作的顺利进行。In one embodiment, the user's access authority to the database can be closed, so that other users cannot access the database temporarily. Thereby, the smooth progress of the pending database recovery operation can be ensured.

在步骤406中,在成功关闭用户对数据库访问权限的情况下,将现有数据库更名操作。In step 406, if the user's access right to the database is successfully closed, the existing database is renamed.

在步骤407中,在未成功关闭用户对数据库访问权限的情况下,开启用户对数据库访问权限。In step 407, if the user's access right to the database is not successfully closed, the user's access right to the database is enabled.

在一种实施例中,将现有的数据库(对应待处理数据库)进行更名操作,更名以防恢复数据库失败。若更名操作失败,则重新开启用户对数据库访问权限,结束恢复操作,从而不会影响用户访问数据库,提高用户在使用过程中的体验感和满意度。In one embodiment, the existing database (corresponding to the database to be processed) is renamed to prevent failure in restoring the database. If the renaming operation fails, the user's access to the database will be re-opened, and the recovery operation will end, so that the user's access to the database will not be affected, and the user's experience and satisfaction during use will be improved.

在步骤408中,在成功将现有数据库更名操作的情况下,创建恢复数据库。In step 408, in case of a successful rename operation of the existing database, a recovery database is created.

在步骤409中,在未成功将现有数据库更名操作的情况下,将数据库名称改回。In step 409, if the operation of renaming the existing database is unsuccessful, the database name is changed back.

在步骤410中,开启用户对数据库访问权限。In step 410, the user's access right to the database is enabled.

在一种实施例中,若更名操作成功,则新建恢复数据库(对应空白数据库),用于承接备份数据库文件的数据。若新建恢复数据库(空白数据库)失败,则将数据库名称改回,重新开启用户对数据库访问权限,结束恢复操作。In one embodiment, if the renaming operation is successful, a recovery database (corresponding to a blank database) is created to take over the data of the backup database file. If the new recovery database (blank database) fails, then change the database name back, re-enable the user's access to the database, and end the recovery operation.

在步骤411中,在成功创建恢复数据库的情况下,进行恢复数据库操作。In step 411, if the recovery database is created successfully, the recovery database operation is performed.

在步骤412中,在未成功创建恢复数据库的情况下,删除创建的恢复数据库。In step 412, if the recovery database is not created successfully, the created recovery database is deleted.

在步骤413中,将数据库名称改回。In step 413, the database name is changed back.

在步骤414中,开启用户对数据库访问权限。In step 414, the user's access right to the database is enabled.

在一种实施例中,若新建恢复数据库(对应空白数据库)成功,则进行恢复数据库操作,将备份数据库文件的数据导入新建的数据库(对应空白数据库)。若恢复数据库操作失败,则删除创建的恢复数据库(对应空白数据库),将数据库名称改回,重新开启用户对数据库访问权限。In one embodiment, if the recovery database (corresponding to the blank database) is successfully created, the database recovery operation is performed, and the data of the backup database file is imported into the newly created database (corresponding to the blank database). If the restore database operation fails, delete the created restore database (corresponding to a blank database), change the database name back, and re-enable the user's access to the database.

在步骤415中,在成功进行恢复数据库操作的情况下,删除现有数据库备份。In step 415, in case of a successful restore database operation, the existing database backup is deleted.

在步骤416中,在未成功删除现有数据库备份的情况下,结束进程。In step 416, in the event that the existing database backup was not successfully deleted, the process ends.

在步骤417中,在成功删除现有数据库备份的情况下,结束进程。In step 417, in case the existing database backup is successfully deleted, the process ends.

在一种实施例中,若恢复数据操作成功,则删除现有数据库的备份(对应待处理数据库),去除残留数据库备份文件(对应备份文件)。若删除现有数据库备份失败,则再次尝试删除现有数据库备份操作,失败与否都结束操作,返回删除现有数据库备份操作失败的信息。若删除现有数据库备份成功,则返回删除现有数据库备份操作成功的信息,结束操作。In one embodiment, if the operation of restoring data is successful, the backup of the existing database (corresponding to the database to be processed) is deleted, and the residual database backup file (corresponding to the backup file) is removed. If the deletion of the existing database backup fails, try to delete the existing database backup operation again, and end the operation whether it fails or not, and return the information that the deletion of the existing database backup operation failed. If the deletion of the existing database backup is successful, then return the message that the operation of deleting the existing database backup is successful, and end the operation.

根据上述描述可知,本发明提供的本发明提供的数据库处理方法,通过在服务器的系统服务处于运行的情况下,创建与待处理数据库对应的文件备份脚本,并基于文件备份脚本对待处理数据库进行备份操作以得到备份文件;在待处理数据库存在数据丢失的情况下,创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库,以使服务器在不暂停系统服务的情况下恢复得到恢复数据库。确保在不暂停服务器运行的前提下,能够对数据库进行备份与恢复操作,从而可以提高用户在使用过程中的体验感和满意度。According to the above description, it can be seen that the database processing method provided by the present invention, by creating a file backup script corresponding to the database to be processed when the system service of the server is running, and backing up the database to be processed based on the file backup script operation to obtain the backup file; in the case of data loss in the database to be processed, create a database recovery script corresponding to the backup file, and build a recovery database corresponding to the database to be processed based on the database recovery script and backup file, so that the server Restoring restores the database without suspending system services. Ensure that the database can be backed up and restored without suspending the operation of the server, so as to improve the user experience and satisfaction during use.

基于相同的构思,本发明还提供一种数据库处理装置。Based on the same idea, the present invention also provides a database processing device.

下面对本发明提供的数据库处理装置进行描述,下文描述的数据库处理装置与上文描述的数据库处理方法可相互对应参照。The database processing device provided by the present invention is described below, and the database processing device described below and the database processing method described above can be referred to in correspondence.

图5是本发明提供的数据库处理装置的结构示意图。Fig. 5 is a schematic structural diagram of a database processing device provided by the present invention.

在本发明一示例性实施例中,数据库处理装置应用于服务器,所述服务器包括待处理数据库。结合图5可知,数据库处理装置可以包括第一模块510、第二模块520和第三模块530,下面将分别介绍各步骤。In an exemplary embodiment of the present invention, the database processing device is applied to a server, and the server includes a database to be processed. As can be seen from FIG. 5 , the database processing apparatus may include a first module 510 , a second module 520 and a third module 530 , and each step will be introduced below.

第一模块510,可以被配置为用于获取待处理数据库;The first module 510 may be configured to acquire the database to be processed;

第二模块520,可以被配置为用于在服务器的系统服务处于运行的情况下,创建与待处理数据库对应的文件备份脚本,并基于文件备份脚本对待处理数据库进行备份操作,得到备份文件;The second module 520 may be configured to create a file backup script corresponding to the database to be processed when the system service of the server is running, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file;

第三模块530,可以被配置为用于在待处理数据库存在数据丢失的情况下,基于备份文件,创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库,以使服务器在系统服务处于运行的情况下恢复得到恢复数据库。The third module 530 may be configured to create a database recovery script corresponding to the backup file based on the backup file when there is data loss in the database to be processed, and to construct a database corresponding to the database to be processed based on the database recovery script and the backup file. The corresponding recovery database, so that the server recovers the recovery database while the system service is running.

在本发明一示例性实施例中,第二模块520可以采用以下方式实现基于文件备份脚本对待处理数据库进行备份操作,得到备份文件:In an exemplary embodiment of the present invention, the second module 520 can implement the backup operation based on the file backup script to the database to be processed in the following manner to obtain the backup file:

基于文件备份脚本,确定与待处理数据库对应的备份命令;Based on the file backup script, determine the backup command corresponding to the database to be processed;

基于备份命令,对待处理数据库进行备份操作,得到备份文件。Based on the backup command, the database to be processed is backed up to obtain a backup file.

在本发明一示例性实施例中,第二模块520可以采用以下方式实现基于备份命令,对待处理数据库进行备份操作,得到备份文件:In an exemplary embodiment of the present invention, the second module 520 can implement the backup operation based on the backup command to obtain the backup file based on the backup command in the following manner:

基于备份命令,对待处理数据库进行备份操作,得到不同备份时刻的备份文件;Based on the backup command, the database to be processed is backed up to obtain backup files at different backup times;

将备份时刻为最新备份时刻的备份文件,作为构建恢复数据库的备份文件。The backup file whose backup time is the latest backup time is used as the backup file for constructing the recovery database.

在本发明一示例性实施例中,第二模块520还可以被配置为用于:In an exemplary embodiment of the present invention, the second module 520 may also be configured to:

基于文件备份脚本,确定与备份文件对应的压缩命令;Based on the file backup script, determine the compression command corresponding to the backup file;

基于压缩命令,对备份文件进行压缩处理,得到压缩后备份文件;Based on the compression command, the backup file is compressed to obtain the compressed backup file;

对压缩后备份文件进行解压操作,得到备份文件。Decompress the compressed backup file to obtain the backup file.

在本发明一示例性实施例中,第三模块530可以采用以下方式实现基于备份文件,构建与待处理数据库对应的恢复数据库:In an exemplary embodiment of the present invention, the third module 530 may implement, based on the backup file, building a recovery database corresponding to the database to be processed in the following manner:

创建与备份文件对应的数据库恢复脚本,并基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库。Create a database recovery script corresponding to the backup file, and build a recovery database corresponding to the database to be processed based on the database recovery script and the backup file.

在本发明一示例性实施例中,第三模块530可以采用以下方式实现基于数据库恢复脚本和备份文件,构建与待处理数据库对应的恢复数据库:In an exemplary embodiment of the present invention, the third module 530 can use the following method to realize building a recovery database corresponding to the database to be processed based on the database recovery script and the backup file:

基于数据库恢复脚本,确定第一命令,其中,第一命令为关闭用户对待处理数据库的访问权限的命令;Based on the database recovery script, the first command is determined, wherein the first command is a command to close the user's access authority to the database to be processed;

在基于第一命令成功关闭用户对待处理数据库的访问权限的情况下,基于数据库恢复脚本,确定第二命令,其中,第二命令为对待处理数据库进行更名操作的命令;In the case that the user's access authority to the database to be processed is successfully closed based on the first command, a second command is determined based on the database recovery script, wherein the second command is a command for renaming the database to be processed;

在基于第二命令成功对待处理数据库进行更名操作的情况下,基于数据库恢复脚本,确定第三命令,其中,第三命令为创建空白数据库的命令,空白数据库用于承接备份文件;In the case of successfully renaming the database to be processed based on the second command, a third command is determined based on the database recovery script, wherein the third command is a command to create a blank database, and the blank database is used to accept backup files;

在基于第三命令成功创建空白数据库的情况下,基于数据库恢复脚本,确定第四命令,其中,第四命令为将备份文件导入至空白数据库的命令;In the case of successfully creating a blank database based on the third command, a fourth command is determined based on the database recovery script, wherein the fourth command is an order for importing the backup file into the blank database;

在基于第四命令成功将备份文件导入至空白数据库的情况下,得到包含备份文件的空白数据库,并将包含备份文件的空白数据库作为恢复数据库。If the backup file is successfully imported into the blank database based on the fourth command, a blank database containing the backup file is obtained, and the blank database containing the backup file is used as a recovery database.

在本发明一示例性实施例中,第三模块530还可以被配置为用于:In an exemplary embodiment of the present invention, the third module 530 may also be configured to:

基于数据库恢复脚本,确定第五命令,其中,第五命令为删除待处理数据库和\或备份文件的命令;Based on the database recovery script, the fifth command is determined, wherein the fifth command is a command to delete the database to be processed and/or the backup file;

基于第五命令,删除待处理数据库和\或备份文件。Based on the fifth command, delete the pending database and/or backup file.

在本发明一示例性实施例中,第三模块530还可以被配置为用于:In an exemplary embodiment of the present invention, the third module 530 may also be configured to:

在基于第二命令未成功对待处理数据库进行更名操作的情况下,重新开启用户对待处理数据库的访问权限,并停止确定第三命令的操作。In the case that the database to be processed is not successfully renamed based on the second command, the user's access right to the database to be processed is reopened, and the operation of determining the third command is stopped.

在本发明一示例性实施例中,第三模块530还可以被配置为用于:In an exemplary embodiment of the present invention, the third module 530 may also be configured to:

在基于第三命令未成功创建空白数据库的情况下,将待处理数据库的名称更改至原名称,以及重新开启用户对待处理数据库的访问权限,并停止确定第四命令的操作。If the blank database is not successfully created based on the third command, the name of the database to be processed is changed to the original name, and the user's access right to the database to be processed is reopened, and the operation of determining the fourth command is stopped.

在本发明一示例性实施例中,第三模块530还可以被配置为用于:In an exemplary embodiment of the present invention, the third module 530 may also be configured to:

在基于第四命令未成功将备份文件导入至空白数据库的情况下,将待处理数据库的名称更改至原名称、重新开启用户对待处理数据库的访问权限,以及删除空白数据库。In the event that the backup file is not successfully imported into the blank database based on the fourth command, the name of the database to be processed is changed to the original name, the user's access right to the database to be processed is reopened, and the blank database is deleted.

在本发明一示例性实施例中,待处理数据库为集群模式的数据库。In an exemplary embodiment of the present invention, the database to be processed is a cluster mode database.

在本发明一示例性实施例中,服务器的系统服务由单体应用提供,或者由微服务提供。In an exemplary embodiment of the present invention, the system service of the server is provided by a monolithic application, or provided by a microservice.

图6示例了一种电子设备的实体结构示意图,如图6所示,该电子设备可以包括:处理器(processor)610、通信接口(Communications Interface)620、存储器(memory)630和通信总线640,其中,处理器610,通信接口620,存储器630通过通信总线640完成相互间的通信。处理器610可以调用存储器630中的逻辑指令,以执行数据库处理方法,所述数据库处理方法应用于服务器,所述服务器包括待处理数据库,所述方法包括:获取所述待处理数据库;在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。FIG. 6 illustrates a schematic diagram of the physical structure of an electronic device. As shown in FIG. 6, the electronic device may include: a processor (processor) 610, a communication interface (Communications Interface) 620, a memory (memory) 630 and a communication bus 640, Wherein, the processor 610 , the communication interface 620 , and the memory 630 communicate with each other through the communication bus 640 . The processor 610 may call the logic instructions in the memory 630 to execute a database processing method, the database processing method is applied to a server, the server includes a database to be processed, and the method includes: acquiring the database to be processed; When the system service of the server is running, create a file backup script corresponding to the database to be processed, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file; in the database to be processed In the case of data loss, based on the backup file, create a database recovery script corresponding to the backup file, and based on the database recovery script and the backup file, construct a recovery database corresponding to the database to be processed, The server recovers to obtain the recovery database when the system service is running.

此外,上述的存储器630中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the logic instructions in the above-mentioned memory 630 may be implemented in the form of software functional units and when sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes. .

另一方面,本发明还提供一种计算机程序产品,所述计算机程序产品包括计算机程序,计算机程序可存储在非暂态计算机可读存储介质上,所述计算机程序被处理器执行时,计算机能够执行上述各方法所提供的数据库处理方法,所述数据库处理方法应用于服务器,所述服务器包括待处理数据库,所述方法包括:获取所述待处理数据库;在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can Executing the database processing method provided by each of the above methods, the database processing method is applied to a server, the server includes a database to be processed, and the method includes: obtaining the database to be processed; when the system service of the server is running In this case, create a file backup script corresponding to the database to be processed, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file; when there is data loss in the database to be processed, Create a database recovery script corresponding to the backup file based on the backup file, and construct a recovery database corresponding to the database to be processed based on the database recovery script and the backup file, so that the server is in the When the system service is running, recover to obtain the recovery database.

又一方面,本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各方法提供的数据库处理方法,所述数据库处理方法应用于服务器,所述服务器包括待处理数据库,所述方法包括:获取所述待处理数据库;在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it is implemented to execute the database processing method provided by the above methods, and the database processing The method is applied to a server, and the server includes a database to be processed, and the method includes: obtaining the database to be processed; when the system service of the server is running, creating a file backup script corresponding to the database to be processed , and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file; in the case of data loss in the database to be processed, create a database corresponding to the backup file based on the backup file Restoring a script, and constructing a restoration database corresponding to the database to be processed based on the database restoration script and the backup file, so that the server restores and obtains the restoration database when the system service is running.

以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network elements. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. It can be understood and implemented by those skilled in the art without any creative effort.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。Through the above description of the implementations, those skilled in the art can clearly understand that each implementation can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the prior art can be embodied in the form of software products, and the computer software products can be stored in computer-readable storage media, such as ROM/RAM, magnetic discs, optical discs, etc., including several instructions to make a computer device (which may be a personal computer, server, or network device, etc.) execute the methods described in various embodiments or some parts of the embodiments.

进一步可以理解的是,本发明实施例中尽管在附图中以特定的顺序描述操作,但是不应将其理解为要求按照所示的特定顺序或是串行顺序来执行这些操作,或是要求执行全部所示的操作以得到期望的结果。在特定环境中,多任务和并行处理可能是有利的。It can be further understood that although operations are described in a specific order in the drawings in the embodiments of the present invention, it should not be understood as requiring that these operations be performed in the specific order shown or in a serial order, or that Do all of the operations shown to get the desired result. In certain circumstances, multitasking and parallel processing may be advantageous.

最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still be Modifications are made to the technical solutions described in the foregoing embodiments, or equivalent replacements are made to some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims (14)

1.一种数据库处理方法,其特征在于,应用于服务器,所述服务器包括待处理数据库,所述方法包括:1. A database processing method, characterized in that it is applied to a server, and the server includes a database to be processed, and the method comprises: 获取所述待处理数据库;Obtain the database to be processed; 在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;When the system service of the server is running, create a file backup script corresponding to the database to be processed, and perform a backup operation on the database to be processed based on the file backup script to obtain a backup file; 在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。In the case that there is data loss in the database to be processed, based on the backup file, create a database recovery script corresponding to the backup file, and based on the database recovery script and the backup file, construct a script related to the database to be processed The recovery database corresponding to the database, so that the server recovers and obtains the recovery database when the system service is running. 2.根据权利要求1所述的数据库处理方法,其特征在于,所述基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件,具体包括:2. The database processing method according to claim 1, wherein the backup operation is performed on the database to be processed based on the file backup script to obtain a backup file, which specifically includes: 基于所述文件备份脚本,确定与所述待处理数据库对应的备份命令;Based on the file backup script, determine a backup command corresponding to the database to be processed; 基于所述备份命令,对所述待处理数据库进行备份操作,得到备份文件。Based on the backup command, a backup operation is performed on the database to be processed to obtain a backup file. 3.根据权利要求2所述的数据库处理方法,其特征在于,所述基于所述备份命令,对所述待处理数据库进行备份操作,得到备份文件,具体包括:3. The database processing method according to claim 2, wherein the backup operation is performed on the database to be processed based on the backup command to obtain a backup file, which specifically includes: 基于所述备份命令,对所述待处理数据库进行备份操作,得到不同备份时刻的备份文件;Based on the backup command, perform a backup operation on the database to be processed to obtain backup files at different backup times; 将所述备份时刻为最新备份时刻的备份文件,作为构建所述恢复数据库的备份文件。The backup file whose backup time is the latest backup time is used as the backup file for constructing the recovery database. 4.根据权利要求2或3所述的数据库处理方法,其特征在于,在所述基于所述备份命令,对所述待处理数据库进行备份操作,得到备份文件之后,所述方法还包括:4. The database processing method according to claim 2 or 3, wherein, after performing a backup operation on the database to be processed based on the backup command and obtaining a backup file, the method further comprises: 基于所述文件备份脚本,确定与所述备份文件对应的压缩命令;determining a compression command corresponding to the backup file based on the file backup script; 基于所述压缩命令,对所述备份文件进行压缩处理,得到压缩后备份文件;Compressing the backup file based on the compression command to obtain a compressed backup file; 在所述基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本之前,所述方法还包括:Before creating a database recovery script corresponding to the backup file based on the backup file, the method further includes: 对所述压缩后备份文件进行解压操作,得到所述备份文件。Decompressing the compressed backup file to obtain the backup file. 5.根据权利要求1所述的数据库处理方法,其特征在于,所述基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,具体包括:5. The database processing method according to claim 1, wherein the recovery database corresponding to the database to be processed is constructed based on the database recovery script and the backup file, specifically comprising: 基于所述数据库恢复脚本,确定第一命令,其中,所述第一命令为关闭用户对所述待处理数据库的访问权限的命令;Determining a first command based on the database recovery script, wherein the first command is a command to close the user's access authority to the database to be processed; 在基于所述第一命令成功关闭用户对所述待处理数据库的访问权限的情况下,基于所述数据库恢复脚本,确定第二命令,其中,所述第二命令为对所述待处理数据库进行更名操作的命令;In the case that the user's access right to the database to be processed is successfully closed based on the first command, a second command is determined based on the database restoration script, wherein the second command is to perform a database recovery operation on the database to be processed command for renaming operation; 在基于所述第二命令成功对所述待处理数据库进行更名操作的情况下,基于所述数据库恢复脚本,确定第三命令,其中,所述第三命令为创建空白数据库的命令,所述空白数据库用于承接所述备份文件;In the case that the database to be processed is successfully renamed based on the second command, a third command is determined based on the database recovery script, wherein the third command is a command for creating a blank database, and the blank The database is used to undertake the backup file; 在基于所述第三命令成功创建所述空白数据库的情况下,基于所述数据库恢复脚本,确定第四命令,其中,所述第四命令为将所述备份文件导入至所述空白数据库的命令;In the case that the blank database is successfully created based on the third command, a fourth command is determined based on the database restoration script, wherein the fourth command is a command for importing the backup file into the blank database ; 在基于所述第四命令成功将所述备份文件导入至所述空白数据库的情况下,得到包含所述备份文件的所述空白数据库,并将所述包含所述备份文件的所述空白数据库作为所述恢复数据库。In the case that the backup file is successfully imported into the blank database based on the fourth command, the blank database containing the backup file is obtained, and the blank database containing the backup file is used as The recovery database. 6.根据权利要求5所述的数据库处理方法,其特征在于,在所述得到包含所述备份文件的所述空白数据库之后,所述方法还包括:6. The database processing method according to claim 5, characterized in that, after said obtaining said blank database comprising said backup file, said method further comprises: 基于所述数据库恢复脚本,确定第五命令,其中,所述第五命令为删除所述待处理数据库和\或所述备份文件的命令;A fifth command is determined based on the database recovery script, wherein the fifth command is a command to delete the database to be processed and/or the backup file; 基于所述第五命令,删除所述待处理数据库和\或所述备份文件。Based on the fifth command, delete the database to be processed and/or the backup file. 7.根据权利要求5所述的数据库处理方法,其特征在于,在所述基于所述数据库恢复脚本,确定第二命令之后,所述方法还包括:7. The database processing method according to claim 5, characterized in that, after the second command is determined based on the database restoration script, the method further comprises: 在基于所述第二命令未成功对所述待处理数据库进行更名操作的情况下,重新开启用户对所述待处理数据库的访问权限,并停止确定第三命令的操作。In the case that the operation of renaming the database to be processed is unsuccessful based on the second command, re-enable the user's access right to the database to be processed, and stop the operation of determining the third command. 8.根据权利要求5所述的数据库处理方法,其特征在于,在所述基于所述数据库恢复脚本,确定第三命令之后,所述方法还包括:8. The database processing method according to claim 5, wherein, after the third command is determined based on the database restoration script, the method further comprises: 在基于所述第三命令未成功创建所述空白数据库的情况下,将所述待处理数据库的名称更改至原名称,以及重新开启用户对所述待处理数据库的访问权限,并停止确定第四命令的操作。In the case that the blank database is not successfully created based on the third command, the name of the database to be processed is changed to the original name, and the user's access right to the database to be processed is reopened, and determination of the fourth The operation of the command. 9.根据权利要求5所述的数据库处理方法,其特征在于,在所述基于所述数据库恢复脚本,确定第四命令之后,所述方法还包括:9. The database processing method according to claim 5, wherein, after the fourth command is determined based on the database restoration script, the method further comprises: 在基于所述第四命令未成功将所述备份文件导入至所述空白数据库的情况下,将所述待处理数据库的名称更改至原名称、重新开启用户对所述待处理数据库的访问权限,以及删除所述空白数据库。In the case of unsuccessfully importing the backup file into the blank database based on the fourth command, changing the name of the database to be processed to the original name, reopening the user's access authority to the database to be processed, and delete said blank database. 10.根据权利要求1所述的数据库处理方法,其特征在于,所述待处理数据库为集群模式的数据库。10. The database processing method according to claim 1, wherein the database to be processed is a cluster mode database. 11.根据权利要求1所述的数据库处理方法,其特征在于,所述服务器的系统服务由单体应用提供,或者由微服务提供。11. The database processing method according to claim 1, wherein the system service of the server is provided by a monolithic application, or provided by a microservice. 12.一种数据库处理装置,其特征在于,应用于服务器,所述服务器包括待处理数据库,所述装置包括:12. A database processing device, characterized in that it is applied to a server, the server includes a database to be processed, and the device includes: 第一模块,用于获取所述待处理数据库;A first module, configured to acquire the database to be processed; 第二模块,用于在所述服务器的系统服务处于运行的情况下,创建与所述待处理数据库对应的文件备份脚本,并基于所述文件备份脚本对所述待处理数据库进行备份操作,得到备份文件;The second module is configured to create a file backup script corresponding to the database to be processed when the system service of the server is running, and perform a backup operation on the database to be processed based on the file backup script to obtain backup file; 第三模块,用于在所述待处理数据库存在数据丢失的情况下,基于所述备份文件,创建与所述备份文件对应的数据库恢复脚本,并基于所述数据库恢复脚本和所述备份文件,构建与所述待处理数据库对应的恢复数据库,以使所述服务器在所述系统服务处于运行的情况下恢复得到所述恢复数据库。The third module is configured to create a database recovery script corresponding to the backup file based on the backup file when there is data loss in the database to be processed, and based on the database recovery script and the backup file, Constructing a restoration database corresponding to the database to be processed, so that the server restores and obtains the restoration database when the system service is running. 13.一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1至11任一项所述的数据库处理方法。13. An electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor according to claim 1 is implemented when executing the program. The database processing method described in any one of to 11. 14.一种非暂态计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至11任一项所述的数据库处理方法。14. A non-transitory computer-readable storage medium on which a computer program is stored, wherein the computer program implements the database processing method according to any one of claims 1 to 11 when executed by a processor.
CN202310146372.4A 2023-02-08 2023-02-08 Database processing method, device, electronic device and storage medium Pending CN116302688A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310146372.4A CN116302688A (en) 2023-02-08 2023-02-08 Database processing method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310146372.4A CN116302688A (en) 2023-02-08 2023-02-08 Database processing method, device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN116302688A true CN116302688A (en) 2023-06-23

Family

ID=86789859

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310146372.4A Pending CN116302688A (en) 2023-02-08 2023-02-08 Database processing method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN116302688A (en)

Similar Documents

Publication Publication Date Title
CN103810058B (en) Backup method, equipment and system for virtual machine
US10423585B2 (en) Method and device for making differential upgrade package, and method and device for system differential upgrading
CN103473277B (en) The Snapshot Method and device of file system
CN112596951B (en) NAS data disaster recovery method, device, equipment and storage medium
CN113886143B (en) Virtual machine continuous data protection method and device and data recovery method and device
CN109032839A (en) A kind of cloud host backup method and device
CN111400105A (en) Database backup method and device
CN114138549A (en) Data backup and recovery method based on kubernets system
CN113297007A (en) Data processing method and device
CN108664255B (en) Software upgrading method and device
US10318385B2 (en) Service recovery using snapshots and interservice messages
CN112256400A (en) Virtual machine snapshot management method and device
US8312237B2 (en) Automated relocation of in-use multi-site protected data storage
US20240311346A1 (en) Storage tiering for computing system snapshots
CN105786650A (en) Data management method and device
CN111488195B (en) Virtual machine cloning method, device, equipment and computer readable storage medium
CN116302688A (en) Database processing method, device, electronic device and storage medium
US12189495B2 (en) System and techniques for backing up scalable computing objects
CN114443354A (en) File recovery method and device, electronic equipment and storage medium
CN115174596A (en) Equipment remote copying method, device and medium
CN102902607A (en) Data backup and recovery method for Android thin client
CN113821378B (en) Cloud hard disk backup method, system, storage medium and equipment
CN108958885A (en) A kind of management method and device of configuration information
CN114546731B (en) Workflow data recovery method and data recovery system
CN117591146A (en) Cluster resource updating method and device based on custom resource information

Legal Events

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