Embodiment
For ease of the understanding to the embodiment of the present invention, be further explained explanation below in conjunction with accompanying drawing as an example of several specific embodiments example, and each embodiment does not form the restriction to the embodiment of the present invention.
Embodiment mono-
On the enforcement hardware of the embodiment of the present invention, depend on a storage medium, this storage medium can be: UKey or USB flash disk etc., other parts are all realized by software.The hierarchical design of a kind of data backup and resume scheme that the embodiment of the present invention provides realizes schematic diagram as shown in Figure 1, wherein, " business datum layer " represents two class data to be backed up in this programme: data file, comprise database file and other data files, and adopt timed backup; Tables of data operation, comprises tables of data action type (increase, revise, delete) and service data, and employing is backed up in realtime." backup and recovery management layer " comprised interface, realization, data-switching that backup is relevant with recovery operation, and the follow-up for anomaly of data and the management of backup medium etc." dielectric layer " provides the general read and write access interface to backup medium, and the function on it is realized and hardware independent.The direction indication data flow of arrow in Fig. 1.
The treatment scheme schematic diagram of the method for a kind of data backup and resume that the embodiment of the present invention provides as shown in Figure 2, comprises following treatment step:
Step 21, when set timed backup condition meet after, data file is carried out to timed backup and obtains backup data files, described backup data files is stored in storage medium, described data file comprises database file.
Described timed backup condition comprises: timing occurs or the data of backing up in realtime occur extremely to, timed events, and above-mentioned timing can be 1 day or 1 week or January etc.The mode of backup data files can adopt the mode of direct copying, and above-mentioned backup data files is stored in above-mentioned storage medium with source document form.
In actual applications, can be backup data files corresponding to this data file by data file transition by timed backup data transformation interface, above-mentioned timed backup data transformation interface can be:
Int FileBackup (char*filename); The data file that // backup is specified.
Step 22, after the tables of data in database is carried out tables of data operation, to described tables of data, operation is backed up in realtime and is obtained tables of data operation backup file, and described tables of data operation backup file is stored in storage medium.
Backup " tables of data operation " is immediately following after the tables of data operation of each business procedure, i.e. a tables of data operation of every execution follows once the backup operation of " tables of data operation " closely, has reached the object of backing up in realtime.
In actual applications, can tables of data operand be converted to this tables of data by the data transformation interface of backing up in realtime and operate corresponding tables of data operation backup file, the above-mentioned data transformation interface of backing up in realtime can be:
Int TabletoBakData (char*bakdata, int*length, void*table); // tables of data operand is converted to bak, write backup file.
Int AddRecord (void*table); The tables of data operation of record is once added in // backup, calls TabletoBakData;
Int Update (char*sql); The tables of data operation of an amendment record of // backup
Int Delete (char*sql); The tables of data operation of a deletion record of // backup
Data item in the operation of described tables of data is as described in Table 1:
Table 1
The tables of data operation backup file of backing up in realtime is with XML(extend markup language, ExtensibleMarkup Language) file, JASON file or self-defining binary file be stored in above-mentioned storage medium, and the file of backing up in realtime can be selected the one of XML, JASON or user-defined format.
Above-mentioned tables of data operation backup file can be stored with the unit of being recorded as, the operation of every corresponding tables of data of record.The record of above-mentioned tables of data operation backup file can be classified according to tables of data title, and the order from arriving first sorts according to the running time.
Step 23, the backup data files of timed backup is recovered, obtained each tables of data information in database, the tables of data operation backup file of backing up in realtime is recovered, obtain the tables of data operation information of each tables of data.
In the time carrying out data recovery, the backup data files of timed backup is recovered, obtain each tables of data information in database.
In actual applications, can recover data transformation interface by timing backup data files corresponding data file is converted to data file, above-mentioned timed backup data transformation interface can be:
Int FileRestore (char*filename); The data file that // recovery is specified
Also need the tables of data operation backup file to backing up in realtime to recover, obtain the tables of data operation information of each tables of data.The tables of data operation recovering is classified according to the title of tables of data, and the order from arriving first sorts according to the running time.
In actual applications, can tables of data be operated to corresponding tables of data operation backup file by real-time recovery data transformation interface and be converted to tables of data operation, the above-mentioned data transformation interface of backing up in realtime can be:
Int Restore (int operation, char*bakData); // recover a data table handling record, call BakDatatoTable;
Then,, for the tables of data recovering, the order according to the running time from arriving first is carried out the tables of data recovering operation corresponding to this tables of data successively, successively each tables of data is carried out to aforesaid operations, thereby recovers the end-state of whole database.
The backup of the backup of " data file " and " tables of data operation " is all atomic operation, should ensure the interruptions such as power-off do not occur in backup procedure, otherwise will cause Backup Data imperfect.
Actual should in, can carry out data exception inspection to data table handling backup file, data exception inspection refers to and checks that whether the data of backing up in realtime correctly complete.Between the corresponding tables of data operation backup file of storing in the current data of each tables of data when system starts at every turn in comparison database and backup medium, there is bias free, as find that there is inconsistent situation, execute the once backup operation of " data file ".Once " data file " backs up successfully, remove the corresponding tables of data operation backup file of storing in backup medium.
Embodiment bis-
The concrete structure of the device of a kind of data backup and resume that this embodiment provides as described in Figure 3, comprises following module:
Timedbackup module 31, after meeting, carries out timed backup to data file and obtains backup data files for the timed backup condition when setting, and described data file comprises database file.
Themodule 32 of backing up in realtime, for the tables of data of database is being carried out after tables of data operation, backs up in realtime and obtains tables of data operation backup file described tables of data operation;
The tables of data operation backup file of backing up in realtime is classified according to tables of data title, and the order according to the running time from arriving first sorts, described tables of data operation comprises: tables of data title, action type, running time, SQL condition field, SQL amendment value field and data object, described action type comprises: add, revise and delete.
Storage medium 33, for storing described backup data files and tables of data operation backup file.
Recovery processing module 34, recovers for the backup data files to timed backup, obtains each tables of data information in database, and the tables of data operation backup file of backing up in realtime is recovered, and obtains the tables of data operation information of each tables of data;
For the tables of data recovering, the order according to the running time from arriving first is carried out the tables of data recovering operation corresponding to this tables of data successively, thereby recovers the end-state of whole database.
Abnormalitydetection processing module 35, for checking that the corresponding tables of data of storing in current data and the backup medium of each tables of data of database operates between backup file and has bias free, if there is deviation, carry out once the backup operation of the data file in described database, after this backup operation completes, remove the corresponding tables of data operation backup file of storing in backup medium.
One of ordinary skill in the art will appreciate that: accompanying drawing is the schematic diagram of an embodiment, the module in accompanying drawing or flow process might not be that enforcement the present invention is necessary.
One of ordinary skill in the art will appreciate that: the module in the equipment in embodiment can be described and be distributed in the equipment of embodiment according to embodiment, also can carry out respective change and be arranged in the one or more equipment that are different from the present embodiment.The module of above-described embodiment can be merged into a module, also can further split into multiple submodules.
The detailed process and the preceding method embodiment that carry out data backup and resume with the device of the embodiment of the present invention are similar, repeat no more herein.
One of ordinary skill in the art will appreciate that all or part of flow process realizing in above-described embodiment method, can carry out the hardware that instruction is relevant by computer program to complete, described program can be stored in a computer read/write memory medium, this program, in the time carrying out, can comprise as the flow process of the embodiment of above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random AccessMemory, RAM) etc.
In sum, the method that the embodiment of the present invention has adopted timed backup and backed up in realtime and combine, both ensured the integrality of backup, ensure again the efficiency of backup, accomplish that i.e. damage recovers, recovers to realize simple and release time is shorter, can realize the concerning taxes terminal devices such as above-mentioned tax-control cash register, network billing machine are carried out to backup and recovery effectively.
The embodiment of the present invention is according to the requirement of concrete network invoice system scheme, can use general medium such as network billing machine intrinsic UKey or USB flash disk etc. to do storage medium, database in network billing machine and other data files are backed up in realtime, once there is aforementioned fault, can fast Backup Data be returned in another brand-new backup network billing machine by the backup information on UKey or USB flash disk, it is reached and the identical state of former network billing machine.
The embodiment of the present invention has fully taken into account the low feature of middle low performance operation for embedded system speed, and backup can not delay the requirement of the business of making out an invoice, and can meet in time user's needs of making out an invoice.
The above; only for preferably embodiment of the present invention, but protection scope of the present invention is not limited to this, is anyly familiar with in technical scope that those skilled in the art disclose in the present invention; the variation that can expect easily or replacement, within all should being encompassed in protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.