WO2020108623A1 - 数据备份方法、装置、服务器以及计算机可读存储介质 - Google Patents
数据备份方法、装置、服务器以及计算机可读存储介质 Download PDFInfo
- Publication number
- WO2020108623A1 WO2020108623A1 PCT/CN2019/122015 CN2019122015W WO2020108623A1 WO 2020108623 A1 WO2020108623 A1 WO 2020108623A1 CN 2019122015 W CN2019122015 W CN 2019122015W WO 2020108623 A1 WO2020108623 A1 WO 2020108623A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- backup
- historical
- snapshot
- task
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operations
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
- G06F11/1466—Management of the backup or restore process to make the backup process non-disruptive
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operations
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operations
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1435—Saving, restoring, recovering or retrying at system level using file system or storage system metadata
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operations
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
- G06F11/1461—Backup scheduling policy
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operations
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
- G06F11/1451—Management of the data involved in backup or backup restore by selection of backup contents
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/80—Database-specific techniques
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/84—Using snapshots, i.e. a logical point-in-time copy of the data
Definitions
- This application relates to the field of database technology, and in particular, to a data backup method, device, server, and computer-readable storage medium.
- a data backup method, device, server, and computer-readable storage medium are provided.
- a data backup method is executed by the server.
- the method includes:
- the backup time of the backup task is a historical time period
- obtain the first snapshot difference between the first historical transaction snapshot and the second historical transaction snapshot, the first historical transaction snapshot and the second historical transaction snapshot are the history respectively Transaction snapshots at the beginning and end of the time period;
- the backup task is executed according to the first snapshot difference to obtain backup data, and the backup data includes at least a visible version of the data item in the target data table.
- a data backup device includes:
- the receiving module is used to receive a backup task, and the backup task is used to back up the data items of the target data table;
- An obtaining module configured to obtain the first snapshot difference between the first historical transaction snapshot and the second historical transaction snapshot when the backup time of the backup task is a historical time period, the first historical transaction snapshot and the second historical transaction
- the snapshots are transaction snapshots at the beginning and end of the historical time period, respectively;
- the backup module is configured to execute the backup task according to the first snapshot difference to obtain backup data, and the backup data includes at least a visible version of the data item in the target data table.
- the data form of the backup data is: storing various files under a directory, or storing as multiple tar packages.
- a server includes a processor and a memory, where at least one instruction is stored in the memory, and the at least one instruction is loaded and executed by the processor to implement the operation performed by the data backup method described above.
- a computer-readable storage medium storing at least one instruction, the at least one instruction is loaded and executed by a processor to implement the operation performed by the data backup method described above.
- FIG. 1 is a schematic diagram of an implementation environment of a data backup method provided by an embodiment of the present application
- FIG. 2 is a flowchart of a data backup method provided by an embodiment of the present application.
- FIG. 3 is a flowchart of a data backup method provided by an embodiment of the present application.
- FIG. 4 is a flowchart of a data backup method provided by an embodiment of the present application.
- FIG. 5 is a flowchart of a data backup method provided by an embodiment of the present application.
- FIG. 7 is a schematic structural diagram of a data backup device provided by an embodiment of the present application.
- FIG. 8 is a schematic structural diagram of a server provided by an embodiment of the present application.
- the database involved in the embodiments of the present application stores multiple data tables, and each data table may be used to store data items, and the data items may have one or more versions.
- the database may be any type of database based on MVCC (Multi-Version Concurrency Control). In the embodiment of the present application, the type of the database is not specifically limited.
- the data in the above database is based on state attributes and can include three states: the current state, the transition state, and the historical state. These three states are collectively referred to as the "full state of the data", referred to as the full state data, the full state
- the different state attributes in the data can be used to identify the state of the data in its life cycle trajectory.
- the latest version of the data item is the data at the current stage.
- the state of the data at the current stage is called the current state.
- Transitional state It is not the latest version of the data item nor the historical state version. During the transition from the current state to the historical state, the data in the transitional state is called half-life data.
- Historical state A state in the history of a data item whose value is the old value, not the current value.
- the state of the data in the historical stage is called the historical state.
- the data may only exist in the historical state and the current state.
- the new value of the data after the transaction is submitted is in the current state.
- the data generated by the transaction before the smallest transaction in the current active transaction list is in a historical state.
- the value of the data before submission becomes the value of the historical state, that is, the old value of the data item is in the historical state.
- the read version still has active transactions (non-latest related transactions) in use, and because the latest related transaction modifies the value of the data item, the latest value is already in a current state, and the read value is relative to the current state It is already in a historical state, so its data state is between the current state and the historical state, so it is called a transition state.
- the A account balance of the User table changes from 10 yuan recharge to 20 yuan, and then consumes 15 yuan to 5 yuan.
- the financial B institution reads data to check the transaction has been in progress, and recharge after A If 20 yuan becomes 25 yuan, then 25 yuan is the current state data, 5 yuan that B is reading is the transition state, and the remaining two values 20 and 10 are the states that existed in history and are historical state data.
- the embodiments of the present application provide a backup method of hybrid physical backup, which is used to perform full-state data backup, which can reduce the amount of backup data and improve backup efficiency.
- the backup task can be triggered by the backup command, the following example is a specific form of the backup command,
- BACKUPNAME specifies the name of the backup data package
- my_table specifies the backup target data table for this backup task
- TYPE LO after the BACKUP field can be used to indicate that the backup type is logical backup
- TYPE PH can be used to indicate that the backup type is physical Backup, the default can be used to indicate that the backup type is physical backup
- WHERE statement is used to specify the backup conditions of the backup task.
- the above data backup method may be applied to a hardware environment including multiple servers 101 as shown in FIG. 1.
- multiple servers 101 are connected through a network, or the multiple servers 101 may also be data isolated.
- the foregoing networks include but are not limited to: wide area network, metropolitan area network, or local area network.
- the data backup method in this embodiment of the present application may be executed by any one server 101 or multiple servers 101.
- a database system may be running on the server 101 to provide data services, such as data storage, data query, and so on.
- the database system can work through the database engine running on the server.
- the data backup method provided by the embodiment of the present application can realize full-state data backup.
- Logical backups can be based on historical transaction snapshots and/or regular transaction snapshots to easily read data values at a certain moment in the full state data.
- the specific implementation strategies are as follows: (1) Based on regular transaction snapshots on the current state data Back up; (2) Based on historical transaction snapshots, back up historical state data and transition state data; (3) Based on historical transaction snapshots and regular transaction snapshots, to achieve simultaneous backup of multiple versions of the same data item.
- the data form obtained by the three strategies based on logical backup is the data organized based on the format of the backup instruction. Therefore, this type of backup can be called logical backup.
- the backup instruction may be a SQL statement, and the specific data organization format may be organized in the INSERT format.
- the name of each file in the backup data package can be different according to the type of backup.
- the file name of the logical backup can be named by LoData_00000001, and the corresponding meta information file can be named by LoMeta_00000001.
- the above data backup method for logical backup cannot back up all systems, that is, a backup package can be obtained by the above data backup method, but information such as control files may not be recorded in the meta information file.
- the difference between the logical backup involved in the embodiments of the present application and the traditional backup method is as follows: one is to support full state data backup, and the other is that the backup method is not carried out by CLI (command line) but by SQL statement. It supports backup, and the third is to generate a physical backup package similar to physical backup.
- CLI command line
- SQL statement SQL statement
- the physical backup refers to a physical backup in a traditional database system. Since it cannot specify a transaction snapshot of a historical time period for the backup task, it can only back up the current state data, that is, the data obtained by its backup is only Include current state data, but not historical state data.
- the name of the data file can be named using PhData_00000001, etc., and the corresponding meta information file can be named using PhMeta_00000001.
- the backup target data may be different, and may be based on the backup target data. Divided into the following four types:
- the first type the current state data point value backup, that is, based on the regular transaction snapshot, you can back up the current state data.
- the backup data package includes the meta information file, the current state data file, and the REDO log file.
- the following uses the flowchart of the data backup method shown in FIG. 2 as an example to back up the current state data point value.
- the data backup method specifically includes the following process:
- the server receives a backup task.
- the backup task is used to back up data items of the target data table.
- the backup time indicated by the above backup task is the current time.
- the server may receive a backup task by receiving a backup instruction, and the backup instruction may carry information about the backup target.
- the embodiment of the present application only uses the backup time as the current time as an example for illustration.
- the current time in the backup instruction may be expressed as "default", that is, the target data of the backup instruction is the current state data at the current time.
- the transaction snapshot may indicate which data is readable in the current system and which are active transactions at the time of creation of the transaction snapshot, and whose data cannot be read by the transaction, so as to know which elements at the current time Which versions of the group are visible. Therefore, through the conventional transaction snapshot, it can be determined that the current state version of the data item in the target data table is visible, that is, the backup data obtained by the backup includes the current state data of the data item in the target data table.
- the server may perform block backup, that is, for any data block corresponding to the target data table, based on the conventional transaction snapshot, the block copy Form to back up the data block where the current state data is located to obtain the backup data.
- This backup of the current state data in the form of a block copy speeds up the backup speed, and because the current state data is physically separated from the transition state and historical state data, this form of block copy can be realized.
- the backup data obtained in this embodiment of the present application includes a backup data package, and the backup data package is a complete backup data package that maintains data consistency.
- Each backup data package has two optional forms: one is to store various files in a directory, and the other is a backup package composed of multiple tar packages:
- the files are named different file names according to types.
- meta information files are named Meta_00000001, Meta_00000002, etc.
- data files are named Data_00000001, Data_00000002, etc.
- log files are named Log_00000001, Log_00000002, etc.
- the meta information is usually small, usually stored in one file, and the data file can be defined as a certain size. For example, if the size of each data file is defined as 1T, the amount of data can be stored to 4EB. In addition, on different operating systems, the maximum file size of the data file is different, such as Ext2/Ext3 (8kB block size) single file maximum 64TB, you can store more data.
- the specific size and other management forms of the log file can be the same as the data file, and will not be repeated here.
- the "00000002" format can expand the number of bits to support a larger amount of data.
- the storage of the files is the same as above, but the files are packaged according to the file size, which is convenient for unified management. Further, it can also support the introduction of compression algorithms to save storage space.
- the backup data further includes a meta information file, a data file, and a log file of the current state data.
- the current state data may be checked at the beginning of the backup process until the end of the backup process
- the log files are backed up in segments. For example, the position of obtaining the REDO log from the beginning of the backup process is assumed to be Loc1; at the same time, it supports new transactions to operate; to the end of the backup process, the position of obtaining the system REDO log is assumed to be Loc2; REDO logs are also archived and backed up to backup data packages.
- the backup of the above log files adopts an immediate backup strategy, and one log information can be generated to back up one, or a piece of log information can be generated to back up one section. Since log management can take the form of segmented files, there can be many small fragments of files in the log file, such as PostgreSQL log files, which are composed of multiple 1G files. Therefore, the above log backup method can be implemented.
- the second type, historical state data point value backup that is, based on historical transaction snapshots, historical state data and transition state data can be backed up, and its backup data package includes meta information file, historical state data and transition state data Data file.
- the following uses the flowchart of the data backup method shown in FIG. 3 as an example to back up historical data point values. Specifically, the data backup method specifically includes the following processes:
- the server receives a backup task, which is used to back up the data items of the target data table.
- the backup time indicated by the above backup task includes a historical moment.
- each version of the data item in the target data table can be judged according to the third historical transaction snapshot to determine the visible version at the moment of creation of the snapshot.
- It performs backup that is, the backup data obtained by the backup includes at least the historical state data and the transition state data of the data items in the target data table.
- the data backed up is a point value on the data item.
- the data item needs to be obtained in a logical manner to generate backup data such as data files.
- the embodiment of the present application also relates to the following two situations of backup of the segment value, including the full state data segment value backup and the historical state data segment value backup Both of these backups can be performed based on the difference in snapshots, which are introduced as follows:
- the third type, full state data segment value backup based on historical transaction snapshots and regular transaction snapshots, enables simultaneous backup of multiple versions of the same data item, and its backup data package includes meta information files, historical state data and transition state Data data files, current state data, and log files.
- the following uses the flowchart of the data backup method shown in FIG. 4 as an example to describe the backup of the state data segment value backup. Specifically, the data backup method specifically includes the following process:
- the server receives a backup task.
- the backup task is used to back up data items of the target data table.
- the backup time indicated by the above backup task includes a time period with the current time as the end point.
- the backup time of the backup task includes a time period with the current time as the end point
- the fourth historical transaction snapshot and the fifth The historical transaction snapshots are the transaction snapshot at the beginning of the time period and the regular transaction snapshot at the current moment, respectively.
- the backup of the current state data may be the same as the backup method of the current state data shown in FIG. 2, which will not be repeated here.
- the backup of the historical state data and the transition state data based on the second snapshot difference can be performed based on logical reading, that is, based on the second snapshot difference, each version of the data item in the target data table is performed Visibility judgment, backup the visible version.
- the backup speed is fast, and part of the data of a block within the scope of "historical transaction snapshot segment”.
- a certain percentage threshold such as the first preset ratio, for example, when most of the data of the data block is within the scope of "historical transaction snapshot segment” , Block copy is performed, the backup speed is fast, but invalid data needs to be identified in the meta information file, for example, in the HMeta_00000001 series of files, this is achieved by block copy, and a small part of the data is in the "historical transaction snapshot Within the scope of "segment”, a logical read method is used to read out the visible version of the data item and write it out to a data file, such as the HData_00000001 series file.
- This backup method is essentially a logical backup method. That is, in the embodiment of the present application, in order to improve the backup efficiency, a backup method based on block backup may also be adopted.
- the server may determine the second data block of the target data table, where the second data block stores Historical state data of the target data table; if based on the second snapshot difference, it is determined that the historical state data stored in the second data block are all visible versions, the second data block is performed in the form of a block copy Backup, get the backup data.
- the second data block is backed up in the form of a block copy, Marking the invisible historical state data in the second data block to obtain backup data; if based on the second snapshot difference, it is determined that the proportion of visible versions in the historical state data stored in the second data block is less than the At the first preset ratio, the visible version in the second data block is read in the form of logical reading to obtain backup data.
- the first ratio may be expressed in the form of a percentage or a decimal within the range of [0,1].
- the default value of the first ratio is 0.2, and the range of values is [0,1].
- the above-mentioned full-state data segment value backup process refers to the existence of data in the current state, the transition state, and the historical state in the backup data, and the latter two are not only the value at a time point, but a time period for the same data item On multiple values.
- the data that is backed up can be divided into the following according to the specified snapshot type (essentially a time point or a time period): the current state data backup: it must be a point value backup, in the same way as the first backup point.
- Transition state data backup point value, segment value
- Backup of historical data point value, segment value
- the fourth type, historical state data point value backup, based on historical transaction snapshot does not include regular transaction snapshot, to achieve simultaneous backup of multiple versions of the same data item, its backup data package includes meta information file, historical state data and transition Data file for the state data.
- the following uses the flowchart of the data backup method shown in FIG. 5 as an example to illustrate the backup of historical state data point value backup. Specifically, the data backup method specifically includes the following process:
- the server receives a backup task, which is used to back up the data items of the target data table.
- the above backup task is used to back up the data items of the target data table.
- the server may receive the backup task by receiving a backup instruction, and the backup instruction may carry information about the backup target.
- the backup task may have different specific backup processes according to the backup time indicated by it.
- the embodiment of the present application only uses the backup time as a historical time period for example, that is, the backup instruction includes the historical time period
- the start time and end time of the backup, the backup target data is historical state data and transition state data in a historical time period before the current time.
- the backup time of the backup task is a historical time period
- the first historical transaction snapshot and the second historical transaction snapshot are: A snapshot of the transaction at the beginning and end of the historical time period.
- the process of performing the backup task based on the first snapshot difference is the same as the process of backing up the historical state data and the transition state data based on the second snapshot difference in step 303, and details are not described herein.
- the backup process it is also possible to determine whether to use block backup, physical backup, or logical backup based on the historical state data stored in the data block, thereby improving backup efficiency and backup flexibility, for example, the server
- the first data block of the target data table may be determined, where the first data block stores historical state data of the target data table; if based on the first snapshot difference, the historical state stored in the first data block is determined When the data are all visible versions, the first data block is backed up in the form of a block copy to obtain backup data.
- the first data block is backed up in the form of a block copy, Mark the invisible historical state data in the first data block to obtain backup data; if based on the first snapshot difference, determine that the proportion of visible versions in the historical state data stored in the first data block is less than the At the first preset ratio, the visible version in the second data block is read in the form of logical reading to obtain backup data.
- the meta data of the historical state data and the transition state data in the backup data are associated, and the associated meta information can be stored separately to the file name associated with In the meta-information file, for example, the transition state data of a historical transaction snapshot segment or historical transaction snapshot is stored in the file IData, and the associated historical state data exists in the HData file.
- the purpose is to facilitate the same The data belonging to the same historical transaction snapshot of the data item is merged during the recovery phase.
- the above-mentioned associated meta information can also be backed up to a meta information file at the same time, for example, to a file named after the HMeta_00000001 series.
- the above association can be associated through file naming, so as to confirm the relationship between the transition state and the historical state data during data recovery, and can ensure the consistency of the data.
- a meta information list is constructed based on the meta information of the backup data and the related meta information of the backup data, and the backup is performed based on the meta information list to obtain a meta information file.
- the backup is performed based on the meta information list to obtain a meta information file.
- the backup efficiency can be further improved based on the different granularity of the backup.
- the granularity of the backup includes: table space level backup, file level backup, file block level backup, and data item level backup (such as (The aforementioned logical backup method).
- the database system mostly uses the table space to manage data.
- the table space is a logical concept.
- For the upper layer executor and data buffer, it is a logical storage layer, which shields the storage details of the physical layer.
- the lower layer operating system
- it is a storage manager that can govern multiple physical files, even network storage. There can be multiple data files in a table space, and files can be dynamically added and deleted.
- the backup can be performed based on the granularity of the table space. If the backup condition does not include the backup condition, such as the WHERE condition, the meta information of the table space of the target data table and all data files under the table space are directly backed up (parallel backup can be used To back up multiple data files).
- the backup condition such as the WHERE condition
- the meta information of the table space of the target data table and all data files under the table space are directly backed up (parallel backup can be used To back up multiple data files).
- the backup task includes a backup, such as a WHERE condition
- the condition is backed up
- the first data file is backed up. For example, if the WHERE condition covers most of a data file, the corresponding data file is directly backed up.
- the backup process when all data files or part of the data files in the target data table meet the backup conditions of the backup task, and the part of the data files account for the preset proportion of the number of files in the target data table, then Back up the multiple data files or some data files. For example, if the WHERE condition covers most of the multiple data files, the multiple data files are backed up. If the WHERE condition covers most of all data files, all data files are backed up in parallel, in fact, a table space granular backup.
- the first data file is backed up, Mark invalid data in the first data file.
- the data is read in the form of logical reading.
- the data items in the first data file are described. For example, if the WHERE condition cannot cover most of a data file, refer to the data block backup method provided in the foregoing embodiment.
- the backup method may use block backup or logical backup.
- the backup target of the backup task includes multiple data tables
- support for backing up the multiple data tables in parallel that is, For the backup of different table objects, parallel backup can be adopted, for example, a backup thread is started for each data table to perform the backup.
- the backup target of the backup task includes multiple data files
- the multiple data files can be backed up in parallel.
- the backup target of the backup task includes multiple data blocks, it is possible to back up the multiple data blocks in parallel.
- Example 1 The way of logical backup
- BACKUP ALL //Back up the entire system, if it is to back up a certain table, such as "BACKUP FROM my_table;"
- the qualified data on a certain data block has enough space to be stored on this page.
- a data valid bit can be added to the page, and the data valid bit can be used to indicate whether the data on this page is spread across pages.
- the data valid bit can be divided into 2 parts, one part is the data visible flag bit, and all are set to 0; the remaining one bit (called the spread page flag bit) indicates whether the data on this page spreads, 1 Means spread across pages, 0 means no spread across pages.
- the embodiment of the present application proposes a backup method based on temporal data on the basis of the temporal database, so that for any state data in the full state data, a variety of flexible methods can be adopted, such as logical or physical methods and logical The physical combination is used to realize the backup, which provides an effective guarantee for the effective storage and security of temporal data.
- the physical backup involved in the above embodiments can be applied to data backup in all cases.
- the logical backup involved in the above embodiments is the backup through logical read methods, for example The way of reading the visible version of a data item can also be applied to data backup in all situations.
- data backup is realized, which can greatly improve the backup efficiency.
- the embodiment of the present application does not limit the combination method of the above physical backup and logical backup. Taking the following implementation scenario as an example, various backup strategies can be formulated through the combination of the physical backup and the logical backup described above, so as to meet the backup requirements during the operation process and ensure efficient backup.
- the above three backup methods can be combined to formulate a backup strategy, that is, when and what means (logical backup, physical backup) are used for backup.
- the optional backup strategy is the same as the traditional database backup strategy.
- a feasible backup strategy is as follows: a full backup of the database (including all data that is the full state data) every six months, and a zero-level backup every month (Does not include read-only tablespaces), do a primary backup once a week, and a secondary backup once a day.
- the backup level can be set based on actual needs.
- Another feasible backup strategy is as follows: a dual strategy is adopted for backup, that is, a combination of logical backup and physical backup. According to the amount of data and tolerance for data loss, first make regular physical backups, and then make logical backups every 2 complete physical backup intervals.
- the visible version of the data item involved in the embodiment of the present application refers to a version that can be read by the firm at the time corresponding to the transaction snapshot corresponding to the backup task.
- Each time the server reads a tuple from the data table it can read the life cycle information of the tuple, that is, the version creation time, deletion time, and the submission time of the version, etc., based on historical time Examples of segment visibility judgment:
- steps in the flowcharts of FIGS. 2-5 are displayed in order according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless clearly stated in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least some of the steps in FIGS. 2-5 may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed and completed at the same time, but may be executed at different times. The order of execution is not necessarily sequential, but can be executed in turn or at least partly with other steps or sub-steps or stages of other steps.
- FIG. 7 is a schematic structural diagram of a data backup device provided by an embodiment of the present application. Referring to FIG. 7, the device includes:
- the receiving module 701 is used to receive a backup task, and the backup task is used to back up the data items of the target data table;
- the obtaining module 702 is configured to obtain the first snapshot difference between the first historical transaction snapshot and the second historical transaction snapshot when the backup time of the backup task is a historical time period, the first historical transaction snapshot and the second history Transaction snapshots are transaction snapshots at the beginning and end of the historical time period, respectively;
- the backup module 703 is configured to execute the backup task according to the first snapshot difference to obtain backup data, and the backup data includes at least a visible version of the data item in the target data table.
- the device provided by the embodiment of the present application on the basis of the temporal database, proposes a backup method based on temporal data so that for any state data in the full state data, a variety of flexible methods can be adopted, such as a logical way
- the physical mode and the combination of logical and physical methods are used to realize the backup, which provides an effective guarantee for the effective storage and security of temporal data.
- the backup module 703 is further used to:
- the first data block is backed up in the form of a block copy to obtain backup data.
- the device further includes:
- the first data block is backed up in the form of a block copy, and the first data block Mark the invisible historical state data to get the backup data;
- the visible in the first data block is read in the form of logical reading Version, get the backup data.
- the device further includes:
- the data block where the current state data is located is backed up in the form of a block copy to obtain backup data.
- the device further includes:
- the log file of the current state data is backed up in sections from the beginning of the backup process until the end of the backup process.
- the device further includes:
- a third historical transaction snapshot is obtained, and the third historical transaction snapshot is the transaction snapshot at the historical moment;
- the backup task is executed to obtain backup data, and the backup data includes at least a visible version of the data item in the target data table.
- the device further includes:
- the backup time of the backup task includes the time period with the current time as the end point
- the snapshots are the transaction snapshot at the beginning of the time period and the normal transaction snapshot at the current time
- the current state data and the visible version in the target data table are backed up, and the backup data includes at least the visible version of the data item in the target data table.
- the backup data when the backup target of the backup task includes historical state data and transition state data, the backup data includes meta-information files and data files of the historical state data and transition state data.
- the backup data when the backup target of the backup task includes current state data, the backup data further includes a meta information file, a data file, and a log file of the current state data.
- the file naming between the meta-information files of the historical state data and the transition state data in the backup data is associated.
- the backup module 703 is further configured to construct a meta information list based on the meta information of the backup target and related meta information of the backup target when backing up the meta information, and perform backup based on the meta information list Get the meta information file.
- the data form of the backup data is: storing various files under a directory, or storing as multiple tar packs.
- the device further includes:
- the first data file is backed up;
- the first data file is backed up. Mark invalid data in the data file
- the first data file is read in the form of logical reading The data item in.
- If the backup target of the backup task includes multiple data tables, support for backing up the multiple data tables in parallel;
- If the backup target of the backup task includes multiple data files, support for backing up the multiple data files in parallel;
- the backup target of the backup task includes multiple data blocks, support for backing up the multiple data blocks in parallel.
- the data backup device provided in the above embodiment only uses the division of the above functional modules as an example for data backup.
- the above functions can be allocated by different functional modules according to needs, that is, The internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
- the data backup device and the data backup method embodiment provided in the above embodiments belong to the same concept. For the specific implementation process, see the method embodiments.
- the above data backup device can be implemented in the form of a computer program, and the computer program can run on the terminal.
- the storage medium on the terminal may store various program modules constituting the data backup device, for example, the receiving module 701, the obtaining module 702, and the backup module 703 shown in FIG. 7.
- the processor causes the processor to execute the steps in the recommended content display method of each embodiment of the present application.
- FIG. 8 is a schematic structural diagram of a server provided by an embodiment of the present application.
- the server 800 may have a relatively large difference due to different configurations or performance, and may include one or more processors (central processing units (CPU) 801 and one Or more than one memory 802, wherein at least one instruction is stored in the memory 802, and the at least one instruction is loaded and executed by the processor 801 to implement the methods provided by the foregoing method embodiments.
- the server may also have components such as a wired or wireless network interface, a keyboard, and input and output interfaces for input and output.
- the server may also include other components for implementing device functions.
- the memory 802 may be a non-volatile and/or volatile memory.
- Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
- Volatile memory can include random access memory (RAM) or external cache memory.
- RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
- SRAM static RAM
- DRAM dynamic RAM
- SDRAM synchronous DRAM
- DDRSDRAM double data rate SDRAM
- ESDRAM enhanced SDRAM
- SLDRAM synchronous chain (Synchlink) DRAM
- SLDRAM synchronous chain (Synchlink) DRAM
- Rambus direct RAM
- DRAM direct memory bus dynamic RAM
- RDRAM memory bus dynamic RAM
- An embodiment of the present application further provides a computer-readable storage medium, which is applied to a server, and the computer-readable storage medium stores at least one instruction, at least one program, code set, or instruction set, the instruction , The program, the code set, or the instruction set is loaded and executed by the processor to implement the operations performed by the server in the data backup method of the foregoing embodiment.
- the program may be stored in a computer-readable storage medium.
- the mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Library & Information Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Retry When Errors Occur (AREA)
Abstract
一种数据备份方法、装置、服务器以及计算机可读存储介质,属于数据库技术领域。所述方法包括:接收备份任务,所述备份任务用于对目标数据表的数据项进行备份);当所述备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,所述第一历史事务快照和所述第二历史事务快照分别为所述历史时间段的起始时刻和结束时刻的事务快照);根据所述第一快照差执行所述备份任务,得到备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本。
Description
本申请要求于2018年11月30日提交中国专利局,申请号为2018114595805,发明名称为“数据备份方法、装置、服务器以及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及数据库技术领域,特别涉及一种数据备份方法、装置、服务器以及计算机可读存储介质。
在数据处理系统中,尤其是OLAP(Online Analytical Processing,联机实时分析)处理系统、数据仓库、大数据分析等场景中,会涉及到在数据库中存储大量数据。由于业务可能不断更新,因此,一个数据项逻辑上会有多个状态对应的版本数据,这样,一个数据项的全态(当前态、过渡态和历史态)数据会得到保存,从而便于系统追踪历史态数据,充分挖掘数据的价值(任何数据都有价值,历史态的数据不能丢失)。而为了保证上述多种状态数据的数据安全,还需对上述全态数据进行备份,然而,数据量的剧增,必然对备份的效率有所影响。因此,如何在数据量剧增的背景下,提高对全态数据的备份效率,是目前面临的一大挑战。
发明内容
根据本申请的各种实施例,提供了一种数据备份方法、装置、服务器以及计算机可读存储介质。
一种数据备份方法,由服务器执行,该方法包括:
接收备份任务,该备份任务用于对目标数据表的数据项进行备份;
当该备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,该第一历史事务快照和该第二历史事务快照分别为该历史时间段的起始时刻和结束时刻的事务快照;
根据该第一快照差执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的可见版本。
一种数据备份装置,该装置包括:
接收模块,用于接收备份任务,该备份任务用于对目标数据表的数据项进行备份;
获取模块,用于当该备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,该第一历史事务快照和该第二历史事务快照分别为该历史时间段的起始时刻和结束时刻的事务快照;
备份模块,用于根据该第一快照差执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的可见版本。
其中,所述备份数据的数据形式为:在目录下存储各类文件,或,存储为多个tar包。
一种服务器,该服务器包括处理器和存储器,该存储器中存储有至少一条指令,该至少一条指令由该处理器加载并执行以实现如上述数据备份方法所执行的操作。
一种计算机可读存储介质,该存储介质中存储有至少一条指令,该至少一条指令由处理器加载并执行以实现如上述数据备份方法所执行的操作。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
图1是本申请实施例提供的一种数据备份方法的实施环境示意图;
图2是本申请实施例提供的一种数据备份方法流程图;
图3是本申请实施例提供的一种数据备份方法流程图;
图4是本申请实施例提供的一种数据备份方法流程图;
图5是本申请实施例提供的一种数据备份方法流程图;
图6是本申请实施例提供的一种页面对比图;
图7是本申请实施例提供的一种数据备份装置的结构示意图;
图8是本申请实施例提供的一种服务器的结构示意图。
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。
本申请实施例涉及的数据库存储有多个数据表,每个数据表可以用于存储数据项,数据项可以有一个或多个版本。其中,该数据库可以为基于MVCC(Multi-Version Concurrency Control,多版本并发控制)的任一类型的数据库。在本申请实施例中,对该数据库的类型不作具体限定。需要说明的是,上述数据库中的数据基于状态属性,可以包括三种状态:当前态、过渡态和历史态,该三种状态合称为“数据的全态”,简称全态数据,全态数据中的各个不同状态属性,可以用于标识数据在其生命周期轨迹中所处的状态。
当前态(Current State):数据项的最新版本的数据,是处于当前阶段的数据。处于当前阶段的数据的状态,称为当前态。
过渡态(Transitional State):不是数据项的最新的版本也不是历史态版本,处于从当前态向历史态转变的过程中,处于过渡态的数据,称为半衰数据。
历史态(Historical state):数据项在历史上的一个状态,其值是旧值,不是当前值。处于历史阶段的数据的状态,称为历史态。一个数据项的历史态,可以有多个,反映了数据的状态变迁的过程。处于历史态的数据,只能被读取而不能被修改或删除。
需要说明的是,在MVCC机制下,数据的上述三种状态均存在,在非MVCC机制下,数据可以只存在历史态和当前态。在MVCC或封锁并发访问控制机制下,事务提交后的数据的新值处于当前态。以MVCC机制为例,当前活跃事务列表中最小的事务之前的事务生成的数据,其状态处于历史态。在封锁并发访问控制机制下,事务提交后,提交前的数据的值变为历史态的值,即数据项的旧值处于历史态。而被读取的版本上尚有活跃事务(非最新相关事务)在使用,而由于最新相关事务修改了数据项的值,其最新值已经处于一个当前态,被读取到的值相对当前态已经处于一个历史状态,因此,其数据状态介于当前态和历史态之间,所以称为过渡态。
例如,MVCC机制下,User表的A账户余额从10元充值变为20元,然后消费了15元变为5元,此时金融B机构读取数据做检查事务一直进行中,A之后又充值20元变为25元,则25元为当前态数据,B正在读取到的5元为过渡态,其余的两个值20、10是历史上存在过的状态,都是历史态数据。
对于任一种状态属性进行存储的数据库来说,在需要对数据库中的数据进行备份时,由于对于一个数据项,该数据库存储了至少一个版本,因此,在备份过程中会涉及到的数据量巨大,例如设一条元组,在一段时间内,平均更新 10次,则更新后的数据量是11条元组,即是初始数据量的11倍,这使得备份带有历史态的数据量会很大,备份的效率成为一个问题。为此,本申请实施例提供了一种混合物理备份的备份方法,用以进行全态数据的备份,能够降低备份数据量,提高备份效率。
对于数据库来说,其备份任务可以由备份命令触发,下面的示例为一种备份命令的具体形式,
BEGIN;
Set BACKUPNAME=‘/usr/bak/my_first_backup_01’READVIEW'20180109000000';//基于历史事务快照备份做逻辑备份
BACKUP TYPE LO FROM my_table;
Set BACKUPNAME=‘/usr/bak/my_first_backup_02’READVIEW FROM'20180109000000'TO'20180119000000';//快照差方式做逻辑备份
BACKUP TYPE LO FROM my_table;
Set BACKUPNAME=‘/usr/bak/my_first_backup_03’READVIEW default;//基于常规事务快照做逻辑备份
BACKUP TYPE LO FROM my_table WHERE pk>10;
END;
其中,BACKUPNAME指定了备份数据包的名称;my_table指定了本次备份任务的备份目标数据表;BACKUP字段后的TYPE LO可以用于表示备份类型为逻辑备份,TYPE PH可以用于表示备份类型为物理备份,缺省可以用于表示备份类型为物理备份;WHERE语句用于指定备份任务的备份条件。
可选地,在本实施例中,上述数据备份方法可以应用于如图1所示的包括多个服务器101的硬件环境中。如图1所示,多个服务器101通过网络进行连接,或者该多个服务器101也可以数据隔离,上述网络包括但不限于:广域网、城域网或局域网。本申请实施例的数据备份方法可以由任一个服务器101或多个服务器101来执行。服务器101上可以运行有数据库系统,从而提供数据服务,例如数据存储、数据查询等等。该数据库系统可以通过服务器上所运行的数据库引擎工作。
本申请实施例提供的数据备份方法,能够实现全态数据的备份,为了便于理解,下面先对逻辑备份和物理备份分别进行介绍:
一、逻辑备份
逻辑备份可以基于历史事务快照或/和常规事务快照,方便地读取全态数据中某个时刻的数据值,其具体实现的策略有以下三种:(1)基于常规事务快照对当前态数据进行备份;(2)基于历史事务快照,对历史态数据和过渡态数据进行备份;(3)基于历史事务快照和常规事务快照,实现对同一个数据项的多个版本的同时备份。
基于逻辑备份的三种策略所得到的数据形式,是基于备份指令的格式所组织的数据,因此,可以将这类备份称为逻辑备份。例如,该备份指令可以是SQL语句,其具体数据组织格式可以按照INSERT格式组织。其中,备份数据包内的各个文件的命名可以根据备份类型的不同而不同,例如,逻辑备份的文件名可以采用LoData_00000001等方式命名,其对应的元信息文件可以采用LoMeta_00000001等方式命名。
上述逻辑备份的数据备份方法,不能够备份全部系统,也即是,通过上述数据备份方法,可以得到一个备份包,但如控制文件等信息可以不在元信息文件中记录。
本申请实施例所涉及的逻辑备份与传统的备份方式的差别在于:一是支持全态数据的备份,二是备份的方式不是以CLI(命令行)方式进行而是以SQL语句的方式来原子地支持备份,三是生成了物理备份包类似于物理备份的方式。
二、物理备份
该物理备份即是指传统的数据库系统中的物理备份,由于其不能为备份任务指定历史时间段的事务快照,因此,其仅能够备份当前态数据,也即是,其备份所得到的数据仅包括当前态数据,而不包括历史态数据。在经由物理备份所得到的备份数据包中,数据文件名可以采用PhData_00000001等方式命名,其对应的元信息文件可以采用PhMeta_00000001等方式命名。
三、混合备份
基于上述第一部分和第二部分的介绍,下面对本申请实施例所涉及的一种混合备份方法进行介绍,需要说明的是,基于不同的备份任务,备份目标数据可以不同,可以基于备份目标数据来分为下面四种类型:
第一种类型,当前态数据点值备份,也即是,基于常规事务快照,可以对 当前态数据的备份,其备份数据包中包括元信息文件、当前态的数据文件、REDO日志文件。下面以图2所示的数据备份方法的流程图,对当前态数据点值进行备份为例进行说明,具体地,该数据备份方法具体包括以下过程:
201、服务器接收备份任务,该备份任务用于对目标数据表的数据项进行备份。
上述备份任务所指示的备份时间为当前时刻。
202、当该备份任务的备份时间为当前时刻时,获取该当前时刻的常规事务快照。
在上述步骤201和202中,服务器可以通过接收备份指令,来接收备份任务,该备份指令中会携带有关于备份目标的信息。本申请实施例仅以备份时间为当前时刻为例进行说明,例如,在备份指令中该当前时刻可以表示为“default”,也即是,该备份指令的目标数据为当前时刻的当前态数据。
203、基于该常规事务快照,执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的当前态数据。
在本申请实施例中,事务快照可以表示在该事务快照的创建时刻当前系统中哪些数据是可读的,哪些是活跃的事务,其数据不能够被事务读取,从而获知在当前时刻哪些元组的哪些版本是可见的。因此,通过常规事务快照,可以确定目标数据表中的数据项的当前态版本可见,也即是备份所获取到的备份数据包括该目标数据表中数据项的当前态数据。
在一种可能实施方式中,对于上述当前态数据,服务器可以采取块备份的方式进行,也即是,对于该目标数据表对应的任一个数据块,基于所述常规事务快照,以块拷贝的形式对当前态数据所在的数据块进行备份,得到备份数据。这种对当前态数据以块拷贝的形式备份,加快了备份的速度,而由于当前态数据和过渡态、历史态数据在物理上是分离的,使得这种块拷贝的形式能够实现。
需要说明的是,本申请实施例所得到的备份数据包括备份数据包,该备份数据包是一个完整的、保持数据一致性的备份数据包。每个备份数据包有两种可选形式:一种是一个目录下存放各种文件,一种是多个tar包构成的一个备份包:
其中,在目录下存放各种文件的备份数据包的形式中,文件按类型分别命名为不同的文件名。例如,元信息文件用Meta_00000001、Meta_00000002等命名;数据文件用Data_00000001、Data_00000002等命名;日志文件用 Log_00000001、Log_00000002等命名。其中,“00000002”等格式中,每个字符用十六进制表示,最多表示的文件个数是“16^8=4 294 967 296”。
其中,元信息通常较小,通常以一个文件存储即可,数据文件可以定义为一定大小,例如,每个数据文件的大小定义为1T,则可以存储到4EB的数据量。另外,在不同的操作系统上,数据文件的最大文件大小不同,如Ext2/Ext3(8kB block size)单个文件的最大为64TB,则可以存储更多的数据。该日志文件的具体大小等管理形式可以与数据文件同理,在此不做赘述。在本申请实施例中,“00000002”格式可以通过扩充位数,以支持更大的数据量。
其中,多个tar包构成的一个备份数据包的形式中,文件的存储同上,只是按文件大小,对文件进行打包,便于统一管理,进一步地,还可以支持引入压缩算法以节约存储空间。
当所述备份任务的备份目标包括当前态数据,则所述备份数据中还包括所述当前态数据的元信息文件、数据文件和日志文件。在一种可能实施方式中,为了保证基于备份进行恢复时的一致性,在对日志文件进行备份时,可以在备份过程的开始时刻直到所述备份过程的结束时刻,对所述当前态数据的日志文件进行分段备份。例如,从备份过程的开始时刻获取REDO日志的位置假定为Loc1;同时支持新的事务进行操作;到备份过程的结束时刻,获取系统REDO日志的位置假定为Loc2;然后把Loc1到Loc2之间的REDO日志也归档并备份到备份数据包。上述日志文件的备份,采取了即刻备份策略,生成一个日志信息即可备份一个,或者生成一段日志信息即可备份一段。由于日志管理可以采取段式文件的方式,因此,日志文件中可以有许多小片段的文件,如PostgreSQL的日志文件,是多个1G的文件组成,因此,可以实现上述日志的备份方式。
第二种类型,历史态数据点值备份,也即是,基于历史事务快照,可以对历史态数据和过渡态数据的备份,其备份数据包中包括元信息文件、历史态数据和过渡态数据的数据文件。下面以图3所示的数据备份方法的流程图,对历史态数据点值进行备份为例进行说明,具体地,该数据备份方法具体包括以下过程:
301、服务器接收备份任务,该备份任务用于对目标数据表的数据项进行备份。
上述备份任务所指示的备份时间包括一个历史时刻。
302、当该备份任务的备份时间为一个历史时刻时,获取第三历史事务快照,该第三历史事务快照为该历史时刻的事务快照。
303、基于该第三历史事务快照执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的可见版本。
在本申请实施例中,通过第三历史事务快照,可以根据第三历史事务快照对目标数据表中的数据项的各个版本进行可见性判断,从而确定在该快照创建时刻的可见版本,再对其进行备份,也即是备份所获取到的备份数据至少包括该目标数据表中数据项的历史态数据和过渡态数据。通过上述备份,不需要有日志文件的备份,所备份出的数据是数据项上的一个点值,需要通过逻辑的方式获取到数据项,从而生成数据文件等备份数据。
其中,可见性判断的步骤如下所述:
(一):当该版本为插入操作生成,当该创建时刻和该提交时刻均在该历史时间段之间,确定该版本可见。
(二):当该版本为删除操作生成,当该删除时刻和该提交时刻均在该历史时间段之间,确定该版本可见。
(三):当该版本为更新操作生成,当该创建时刻在该历史时间段的起始时刻之后,该提交时刻在该历史时间段之间,确定该版本可见。
上述图2和图3所示的对数据项的点值的备份,本申请实施例还涉及到以下两种对段值备份的情况,包括全态数据段值备份和历史态数据段值备份,这两种备份,均可以基于快照差进行,分别介绍如下:
第三种类型,全态数据段值备份,基于历史事务快照和常规事务快照,实现同一个数据项的多个版本的同时备份,其备份数据包中包括元信息文件、历史态数据和过渡态数据的数据文件、当前态数据以及日志文件。下面以图4所示的数据备份方法的流程图,对全态数据段值备份进行备份为例进行说明,具体地,该数据备份方法具体包括以下过程:
401、服务器接收备份任务,该备份任务用于对目标数据表的数据项进行备份。
上述备份任务所指示的备份时间包括以当前时刻为结束点的时间段。
402、当该备份任务的备份时间包括以当前时刻为结束点的时间段,获取第 四历史事务快照和第五历史事务快照之间的第二快照差,该第四历史事务快照和该第五历史事务快照分别为该时间段的起始时刻的事务快照和该当前时刻的常规事务快照。
403、根据该第二快照差,对当前态数据和该目标数据表中的可见版本进行备份,该备份数据至少包括该目标数据表中数据项的可见版本。
其中,对于当前态数据的备份可以与图2所示的当前态数据的备份方法同理,在此不做赘述。而基于第二快照差对历史态数据和过渡态数据进行的备份,可以基于逻辑读取的方式进行,也即是,基于该第二快照差,对目标数据表中的数据项的各个版本进行可见性判断,对可见版本进行备份。
而在一种实施方式中,由于历史态数据是以块存储的,因此,一个块的全部数据处于“历史事务快照段”的范围内,则进行块拷贝,备份速度快,一个块的部分数据处于“历史事务快照段”的范围内,则可以基于一定比例阈值,例如第一预设比例,来确定具体备份方式,例如,当数据块的大部分数据处于“历史事务快照段”的范围内,则进行块拷贝,备份速度快,但是无效的数据需要在元信息文件中被标识,例如在HMeta_00000001系列文件中标识,这种是通过块拷贝方式实现的,而小部分数据处于“历史事务快照段”的范围内,则采取逻辑读取的方式,把数据项的可见版本读出,写出到数据文件中,例如HData_00000001系列文件。但是历史态所处的范围的相关情况被记录到HMeta_00000001系列文件中,这种备份方式在本质上这是逻辑备份的方式。也即是,在本申请实施例中,为了提高备份效率,还可以采用基于块备份的一种备份方式,例如,服务器可以确定目标数据表的第二数据块,所述第二数据块存储有所述目标数据表的历史态数据;如果基于所述第二快照差,确定所述第二数据块所存储的历史态数据均为可见版本,以块拷贝的形式对所述第二数据块进行备份,得到备份数据。进一步地,如果基于所述第二快照差,确定所述第二数据块中可见版本的比例大于或等于第一预设比例时,以块拷贝的形式对所述第二数据块进行备份,对所述第二数据块中不可见的历史态数据进行标记,得到备份数据;如果基于所述第二快照差,确定所述第二数据块所存储的历史态数据中可见版本的比例小于所述第一预设比例时,以逻辑读取的形式读取所述第二数据块中的可见版本,得到备份数据。
在上述过程中,第一比例可以采用百分比的形式表示或者[0,1]范围内的小数来表示,例如,该第一比例的默认值为0.2,取值范围为[0,1]。
上述全态数据段值备份过程,是指备份数据中存在有当前态、过渡态、历史态的数据,且对于同一个数据项后两者不仅是一个时间点上的值,而是一个时间段上的多个值。其所备份的数据根据指定的快照类型(本质上是时间点还是时间段),可以分为如下内容:当前态数据的备份:一定是点值备份,方式同第一备份点。过渡态数据的备份(点值、段值):可能是点值也可能是段值。历史态数据的备份(点值、段值):可能是点值也可能是段值,本申请实施例不做赘述。
第四种类型,历史态数据点值备份,基于历史事务快照不包括常规事务快照,实现同一个数据项的多个版本的同时备份,其备份数据包中包括元信息文件、历史态数据和过渡态数据的数据文件。下面以图5所示的数据备份方法的流程图,对历史态数据点值备份进行备份为例进行说明,具体地,该数据备份方法具体包括以下过程:
501、服务器接收备份任务,该备份任务用于对目标数据表的数据项进行备份。
上述备份任务用于对目标数据表的数据项进行备份。
在本申请实施例中,服务器可以通过接收备份指令,来接收备份任务,该备份指令中会携带有关于备份目标的信息。该备份任务根据其指示的备份时间的不同,可以有不同的具体备份过程,本申请实施例仅以备份时间为历史时间段为例进行说明,也即是,该备份指令中包括该历史时间段的起始时刻和结束时刻,备份的目标数据为当前时刻以前的一个历史时间段内的历史态数据和过渡态数据。
502、当该备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,该第一历史事务快照和该第二历史事务快照分别为该历史时间段的起始时刻和结束时刻的事务快照。
503、根据该第一快照差执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的可见版本。
在本申请实施例中,基于第一快照差执行备份任务的过程与上述步骤303中基于第二快照差对历史态数据和过渡态数据进行备份的过程同理,在此不做赘述。进一步地,还可以在备份过程中,基于数据块中所存储的历史态数据来确定是采用块备份,还是采用物理备份,还是采用逻辑备份,从而提高备份效 率以及备份的灵活性,例如,服务器可以确定目标数据表的第一数据块,所述第一数据块存储有所述目标数据表的历史态数据;如果基于所述第一快照差,确定所述第一数据块所存储的历史态数据均为可见版本时,以块拷贝的形式对所述第一数据块进行备份,得到备份数据。进一步地,如果基于所述第一快照差,确定所述第一数据块中可见版本的比例大于或等于第一预设比例时,以块拷贝的形式对所述第一数据块进行备份,对所述第一数据块中不可见的历史态数据进行标记,得到备份数据;如果基于所述第一快照差,确定所述第一数据块所存储的历史态数据中可见版本的比例小于所述第一预设比例时,以逻辑读取的形式读取所述第二数据块中的可见版本,得到备份数据。
需要说明的一点是,在上述任一种实施方式中,对于在对过渡态数据进行备份时,对于同一个数据项的、满足备份条件的多个版本,在备份的过程中,可以单独存放到独立的文件中,文件以IData_00000001系列命名。对于过渡态数据的备份方式,可以采用逻辑读取的方式。
需要说明的又一点是,在上述任一种实施方式中,所述备份数据中的历史态数据和过渡态数据的元信息相关联,其相关联的元信息可以分别存储至文件名相关联的元信息文件中,例如,某一历史事务快照段或历史事务快照的过渡态数据存放在文件IData中、相关联的历史态数据存在于HData文件中,目的是在恢复的时候,便于把同一个数据项的属于同一个历史事务快照范围内的数据在恢复阶段合并。在另一种可能实施方式中,上述相关联的元信息还可以同时备份到元信息文件中,例如备份到以HMeta_00000001系列命名的文件中。上述相关联可以通过文件命名相关联,以便在进行数据恢复时确认过渡态和历史态数据之间的关系,能够保证数据的一致性。
进一步地,在在对元信息进行备份时,根据备份数据的元信息和所述备份数据的相关元信息构造元信息列表,基于所述元信息列表进行备份,得到元信息文件。该元信息的备份,由于数据量较小,用一个线程进行备份即可。
在一种可能实施方式中,还可以基于备份的不同粒度来进一步提高备份效率,备份的粒度包括:表空间级别的备份、文件级别的备份、文件块级别的备份、数据项级别的备份(如前述的逻辑备份方式)。数据库系统中多使用表空间的方式来管理数据,表空间,是逻辑概念,对上层(执行器和数据缓冲区)而言就是一个逻辑存储层,其屏蔽了物理层面的存储细节。但对于下层(操作系 统)而言,是一个存储管理器,可以管辖多个物理文件,甚至是网络存储。一个表空间中可以有多个数据文件,文件可以动态增加、删除。
由此,可以基于表空间粒度来进行备份,如果备份任务中不包括备份条件,例如WHERE条件,则直接备份目标数据表的表空间的元信息、表空间管辖的所有数据文件(可采用并行备份来备份多个数据文件)。
而如果备份任务中包括备份,例如WHERE条件,则可以从文件粒度进行备份,也即是,在备份过程中,当所述目标数据表中第一数据文件的数据项均符合所述备份任务的备份条件时,则备份所述第一数据文件。例如,如果WHERE条件覆盖一个数据文件的大部分,则直接备份对应的数据文件。
在备份过程中,当所述目标数据表中全部数据文件或是部分数据文件中均符合所述备份任务的备份条件时,且该部分数据文件占目标数据表的文件数的预设比例,则备份该多个数据文件或部分数据文件。例如,如果WHERE条件覆盖多个数据文件的大部分,则备份该多个数据文件。如果WHERE条件覆盖所有的数据文件的大部分,则并行备份所有的数据文件,实则是进行表空间粒度备份。
当所述目标数据表中第一数据文件的部分数据项符合所述备份任务的备份条件且所述部分数据项的比例大于或等于第二预设比例时,则备份所述第一数据文件,对所述第一数据文件中的无效数据进行标记。当所述目标数据表中第一数据文件的部分数据项符合所述备份任务的备份条件且所述部分数据项的比例小于所述第二预设比例时,以逻辑读取的形式读取所述第一数据文件中的数据项。例如,如果WHERE条件不能覆盖一个数据文件的大部分,则参照上述实施例提供的数据块备份方式,备份的方式可能采用块备份也可能是逻辑备份方式。
在本申请实施例中,为了提高备份效率,在上述任一种备份方法中,如果所述备份任务的备份目标包括多个数据表,支持并行对所述多个数据表进行备份,也即是,对于不同的表对象的备份,可以采取并行备份方式进行,例如,为每个数据表启动一个备份线程来执行备份。
在本申请实施例中,为了提高备份效率,在上述任一种备份方法中,如果所述备份任务的备份目标包括多个数据文件,支持并行对所述多个数据文件进行备份。
在本申请实施例中,为了提高备份效率,在上述任一种备份方法中,如果所述备份任务的备份目标包括多个数据块,支持并行对所述多个数据块进行备份。
上述三类并行备份的方式还可以至少两种方式结合来实现备份过程,以便最大程度上的提高备份效率,例如,对多个数据表和多个数据文件均采用并行备份方式进行,本申请实施例对结合方式不做具体限定。
对于本申请实施例所提及的三种备份方法,三者之间的差别例子如下:
示例1:逻辑备份的方式
BEGIN;
Set BACKUPNAME=‘/usr/bak/my_first_backup_02’READVIEW FROM'20180109000000'TO'20180119000000';//快照差方式做逻辑备份
BACKUP TYPE LO FROM my_table;
END;
示例2:物理备份的方式
BEGIN;
Set BACKUPNAME=‘/usr/bak/my_first_backup_04’READVIEW default;//基于常规事务快照做物理备份
BACKUP ALL;//备份整个系统,如果是备份某个表,则如“BACKUP FROM my_table;”
END;
示例3:混合备份的方式
BEGIN;
Set BACKUPNAME=‘/usr/bak/my_first_backup_04’READVIEW FROM'20180109000000'TO now();//快照差方式做混合备份,从历史的时间'20180109000000'起,直到本事务可见的所有已提交的数据都需要备份
BACKUP FROM my_table01,my_table02,my_table03;//备份指定的三个表,也可备份整个系统
可选地,在按照块备份方式进行备份时,数据块上的数据还存在两种情况:
第一种情况、不跨页,某数据块上符合条件的数据在本页的空间足够存储。
第二种情况、跨页:某数据块上符合条件的数据在本页的空间不够存储,后续有续接的页面存在。
基于上述情况,对于一个数据块,如果其不跨页,则其数据结构中的页尾部分,做特殊标识,表示本页之后的页与本页没有关联。如图6所示,可以在页面上增加数据有效位,该数据有效位可以用于表示本页数据是否跨页。在一种可能实施方式中,该数据有效位可以分为2部分,一部分是数据可见标识位,全部置0;余下一个bit位(称为跨页标识位)表示本页数据是否跨页,1表示跨页,0表示不跨页。当有跨页标识位存在时,则寻找数据时不能停止,继续读入下一页。
本申请实施例在时态数据库的基础上,提出了基于时态数据的备份方法使得对于全态数据中的任何状态的数据,都可以采取多种灵活的方式,例如逻辑方式或物理方式以及逻辑物理结合的方式来实现备份,为时态数据的有效存储和安全可靠性,提供了有效保障。
需要说明的是,上述实施例中所涉及的物理备份,例如块拷贝方式,可以适用于所有情况的数据备份,上述实施例中所涉及到的逻辑备份,即通过逻辑读取方式的备份,例如读取数据项的可见版本的方式,也可以适用于所有情况的数据备份。基于物理备份和逻辑备份的灵活结合,来实现数据备份,能够大大提高备份效率,本申请实施例对上述物理备份和逻辑备份的结合方式不做限定。以下述实施场景为例,通过上述物理备份和逻辑备份的结合可以制定各种备份策略,以在满足运营过程中的备份需求的同时,保证高效率的备份。
在一种实施场景中,可以将上述三种备份方法搭配,来制定备份策略,即什么时候采取什么手段(逻辑备份、物理备份)进行备份。可选的备份策略与传统的数据库备份策略相同,例如,一种可行的备份策略如下:每半年做一个数据库的全备份(包括所有的数据即全态数据),每一个月做一次零级备份(不包含只读表空间),每个星期做一次一级备份,每天做一次二级备份。该备份级别可以基于实际需求设定。而另一种可行的备份策略如下:采取双策略进行备份,即逻辑备份和物理备份结合。根据数据量和对数据丢失的容忍度,先定期做物理备份,然后在每2个完整的物理备份时间间隔内,做逻辑备份,通过执行上述备份策略,可以达到提高数据安全性和一致性的目的,还能够保证高效 率的备份。
需要说明的是,本申请实施例涉及的数据项的可见版本,是指在备份任务所对应的事务快照所对应时刻能够被事务所读取的版本。对于数据表内的任一元组的任一版本,根据事务快照以及所述版本的创建时刻、删除时刻以及所述版本的提交时刻,确定所述版本是否可见。服务器从数据表中每读取一条元组,均可以读取到该元组的生命周期信息,也即是该版本的创建时刻、删除时刻以及所述版本的提交时刻等信息,以基于历史时间段的可见性判断为例:
(一):当该版本为插入操作生成,当该创建时刻在该历史时间段的起始时刻之前,该提交时刻在该历史时间段之间,确定该版本可见;或者,当该创建时刻和该提交时刻均在该历史时间段之间,确定该版本可见。
(二):当该版本为删除操作生成,当该删除时刻在该历史时间段的起始时刻之前,该提交时刻在该历史时间段之间,确定该版本可见;或者,当该删除时刻和该提交时刻均在该历史时间段之间,确定该版本可见。
(三):当该版本为更新操作生成,当该创建时刻在该历史时间段的起始时刻之前,该提交时刻在该历史时间段之间,确定该版本可见;或者,当该创建时刻在该历史时间段的起始时刻之后,该提交时刻在该历史时间段之间,确定该版本可见。
应该理解的是,虽然图2-5的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-5中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交底地执行。
图7是本申请实施例提供的一种数据备份装置的结构示意图,参见图7,该装置包括:
接收模块701,用于接收备份任务,该备份任务用于对目标数据表的数据项进行备份;
获取模块702,用于当该备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,该第一历史事务快照和该 第二历史事务快照分别为该历史时间段的起始时刻和结束时刻的事务快照;
备份模块703,用于根据该第一快照差,执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的可见版本。
本申请实施例提供的装置,在时态数据库的基础上,提出了基于时态数据的备份方法使得对于全态数据中的任何状态的数据,都可以采取多种灵活的方式,例如逻辑方式或物理方式以及逻辑物理结合的方式来实现备份,为时态数据的有效存储和安全可靠性,提供了有效保障。
在一种可能实施方式中,该备份模块703还用于:
确定第一数据块,该第一数据块存储有该目标数据表的历史态数据;
如果基于该第一快照差,确定该第一数据块所存储的历史态数据均为可见版本,以块拷贝的形式对该第一数据块进行备份,得到备份数据。
在一种可能实施方式中,基于图7的装置组成,该装置还包括:
如果基于该第一快照差,确定该第一数据块中可见版本的比例大于或等于第一预设比例时,以块拷贝的形式对该第一数据块进行备份,对该第一数据块中不可见的历史态数据进行标记,得到备份数据;
如果基于该第一快照差,确定该第一数据块所存储的历史态数据中可见版本的比例小于该第一预设比例时,以逻辑读取的形式读取该第一数据块中的可见版本,得到备份数据。
在一种可能实施方式中,基于图7的装置组成,该装置还包括:
当该备份任务的备份时间为当前时刻时,获取该当前时刻的常规事务快照;
基于该常规事务快照,以块拷贝的形式对当前态数据所在的数据块进行备份,得到备份数据。
在一种可能实施方式中,基于图7的装置组成,该装置还包括:
当该备份任务的备份目标包括当前态数据,在备份过程的开始时刻直到该备份过程的结束时刻,对该当前态数据的日志文件进行分段备份。
在一种可能实施方式中,基于图7的装置组成,该装置还包括:
当该备份任务的备份时间为一个历史时刻时,获取第三历史事务快照,该第三历史事务快照为该历史时刻的事务快照;
根据该第三历史事务快照,执行该备份任务,得到备份数据,该备份数据至少包括该目标数据表中数据项的可见版本。
在一种可能实施方式中,基于图7的装置组成,该装置还包括:
当该备份任务的备份时间包括以当前时刻为结束点的时间段,获取第四历史事务快照和第五历史事务快照之间的第二快照差,该第四历史事务快照和该第五历史事务快照分别为该时间段的起始时刻的事务快照和该当前时刻的常规事务快照;
根据该第二快照差,对当前态数据和该目标数据表中的可见版本进行备份,该备份数据至少包括该目标数据表中数据项的可见版本。
在一种可能实施方式中,当该备份任务的备份目标包括历史态数据和过渡态数据,则该备份数据中包括该历史态数据和过渡态数据的元信息文件和数据文件。
在一种可能实施方式中,当该备份任务的备份目标包括当前态数据,则该备份数据中还包括该当前态数据的元信息文件、数据文件和日志文件。
在一种可能实施方式中,该备份数据中历史态数据和过渡态数据的元信息文件之间的文件命名相关联。
在一种可能实施方式中,该备份模块703还用于在对元信息进行备份时,根据备份目标的元信息和该备份目标的相关元信息构造元信息列表,基于该元信息列表进行备份,得到元信息文件。
在一种可能实施方式中,该备份数据的数据形式为:在目录下存储各类文件,或,存储为多个tar包。
在一种可能实施方式中,基于图7的装置组成,该装置还包括:
在备份过程中,当该目标数据表中第一数据文件的数据项均符合该备份任务的备份条件时,则备份该第一数据文件;
当该目标数据表中第一数据文件的部分数据项符合该备份任务的备份条件且该部分数据项的比例大于或等于第二预设比例时,则备份该第一数据文件,对该第一数据文件中的无效数据进行标记;
当该目标数据表中第一数据文件的部分数据项符合该备份任务的备份条件且该部分数据项的比例小于该第二预设比例时,以逻辑读取的形式读取该第一数据文件中的数据项。
在一种可能实施方式中,在执行该备份任务时,采用下述至少一种方式实现:
如果该备份任务的备份目标包括多个数据表,支持并行对该多个数据表进行备份;
如果该备份任务的备份目标包括多个数据文件,支持并行对该多个数据文 件进行备份;
如果该备份任务的备份目标包括多个数据块,支持并行对该多个数据块进行备份。
上述所有可选技术方案,可以采用任意结合形成本公开的可选实施例。
需要说明的是:上述实施例提供的数据备份装置在数据备份时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的数据备份装置与数据备份方法实施例属于同一构思,其具体实现过程详见方法实施例。
上述数据备份装置可以实现为一种计算机程序的形式,计算机程序可在终端上运行。终端上的存储介质中可存储组成该数据备份装置的各个程序模块,比如,图7所示的接收模块701、获取模块702和备份模块703。各个程序模块构成的计算机程序在被处理器执行时,使得处理器执行本申请各个实施例的推荐内容显示方法中的步骤。
图8是本申请实施例提供的一种服务器的结构示意图,该服务器800可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(central processing units,CPU)801和一个或一个以上的存储器802,其中,所述存储器802中存储有至少一条指令,所述至少一条指令由所述处理器801加载并执行以实现上述各个方法实施例提供的方法。当然,该服务器还可以具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该服务器还可以包括其他用于实现设备功能的部件。
该存储器802可以是非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质应用于服务器,该计算机可读存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,该指令、该程序、该代码集或该指令集由处理器加载并执行以实现上述实施例的数据备份方法中服务器所执行的操作。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。
Claims (20)
- 一种数据备份方法,由服务器执行,其特征在于,所述方法包括:接收备份任务,所述备份任务用于对目标数据表的数据项进行备份;当所述备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,所述第一历史事务快照和所述第二历史事务快照分别为所述历史时间段的起始时刻和结束时刻的事务快照;根据所述第一快照差执行所述备份任务,得到备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本。
- 根据权利要求1所述的方法,其特征在于,所述根据所述第一快照差执行所述备份任务,得到备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本包括:确定第一数据块,所述第一数据块存储有所述目标数据表的历史态数据;如果基于所述第一快照差,确定所述第一数据块所存储的历史态数据均为可见版本时,以块拷贝的形式对所述第一数据块进行备份,得到所述备份数据。
- 根据权利要求2所述的方法,其特征在于,所述方法还包括:如果基于所述第一快照差,确定所述第一数据块中可见版本的比例大于或等于第一预设比例时,以块拷贝的形式对所述第一数据块进行备份,对所述第一数据块中不可见的历史态数据进行标记,得到所述备份数据。
- 根据权利要求3所述的方法,其特征在于,所述方法还包括:如果基于所述第一快照差,确定所述第一数据块所存储的历史态数据中可见版本的比例小于所述第一预设比例时,以逻辑读取的形式读取所述第一数据块中的可见版本,得到所述备份数据。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:当所述备份任务的备份时间为当前时刻时,获取所述当前时刻的常规事务快照;基于所述常规事务快照,以块拷贝的形式对当前态数据所在的数据块进行备份,得到所述备份数据。
- 根据权利要求5所述的方法,其特征在于,所述方法还包括:当所述备份任务的备份目标包括当前态数据,在备份过程的开始时刻直到所述备份过程的结束时刻,对所述当前态数据的日志文件进行分段备份。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:当所述备份任务的备份时间为一个历史时刻时,获取第三历史事务快照,所述第三历史事务快照为所述历史时刻的事务快照;根据所述第三历史事务快照执行所述备份任务,得到所述备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:当所述备份任务的备份时间包括以当前时刻为结束点的时间段,获取第四历史事务快照和第五历史事务快照之间的第二快照差,所述第四历史事务快照和所述第五历史事务快照分别为所述时间段的起始时刻的事务快照和所述当前时刻的常规事务快照;根据所述第二快照差,对当前态数据和所述目标数据表中的可见版本进行备份,所述备份数据至少包括所述目标数据表中数据项的可见版本。
- 根据权利要求1所述的方法,其特征在于,当所述备份任务的备份目标包括历史态数据和过渡态数据,则所述备份数据中包括所述历史态数据和过渡态数据的元信息文件和数据文件;当所述备份任务的备份目标包括当前态数据,则所述备份数据中还包括所述当前态数据的元信息文件、数据文件和日志文件。
- 根据权利要求1所述的方法,其特征在于,所述备份数据中的历史态数据和过渡态数据的元信息文件之间的文件命名相关联。
- 根据权利要求1所述的方法,其特征在于,所述根据所述第一快照差执行所述备份任务,得到备份数据包括:在对元信息进行备份时,根据备份目标的元信息和所述备份目标的相关元信息构造元信息列表,基于所述元信息列表进行备份,得到元信息文件。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:在备份过程中,当所述目标数据表中第一数据文件的数据项均符合所述备份任务的备份条件时,则备份所述第一数据文件;当所述目标数据表中第一数据文件的部分数据项符合所述备份任务的备份条件且所述部分数据项的比例大于或等于第二预设比例时,则备份所述第一数据文件,对所述第一数据文件中的无效数据进行标记。
- 根据权利要求12所述的方法,其特征在于,所述方法还包括:当所述目标数据表中第一数据文件的部分数据项符合所述备份任务的备份条件且所述部分数据项的比例小于所述第二预设比例时,以逻辑读取的形式读 取所述第一数据文件中的数据项。
- 根据权利要求1所述的方法,其特征在于,在执行所述备份任务时,采用下述至少一种方式实现:如果所述备份任务的备份目标包括多个数据表,支持并行对所述多个数据表进行备份;如果所述备份任务的备份目标包括多个数据文件,支持并行对所述多个数据文件进行备份;如果所述备份任务的备份目标包括多个数据块,支持并行对所述多个数据块进行备份。
- 一种数据备份装置,其特征在于,所述装置包括:接收模块,用于接收备份任务,所述备份任务用于对目标数据表的数据项进行备份;获取模块,用于当所述备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,所述第一历史事务快照和所述第二历史事务快照分别为所述历史时间段的起始时刻和结束时刻的事务快照;备份模块,用于根据所述第一快照差执行所述备份任务,得到备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本。
- 一种服务器,其特征在于,所述服务器包括处理器和存储器,所述存储器中存储有至少一条指令,所述至少一条指令由该处理器加载并执行,使得所述服务器执行以下步骤:接收备份任务,所述备份任务用于对目标数据表的数据项进行备份;当所述备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,所述第一历史事务快照和所述第二历史事务快照分别为所述历史时间段的起始时刻和结束时刻的事务快照;根据所述第一快照差执行所述备份任务,得到备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本。
- 根据权利要求16所述的服务器,其特征在于,所述至少一条指令由该处理器加载并执行,使得所述服务器具体执行以下步骤:确定第一数据块,所述第一数据块存储有所述目标数据表的历史态数据;如果基于所述第一快照差,确定所述第一数据块所存储的历史态数据均为 可见版本时,以块拷贝的形式对所述第一数据块进行备份,得到所述备份数据。
- 根据权利要求17所述的服务器,其特征在于,所述至少一条指令由该处理器加载并执行,使得所述服务器还执行以下步骤:如果基于所述第一快照差,确定所述第一数据块中可见版本的比例大于或等于第一预设比例时,以块拷贝的形式对所述第一数据块进行备份,对所述第一数据块中不可见的历史态数据进行标记,得到所述备份数据。
- 一种计算机可读存储介质,其特征在于,所述存储介质中存储有至少一条指令,所述至少一条指令由该处理器加载并执行时,使得所述服务器执行以下步骤:接收备份任务,所述备份任务用于对目标数据表的数据项进行备份;当所述备份任务的备份时间为历史时间段时,获取第一历史事务快照和第二历史事务快照之间的第一快照差,所述第一历史事务快照和所述第二历史事务快照分别为所述历史时间段的起始时刻和结束时刻的事务快照;根据所述第一快照差执行所述备份任务,得到备份数据,所述备份数据至少包括所述目标数据表中数据项的可见版本。
- 根据权利要求19所述的计算机可读存储介质,其特征在于,所述至少一条指令由该处理器加载并执行,使得所述服务器具体执行以下步骤:确定第一数据块,所述第一数据块存储有所述目标数据表的历史态数据;如果基于所述第一快照差,确定所述第一数据块所存储的历史态数据均为可见版本时,以块拷贝的形式对所述第一数据块进行备份,得到所述备份数据。
Priority Applications (3)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| EP19890759.4A EP3822794B1 (en) | 2018-11-30 | 2019-11-29 | Data backup method and apparatus, server and computer readable storage medium |
| JP2021518656A JP7395227B2 (ja) | 2018-11-30 | 2019-11-29 | データバックアップ方法、装置、サーバ及びコンピュータプログラム |
| US17/178,453 US12001297B2 (en) | 2018-11-30 | 2021-02-18 | Data backup method and apparatus, server, and computer-readable storage medium |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811459580.5A CN110209528B (zh) | 2018-11-30 | 2018-11-30 | 数据备份方法、装置、服务器以及存储介质 |
| CN201811459580.5 | 2018-11-30 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US17/178,453 Continuation US12001297B2 (en) | 2018-11-30 | 2021-02-18 | Data backup method and apparatus, server, and computer-readable storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020108623A1 true WO2020108623A1 (zh) | 2020-06-04 |
Family
ID=67779956
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/122015 Ceased WO2020108623A1 (zh) | 2018-11-30 | 2019-11-29 | 数据备份方法、装置、服务器以及计算机可读存储介质 |
Country Status (5)
| Country | Link |
|---|---|
| US (1) | US12001297B2 (zh) |
| EP (1) | EP3822794B1 (zh) |
| JP (1) | JP7395227B2 (zh) |
| CN (1) | CN110209528B (zh) |
| WO (1) | WO2020108623A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114461443A (zh) * | 2020-11-09 | 2022-05-10 | 腾讯科技(深圳)有限公司 | 一种展示数据生成方法、装置及存储介质 |
| CN116756135A (zh) * | 2023-07-11 | 2023-09-15 | 星环信息科技(上海)股份有限公司 | 一种数据清理方法、装置、设备及介质 |
| CN116842071A (zh) * | 2023-06-26 | 2023-10-03 | 中国建设银行股份有限公司 | 业务数据存储方法、装置、电子设备及存储介质 |
Families Citing this family (15)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110209527B (zh) | 2018-11-30 | 2023-05-05 | 腾讯科技(深圳)有限公司 | 数据恢复方法、装置、服务器以及存储介质 |
| CN110209528B (zh) | 2018-11-30 | 2022-10-28 | 腾讯科技(深圳)有限公司 | 数据备份方法、装置、服务器以及存储介质 |
| CN110851302B (zh) * | 2019-10-31 | 2021-06-18 | 上海爱数信息技术股份有限公司 | 一种数据库信息的备份方法及恢复方法 |
| CN113138877B (zh) * | 2020-01-17 | 2024-04-19 | 伊姆西Ip控股有限责任公司 | 用于管理备份系统的方法、设备和计算机程序产品 |
| CN112948176B (zh) * | 2021-02-23 | 2023-09-15 | 上海上讯信息技术股份有限公司 | 一种db2数据库恢复的方法及设备 |
| CN113780380B (zh) * | 2021-08-27 | 2024-10-15 | 上海数禾信息科技有限公司 | 数据处理方法、装置、系统、存储介质及计算机设备 |
| CN116264634B (zh) * | 2021-12-14 | 2025-09-12 | 荣耀终端股份有限公司 | 拍摄方法、电子设备及系统 |
| CN116974983A (zh) * | 2022-04-24 | 2023-10-31 | 腾讯科技(深圳)有限公司 | 数据处理方法、装置、计算机可读介质及电子设备 |
| CN115454717B (zh) * | 2022-09-16 | 2023-05-05 | 广州鼎甲计算机科技有限公司 | 数据库实时备份方法、装置、计算机设备和存储介质 |
| CN116107996B (zh) * | 2022-12-30 | 2026-03-20 | 浪潮数字粮储科技有限公司 | 一种基于数据仓库的数据版本管理方法、设备及介质 |
| US12346222B2 (en) * | 2023-10-26 | 2025-07-01 | Dell Products L.P. | System and method for backing up data from edge infrastructures |
| CN117667521A (zh) * | 2023-12-15 | 2024-03-08 | 中电云计算技术有限公司 | 数据备份方法、装置、设备及计算机可读存储介质 |
| CN118331795B (zh) * | 2024-06-17 | 2024-10-11 | 天津南大通用数据技术股份有限公司 | 在线备份设备和方法 |
| CN119336543B (zh) * | 2024-10-15 | 2025-07-04 | 广州鼎甲计算机科技有限公司 | 指纹库恢复方法、装置、计算机设备、可读存储介质和程序产品 |
| CN121210216B (zh) * | 2025-11-27 | 2026-02-06 | 苏州元脑智能科技有限公司 | 数据备份方法、装置、设备、介质及计算机程序产品 |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102591744A (zh) * | 2010-12-17 | 2012-07-18 | 微软公司 | 从任何群集节点的数据的备份和还原 |
| CN104375904A (zh) * | 2014-10-30 | 2015-02-25 | 浪潮电子信息产业股份有限公司 | 一种基于快照差异化数据传输的容灾备份方法 |
| CN106610875A (zh) * | 2015-10-23 | 2017-05-03 | 先智云端数据股份有限公司 | 混合备份还原管理系统及其备份方法、还原方法 |
| CN107077495A (zh) * | 2014-10-19 | 2017-08-18 | 微软技术许可有限责任公司 | 数据库管理系统中的高性能事务 |
| US20170286228A1 (en) * | 2016-03-30 | 2017-10-05 | Acronis International Gmbh | System and method for data protection during full data backup |
| CN107835983A (zh) * | 2015-04-16 | 2018-03-23 | 诺宝公司 | 使用一致的数据库快照在分布式数据库中进行备份和还原 |
| CN110209528A (zh) * | 2018-11-30 | 2019-09-06 | 腾讯科技(深圳)有限公司 | 数据备份方法、装置、服务器以及存储介质 |
Family Cites Families (17)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7100089B1 (en) * | 2002-09-06 | 2006-08-29 | 3Pardata, Inc. | Determining differences between snapshots |
| US7831639B1 (en) * | 2004-12-22 | 2010-11-09 | Symantec Operating Corporation | System and method for providing data protection by using sparse files to represent images of data stored in block devices |
| JP4668763B2 (ja) * | 2005-10-20 | 2011-04-13 | 株式会社日立製作所 | ストレージ装置のリストア方法及びストレージ装置 |
| US20070277012A1 (en) | 2006-05-23 | 2007-11-29 | Hitachi, Ltd. | Method and apparatus for managing backup data and journal |
| JP5211514B2 (ja) | 2007-03-09 | 2013-06-12 | 富士通株式会社 | 更新装置、更新方法および更新プログラム |
| US8635187B2 (en) | 2011-01-07 | 2014-01-21 | Symantec Corporation | Method and system of performing incremental SQL server database backups |
| US9817834B1 (en) * | 2012-10-01 | 2017-11-14 | Veritas Technologies Llc | Techniques for performing an incremental backup |
| US9336090B2 (en) * | 2012-10-10 | 2016-05-10 | Hitachi, Ltd. | Storage apparatus comprising snapshot function, and storage control method |
| US9098522B2 (en) * | 2012-11-29 | 2015-08-04 | Sap Se | Version garbage collection using snapshot lists |
| US10725966B1 (en) * | 2014-06-30 | 2020-07-28 | Veritas Technologies Llc | Block level incremental backup for QCOW2 virtual disks |
| CN104778095B (zh) | 2015-01-20 | 2017-11-17 | 成都携恩科技有限公司 | 一种云平台数据管理方法 |
| CN106445738B (zh) * | 2016-09-13 | 2020-10-16 | 苏州浪潮智能科技有限公司 | 一种数据库备份方法及装置 |
| US10545995B2 (en) * | 2017-05-22 | 2020-01-28 | Sap Se | Validating query results during asynchronous database replication |
| CN110309233B (zh) | 2018-03-28 | 2022-11-15 | 腾讯科技(深圳)有限公司 | 数据存储的方法、装置、服务器和存储介质 |
| CN110309122B (zh) | 2018-03-28 | 2022-12-30 | 腾讯科技(深圳)有限公司 | 获取增量数据的方法、装置、服务器和存储介质 |
| CN110196758A (zh) | 2018-05-10 | 2019-09-03 | 腾讯科技(深圳)有限公司 | 数据处理方法和装置、存储介质及电子装置 |
| US11126505B1 (en) * | 2018-08-10 | 2021-09-21 | Amazon Technologies, Inc. | Past-state backup generator and interface for database systems |
-
2018
- 2018-11-30 CN CN201811459580.5A patent/CN110209528B/zh active Active
-
2019
- 2019-11-29 EP EP19890759.4A patent/EP3822794B1/en active Active
- 2019-11-29 WO PCT/CN2019/122015 patent/WO2020108623A1/zh not_active Ceased
- 2019-11-29 JP JP2021518656A patent/JP7395227B2/ja active Active
-
2021
- 2021-02-18 US US17/178,453 patent/US12001297B2/en active Active
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102591744A (zh) * | 2010-12-17 | 2012-07-18 | 微软公司 | 从任何群集节点的数据的备份和还原 |
| CN107077495A (zh) * | 2014-10-19 | 2017-08-18 | 微软技术许可有限责任公司 | 数据库管理系统中的高性能事务 |
| CN104375904A (zh) * | 2014-10-30 | 2015-02-25 | 浪潮电子信息产业股份有限公司 | 一种基于快照差异化数据传输的容灾备份方法 |
| CN107835983A (zh) * | 2015-04-16 | 2018-03-23 | 诺宝公司 | 使用一致的数据库快照在分布式数据库中进行备份和还原 |
| CN106610875A (zh) * | 2015-10-23 | 2017-05-03 | 先智云端数据股份有限公司 | 混合备份还原管理系统及其备份方法、还原方法 |
| US20170286228A1 (en) * | 2016-03-30 | 2017-10-05 | Acronis International Gmbh | System and method for data protection during full data backup |
| CN110209528A (zh) * | 2018-11-30 | 2019-09-06 | 腾讯科技(深圳)有限公司 | 数据备份方法、装置、服务器以及存储介质 |
Non-Patent Citations (1)
| Title |
|---|
| See also references of EP3822794A4 * |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114461443A (zh) * | 2020-11-09 | 2022-05-10 | 腾讯科技(深圳)有限公司 | 一种展示数据生成方法、装置及存储介质 |
| CN116842071A (zh) * | 2023-06-26 | 2023-10-03 | 中国建设银行股份有限公司 | 业务数据存储方法、装置、电子设备及存储介质 |
| CN116756135A (zh) * | 2023-07-11 | 2023-09-15 | 星环信息科技(上海)股份有限公司 | 一种数据清理方法、装置、设备及介质 |
| CN116756135B (zh) * | 2023-07-11 | 2024-04-23 | 星环信息科技(上海)股份有限公司 | 一种数据清理方法、装置、设备及介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110209528A (zh) | 2019-09-06 |
| CN110209528B (zh) | 2022-10-28 |
| US12001297B2 (en) | 2024-06-04 |
| EP3822794A1 (en) | 2021-05-19 |
| JP2022501747A (ja) | 2022-01-06 |
| US20210173747A1 (en) | 2021-06-10 |
| EP3822794B1 (en) | 2022-10-12 |
| EP3822794A4 (en) | 2021-09-15 |
| JP7395227B2 (ja) | 2023-12-11 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| EP3822794B1 (en) | Data backup method and apparatus, server and computer readable storage medium | |
| US11061928B2 (en) | Snapshots and forks of storage systems using distributed consistent databases implemented within an object store | |
| US11755427B2 (en) | Fast recovery and replication of key-value stores | |
| KR102579190B1 (ko) | 일관된 데이터베이스 스냅샷들을 이용한 분산 데이터베이스에서의 백업 및 복원 | |
| CN102722449B (zh) | 基于SSD的Key-Value型本地存储方法及系统 | |
| CN102906743B (zh) | 混合oltp和olap高性能数据库系统 | |
| US10437662B2 (en) | Crash recovery using non-volatile memory | |
| EP2356560B1 (en) | Atomic multiple modification of data in a distributed storage system | |
| CN110209527B (zh) | 数据恢复方法、装置、服务器以及存储介质 | |
| US11921704B2 (en) | Version control interface for accessing data lakes | |
| US9311311B2 (en) | Archival management of database logs | |
| US11829291B2 (en) | Garbage collection of tree structure with page mappings | |
| US20230385265A1 (en) | Data lake with transactional semantics | |
| US11836116B2 (en) | Managing operations between heterogeneous file systems | |
| US20230409545A1 (en) | Version control interface supporting time travel access of a data lake | |
| WO2019184618A1 (zh) | 数据存储的方法、装置、服务器和存储介质 | |
| US10896168B2 (en) | Application-defined object logging through a file system journal | |
| US12596616B1 (en) | System and method for generating a digital backup of database applications to allow join operations | |
| Li | SEV: a Storage-Efficient Versioning File System |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19890759 Country of ref document: EP Kind code of ref document: A1 |
|
| ENP | Entry into the national phase |
Ref document number: 2019890759 Country of ref document: EP Effective date: 20210210 |
|
| ENP | Entry into the national phase |
Ref document number: 2021518656 Country of ref document: JP Kind code of ref document: A |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |