CN113742140B - File backup method and device and computing equipment - Google Patents

File backup method and device and computing equipment Download PDF

Info

Publication number
CN113742140B
CN113742140B CN202111291528.5A CN202111291528A CN113742140B CN 113742140 B CN113742140 B CN 113742140B CN 202111291528 A CN202111291528 A CN 202111291528A CN 113742140 B CN113742140 B CN 113742140B
Authority
CN
China
Prior art keywords
file
snapshot
directory
time
disk
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.)
Active
Application number
CN202111291528.5A
Other languages
Chinese (zh)
Other versions
CN113742140A (en
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.)
Uniontech Software Technology Co Ltd
Original Assignee
Uniontech Software Technology Co Ltd
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 Uniontech Software Technology Co Ltd filed Critical Uniontech Software Technology Co Ltd
Priority to CN202210142422.7A priority Critical patent/CN114490192A/en
Priority to CN202111291528.5A priority patent/CN113742140B/en
Publication of CN113742140A publication Critical patent/CN113742140A/en
Application granted granted Critical
Publication of CN113742140B publication Critical patent/CN113742140B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion

Abstract

The invention discloses a file backup method, a file backup device and computing equipment, wherein the method comprises the following steps: reading an original file in a disk into an internal memory to obtain a cache file; receiving one or more write operations on a cache file, and modifying the cache file according to the write operations to obtain a new cache file; writing the new cache file into a disk to generate a file snapshot corresponding to the current time point; and writing the new cache file back to the original file in the disk. According to the technical scheme of the invention, the automatic file modification process and the double backup of the initial file are realized, and the method and the device are suitable for various file systems.

Description

File backup method and device and computing equipment
Technical Field
The present invention relates to the technical field of computers and operating systems, and in particular, to a file backup method, a backup apparatus, and a computing device.
Background
A computer is used as a terminal device of an information system, and a large amount of file data often exists on an operating system of the computer. To prevent accidental loss or modification of system files, operating systems typically provide backup facilities for backing up directories or files.
In the prior art, a file backup is implemented by using a snapshot function provided by a file system, for example, a btrfs file system may generate a snapshot by using a child volume, and use a snapshot file as a backup file. According to the technical scheme, the files in the file system can only be backed up through the snapshot function provided by the file system, so that the snapshot function is limited to a specific file system, for example, in a Linux system, only a btrfs file system supports the snapshot function, but file systems such as ext3, ext4, xfs, fat, vfat and the like do not support the snapshot function. In OS operating systems, however, the file system is usually a mixture of file systems, so that file backup cannot be realized by this scheme. In addition, the above technical solutions require a human to create the backup file through a tool, and the backup file cannot be automatically generated in real time.
In another technical scheme, the entire file is copied by a copying tool such as cp and rsync, and only the changed file is incrementally copied based on the first complete copy, and the copied file is used as a backup file. The scheme has large backup space, needs manual creation of backup files through a tool, cannot generate the backup files in real time, and has a single corresponding relation between the backup catalog and the backup files, so that the backup of the files and the catalog is not systematized.
For this reason, a file backup method is needed to solve the problems in the above technical solutions.
Disclosure of Invention
To this end, the present invention provides a file backup method and apparatus in an attempt to solve, or at least alleviate, the problems identified above.
According to one aspect of the present invention, there is provided a file backup method, executed in an operating system of a computing device, the method comprising the steps of: reading an original file in a disk into an internal memory to obtain a cache file; receiving one or more write operations on a cache file, and modifying the cache file according to the write operations to obtain a new cache file; writing the new cache file into a disk to generate a file snapshot corresponding to the current time point; and writing the new cache file back to the original file in the disk.
Optionally, in the file backup method according to the present invention, the step of writing the new cached file to a disk to generate a file snapshot corresponding to the current time point includes: determining the interval time between the current time point and the time point corresponding to the last file snapshot; judging whether the interval time exceeds preset time or not; and if the preset time is exceeded, writing the new cache file into a disk to generate a file snapshot corresponding to the current time point.
Optionally, in the file backup method according to the present invention, before writing the new cached file into a disk and generating a file snapshot corresponding to the current time point, the method further includes: and copying the copy of the original file in a disk.
Optionally, in the file backup method according to the present invention, the step of copying the copy of the original file in the disk includes: and judging whether at least one file snapshot exists in the disk, and if not, copying the copy of the original file in the disk.
Optionally, in the file backup method according to the present invention, after generating the file snapshot corresponding to the current time point, the method includes the steps of: establishing association among the file snapshot, the current time point and the index node of the original file to generate a file snapshot and time relation table; the file snapshot and time relation table comprises a plurality of time points, and each time point is associated with one or more snapshots of the original file.
Optionally, in the file backup method according to the present invention, the disk includes a snapshot storage device, and the file snapshot and time relation table is adapted to be stored in the snapshot storage device; the snapshot storage device is further adapted to store directory snapshot information corresponding to each directory, where the directory snapshot information includes time points and index nodes corresponding to one or more directory snapshots.
Optionally, in the file backup method according to the present invention, the method further includes: receiving an access request for a target directory snapshot based on a directory name; acquiring corresponding directory snapshot information from a snapshot storage device based on the directory name; acquiring corresponding file information based on each index node in the directory snapshot information, and generating a directory file and time relation table based on time points corresponding to one or more directory snapshots and corresponding file information; and generating a target directory snapshot and time relation table based on the directory file and time relation table and the file snapshot and time relation table, and returning to the target directory snapshot and time relation table.
Optionally, in the file backup method according to the present invention, the step of generating a target directory snapshot and time relation table based on the directory file and time relation table and the file snapshot and time relation table includes: filtering the file snapshots and the time relation table based on the file information corresponding to each time point in the directory file and time relation table to obtain one or more file snapshots corresponding to each time point and obtain the directory snapshot corresponding to each time point; generating the target directory snapshot and time relationship table based on the directory snapshot corresponding to each time point.
According to an aspect of the present invention, there is provided a backup apparatus residing in an operating system, including: the reading module is suitable for reading an original file in the disk into an internal memory to obtain a cache file; the write-in module is suitable for receiving one or more write-in operations on the cache file, and modifying the cache file according to the write-in operations to obtain a new cache file; the snapshot generating module is suitable for writing the new cache file into a disk so as to generate a file snapshot corresponding to the current time point; and the write-back module is suitable for writing the new cache file back to an original file in the disk.
According to an aspect of the present invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the file backup method as described above.
According to an aspect of the present invention, there is provided a readable storage medium storing program instructions which, when read and executed by a computing device, cause the computing device to perform the method as described above.
According to the technical scheme of the invention, the file snapshot is respectively generated aiming at the write-in operation of a user at each time point, so that the data of the modification process of the file at each time point can be recorded, and the original file data is permanently reserved in the disk by copying the copy of the original file in the disk. In this way, an automatic file modification process and a dual backup of the initial file are achieved. It should be noted that the backup method of the present invention is performed in an operating system, and is applicable to various file systems, and is not limited to a specific file system.
In addition, according to the technical scheme of the invention, when the interval time between the write operation and the last write operation exceeds the preset time, the file snapshot is generated as the backup file according to the write operation on the cache file, so that the phenomenon that a large amount of unnecessary snapshot data is generated to occupy the disk space is avoided.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a computing device 100, according to one embodiment of the invention;
FIG. 2 illustrates a flow diagram of a file backup method 200 according to one embodiment of the invention;
FIG. 3 illustrates a process diagram for generating a file snapshot according to one embodiment of the present invention;
FIG. 4 illustrates a schematic diagram of a file snapshot versus time table in accordance with one embodiment of the present invention;
FIG. 5 is a diagram illustrating a table of directory files versus time according to one embodiment of the invention;
FIG. 6 is a diagram illustrating a target directory snapshot and a schedule, according to one embodiment of the invention; and
fig. 7 shows a schematic diagram of a backup device 700 according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 is a schematic block diagram of an example computing device 100.
As shown in FIG. 1, in a basic configuration 102, a computing device 100 typically includes a system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between the processor 104 and the system memory 106.
Depending on the desired configuration, the processor 104 may be any type of processing, including but not limited to: a microprocessor (UP), a microcontroller (UC), a digital information processor (DSP), or any combination thereof. The processor 104 may include one or more levels of cache, such as a level one cache 110 and a level two cache 112, a processor core 114, and registers 116. The example processor core 114 may include an Arithmetic Logic Unit (ALU), a Floating Point Unit (FPU), a digital signal processing core (DSP core), or any combination thereof. The example memory controller 118 may be used with the processor 104, or in some implementations the memory controller 118 may be an internal part of the processor 104.
Depending on the desired configuration, system memory 106 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 may include an operating system 120, one or more applications 122, and program data 124. In some implementations, the application 122 can be arranged to execute instructions on an operating system with program data 124 by one or more processors 104.
Computing device 100 also includes a storage device 132, storage device 132 including removable storage 136 and non-removable storage 138.
Computing device 100 may also include a storage interface bus 134. The storage interface bus 134 enables communication from the storage devices 132 (e.g., removable storage 136 and non-removable storage 138) to the basic configuration 102 via the bus/interface controller 130. At least a portion of the operating system 120, applications 122, and data 124 may be stored on removable storage 136 and/or non-removable storage 138, and loaded into system memory 106 via storage interface bus 134 and executed by the one or more processors 104 when the computing device 100 is powered on or the applications 122 are to be executed.
Computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus/interface controller 130. The example output device 142 includes an image processing unit 148 and an audio processing unit 150. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 158. An example communication device 146 may include a network controller 160, which may be arranged to facilitate communications with one or more other computing devices 162 over a network communication link via one or more communication ports 164.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in a manner that encodes information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
Computing device 100 may be implemented as a personal computer including both desktop and notebook computer configurations. Of course, computing device 100 may also be implemented as part of a small-form factor portable (or mobile) electronic device such as a cellular telephone, a digital camera, a Personal Digital Assistant (PDA), a personal media player device, a wireless web-watch device, a personal headset, an application specific device, or a hybrid device that include any of the above functions. And may even be implemented as a server, such as a file server, a database server, an application server, a WEB server, and so forth. The embodiments of the present invention are not limited thereto.
In an embodiment in accordance with the invention, the computing device 100 is configured to perform a file backup method 200 in accordance with the invention. The operating system 120 of the computing device 100 includes a plurality of program instructions for executing the file backup method 200 of the present invention, which may instruct a processor to execute the file backup method 200 of the present invention, so that the computing device 100 can back up files of various file systems by executing the file backup method 200 of the present invention.
According to an embodiment of the present invention, a backup apparatus 700 resides in the operating system 120, and the backup apparatus 700 includes a plurality of program instructions for executing the file backup method 200 of the present invention, so that the file backup method 200 of the present invention can be executed in the backup apparatus 700, so that the backup apparatus 700 can implement backup of files of each file system by executing the file backup method of the present invention.
FIG. 2 shows a flow diagram of a file backup method 200 according to one embodiment of the invention. The file backup method 200 may be performed in an operating system of a computing device, such as the computing device 100 described above. The operating system may be implemented, for example, as a Linux operating system.
It should be noted that, in the specific embodiment, the file backup method 200 is specifically described only by taking the Linux operating system as an example. However, it should be understood that the file backup method 200 of the present invention is not limited to the particular type of operating system that performs the method, and those skilled in the art will appreciate that the method can be implemented on other types of operating systems as well, such as the Windows operating system, without the need for creative efforts. Any kind of operating system that can implement the backup of the files of each file system by the method of the present invention is within the scope of the present invention.
In the embodiment of the present invention, the computing device 100 includes a disk adapted to store file data, and a kernel of the operating system is connected to the disk, and can read data in the disk.
As shown in fig. 2, the method 200 begins at step S210.
In step S210, the kernel of the operating system reads the original file in the disk, and reads the original file in the disk into the memory of the computing device to obtain the cache file. Here, the original cache file without modification is identical to the original file data.
In step S220, one or more write operations to the cache file are received, and the cache file is modified according to the write operations to obtain a new cache file.
Here, it should be noted that the write operation to the cache file may be performed once or more times, the time of each write operation differs, and the data in the new cache file obtained after each write operation is changed from the data in the cache file before the current write operation.
Subsequently, in step S230, the new cached file is written to the disk to generate a file snapshot corresponding to the current time point. Here, the time point corresponding to the file snapshot is also the time point at which the file snapshot is generated. In one implementation, the cache file is written to disk by a writeback queue or sync system in the kernel, which may call do _ writes () in the kernel to write the data in memory (cache file) to disk.
According to one embodiment, a predetermined time may be preset, and when the interval time between the write operation and the last write operation exceeds the predetermined time, the file snapshot may be generated as the backup file according to the write operation on the cache file, so as to avoid generating a large amount of unnecessary snapshot data and occupying the disk space.
Specifically, before generating a file snapshot corresponding to the current point in time, the point in time corresponding to the last file snapshot may be obtained from the snapshot storage. And then determining the interval time between the current time point and the time point corresponding to the last file snapshot, and judging whether the interval time exceeds the preset time. And if the preset time is exceeded, writing the new cache file into the disk to generate a file snapshot corresponding to the current time point. If the preset time is not exceeded, the interval time is short, the operations of writing the new cache file into the disk and generating the file snapshot are not executed, and the file snapshot corresponding to the current time point cannot be generated, so that the storage space is saved.
Finally, in step S240, the new cache file is written back to the original file in the disk.
Additionally, in one embodiment, a copy of the original file may be copied in disk before performing step S230. Specifically, before step S230 is executed, it is determined whether at least one file snapshot already exists in the snapshot data storage device of the disk, and if no file snapshot exists (which indicates that the file is the first write operation to the cached file), a copy of the original file is copied in the disk.
If at least one file snapshot exists, the current writing operation is not the first writing operation on the cache file, and the previous operation of copying the copy of the original file in the disk is also described, so that the copy of the original file does not need to be copied in the disk, and the new cache file is directly written in the disk to generate the file snapshot corresponding to the current time point.
It should be noted that the present invention generates file snapshots respectively for the write operation of the user at each time point, so as to record the modification process data of the file at each time point, and to make the original file data permanently retained in the disk by copying the copy of the original file in the disk. In this way, a double backup of the file modification process and the initial file is achieved.
FIG. 3 illustrates a process diagram for generating a file snapshot according to one embodiment of the present invention. The process of generating multiple file snapshots at multiple points in time for one original file fileA is described in detail below in conjunction with fig. 3.
As shown in fig. 3, in the first step, the original file fileA in the disk is read into the Cache, and the initial Cache file is represented as the Cache. At this time, the Cache file data is the same as the file data of fileA.
And step two, receiving a first write-in operation on the initial Cache file Cache at the time point t1, and modifying the Cache file Cache according to the first write-in operation to obtain a first new Cache file Cache t 1.
And thirdly, copying the original file A in the disk to obtain an original file COPY.
Step four, writing the first new Cache file Cache t1 into the disk to generate a snapshot t1 of the original file a corresponding to the time point t 1.
Step four may be performed while step five is performed.
And step five, writing the first new Cache file Cache t1 back to the original file fileA in the disk, thereby updating the original file.
And sixthly, recording the corresponding relation between the time point t1 and the snapshot t1, and storing the corresponding relation in a snapshot storage device (database).
Step seven, at the time point of t2, a write operation (i.e., a second write operation on the Cache file) to the first new Cache file Cache t1 is received, and the first new Cache file Cache t1 is modified according to the write operation to obtain a second new Cache file Cache t 2.
Subsequently, as in the fourth to sixth steps, the second new Cache file Cache t2 is written into the disk to generate a snapshot t2 corresponding to the time point t 2. And writing the second new Cache file Cache t2 back to the fileA in the disk. And recording the corresponding relation between the time point t2 and the snapshot t2, and storing the corresponding relation in a snapshot storage device (database).
Next, at a time point t3, a write operation on the second new Cache file Cache t2 (that is, a third write operation on the Cache file) may be received, and the second new Cache file Cache t2 is modified according to the write operation, so as to obtain a third new Cache file Cache t 3. Subsequently, as in the fourth to sixth steps, the third new Cache file Cache t3 is written into the disk to generate a snapshot t3 corresponding to the time point t 3. And writing the third new Cache file Cache t3 back to the fileA in the disk. And recording the corresponding relation between the time point t3 and the snapshot t3, and storing the corresponding relation in a snapshot storage device (database).
Similarly, at the time point tN, a write operation on the Cache file is received, and the Cache file is modified according to the write operation to obtain a new Cache file, namely, the Cache tN. And then, as in the fourth to sixth steps, writing the Cache tN into the disk to generate a snapshot tN corresponding to the tN time point. And writing the Cache tN back to the fileA in the disk. And recording the corresponding relation between the time point tN and the snapshot tN, and storing the corresponding relation in a snapshot storage device (database).
It should be appreciated that as the write operation to the cache file is performed at time t 1-tN, the data of the cache file changes over time, and the original file fileA in the disk is continuously updated. And the snapshot snapshots 1-snapshot tN generated at each time point record the modification process data of the file at each time point.
According to one embodiment, a snapshot storage is included on the disk. After generating the file snapshot corresponding to the current time point, the file snapshot may be stored in a snapshot storage of the disk. Specifically, the file snapshot, the time point of snapshot generation (i.e., the current time point), and the index node of the original file are associated to generate a file snapshot and time relation table, and the file snapshot and the time relation table are stored in the snapshot storage device.
The file snapshot and time relation table is created based on snapshots of a plurality of files, time points of snapshot creation, index nodes of original files corresponding to the snapshots, and associations between the index nodes and the original files. After the file snapshot corresponding to the current time point is generated each time, the file snapshot, the current time point and the index node of the original file are respectively associated and stored in a file snapshot and time relation table in a snapshot storage device. In this way, the file snapshot and time relationship table may reflect an association relationship among a plurality of time points, index nodes of a plurality of original files, and a plurality of file snapshots corresponding to each original file, in other words, a snapshot of a plurality of original files at each time point may be determined according to the file snapshots and the time relationship table.
FIG. 4 illustrates a diagram of a file snapshot versus time table, according to one embodiment of the invention.
As shown in FIG. 4, the file snapshot-to-time relationship table includes a plurality of time points, for example, time points including t1, t2, t3, t4, t5, t6, and t7, each time point may be associated with one or more snapshots of an original file, and each original file may include a snapshot of a file generated at one or more time points. Here, the original files include, for example, file a, file B, file C … …, file N. As shown in FIG. 4, the snapshots of File A include, for example, the A1 snapshot generated at time t1, the A2 snapshot generated at time t2, the A3 snapshot generated at time t4, and the A4 snapshot generated at time t 7. The snapshots of file B include, for example, the B1 snapshot generated at time t2, and the B2 snapshot generated at time t 5. The snapshots of file C include, for example, the C1 snapshot generated at time t1, the C2 snapshot generated at time t3, the C3 snapshot generated at time t5, and the C4 snapshot generated at time t 7. The snapshots of file N include, for example, the N1 snapshot generated at time t1, the N2 snapshot generated at time t2, and the N3 snapshot generated at time t 6.
According to one embodiment, the snapshot storage device may further store directory snapshot information corresponding to each directory, where the directory snapshot information includes time points corresponding to one or more directory snapshots and inodes of one or more files corresponding to the directory snapshots. Here, the directory name may be stored in association with the directory snapshot information, so that the corresponding directory snapshot information may be obtained by querying based on the directory name.
In addition, the snapshot storage device also contains file information of one or more files, and the file information is stored in association with the index node of the file, so that the corresponding file information can be queried from the snapshot storage device based on the index node of the file.
In one embodiment, a user may request access to a target directory snapshot corresponding to a directory name by entering the directory name. Here, the target directory snapshot contains a snapshot of all files under the target directory.
When receiving an access request of a user to the target directory snapshot based on the directory name, acquiring corresponding directory snapshot information from the snapshot storage device based on the directory name. As described above, the directory snapshot information includes time points corresponding to one or more directory snapshots and inodes of one or more files corresponding to the directory snapshots.
Subsequently, the corresponding file information is obtained from the snapshot storage device based on each inode in the directory snapshot information. A directory file to time relationship table is generated based on the time points corresponding to the one or more directory snapshots and the corresponding file information. Here, fig. 5 shows a schematic diagram of a directory file and time relation table according to an embodiment of the present invention.
As shown in fig. 5, the time points corresponding to the one or more directory snapshots include t1, t2, t3, t4, t5, t6, and t7, where each time point is a time point at which one directory snapshot is generated, and each time point corresponds to one or more file information under a directory. For example, the file information corresponding to the time point t1 includes file a, file B, file C, and file N, the file information corresponding to the time point t2 includes file a, file C, and file N, the file information corresponding to the time point t3 includes file B, file … …, and the file information corresponding to the time point t7 includes file a, file C, and file N.
Next, a target directory snapshot and time relationship table is generated based on the directory file and time relationship table (as shown in FIG. 5) and the file snapshot and time relationship table (as shown in FIG. 4), and the target directory snapshot and time relationship table is returned. FIG. 6 illustrates a diagram of a target directory snapshot and a schedule, according to one embodiment of the invention.
Specifically, when the target directory snapshot and the time relation table are generated, filtering may be performed in the file snapshot and time relation table based on one or more file information corresponding to each time point in the directory file and time relation table to obtain one or more file snapshots corresponding to each time point, and the directory snapshot corresponding to each time point may be obtained based on the one or more file snapshots corresponding to the time points. In this way, a target directory snapshot to time relationship table may be generated based on the directory snapshot corresponding to each point in time.
As shown in fig. 5 and 6, the file information corresponding to the directory at the time point t2 includes a file a, a file C, and a file N, and then the directory snapshot corresponding to the time point t2 is composed of one or more file snapshots closest to the time point t2, and based on this, the directory snapshot corresponding to the time point t2 includes a2 snapshot, a C1 snapshot, and an N2 snapshot. Similarly, the directory snapshots corresponding to the time point t5 include a B2 snapshot, a C3 snapshot, and an N2 snapshot.
In the finally generated target directory snapshot and time relation table, each time point corresponds to one or more file snapshots under the directory, and the one or more file snapshots form the directory snapshot corresponding to the time point.
Therefore, according to the method, the target directory snapshot and the time relation table can be obtained only by inputting the directory name, so that the user can view the snapshot content of the specified directory at each time point.
Fig. 7 shows a schematic diagram of a backup device 700 according to an embodiment of the invention. The backup apparatus 700 resides in an operating system of a computing device (e.g., the computing device 100) and is adapted to perform the file backup method 200 of the present invention. A disk adapted to store file data is included in the computing device 100.
The backup device 700 includes a reading module 710, a writing module 720, a snapshot generating module 730, and a write-back module 740 connected in sequence. The reading module 710 may read an original file in the disk to the memory to obtain a cache file. The write-in module 720 is adapted to receive one or more write-in operations on the cache file, and modify the cache file according to the write-in operations to obtain a new cache file. The snapshot generating module 730 is adapted to write the new cached file to the disk to generate a file snapshot corresponding to the current time point. The write back module 740 is adapted to write back the new cached file to the original file in the disk.
It should be noted that the reading module 710 is configured to execute the aforementioned step S210, the writing module 720 is configured to execute the aforementioned step S220, the snapshot generating module 730 is configured to execute the aforementioned step S230, and the write-back module 740 is configured to execute the aforementioned step S240. Here, the specific execution logic of the reading module 710, the writing module 720, the snapshot generating module 730, and the write-back module 740 is as described in the foregoing steps S210 to S240 in the method 200, and is not described herein again.
According to the file backup scheme of the invention, the file snapshots of each time point are respectively generated aiming at the write operation of a user at each time point, so that the modification process data of the file at each time point can be recorded, and the original file data is permanently reserved in the disk by copying the copy of the original file in the disk. In this way, an automatic file modification process and a dual backup of the initial file are achieved. It should be noted that the backup method of the present invention is performed in an operating system, and is applicable to various file systems, and is not limited to a specific file system.
In addition, according to the technical scheme of the invention, when the interval time between the write operation and the last write operation exceeds the preset time, the file snapshot is generated as the backup file according to the write operation on the cache file, so that the phenomenon that a large amount of unnecessary snapshot data is generated to occupy the disk space is avoided.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to execute the file backup method of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, readable media may comprise readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense, and the scope of the present invention is defined by the appended claims.

Claims (6)

1. The file backup method is executed in an operating system of a computing device, the computing device comprises a disk, and the disk comprises a snapshot storage device, and the method comprises the following steps:
reading an original file in a disk into an internal memory to obtain a cache file;
receiving one or more write operations on a cache file, and modifying the cache file according to the write operations to obtain a new cache file;
determining the interval time between the current time point and the time point corresponding to the last file snapshot, judging whether the interval time exceeds the preset time, and if the interval time exceeds the preset time, writing the new cache file into a disk to generate the file snapshot corresponding to the current time point;
establishing association among the file snapshot, the current time point and the index node of the original file to generate a file snapshot and time relation table, and storing the file snapshot and the time relation table in the snapshot storage device, wherein the file snapshot and time relation table comprises a plurality of time points, each time point is associated with one or more snapshots of the original file, so as to determine the snapshots of the original file at each time point according to the file snapshot and time relation table, the snapshot storage device is further suitable for storing directory snapshot information corresponding to each directory, and the directory snapshot information comprises the time points and the index nodes corresponding to one or more directory snapshots;
writing the new cache file back to an original file in a disk;
receiving an access request for a target directory snapshot based on a directory name;
acquiring corresponding directory snapshot information from a snapshot storage device based on the directory name;
acquiring corresponding file information based on each index node in the directory snapshot information, and generating a directory file and time relation table based on time points corresponding to one or more directory snapshots and corresponding file information;
and generating a target directory snapshot and time relation table based on the directory file and time relation table and the file snapshot and time relation table, and returning to the target directory snapshot and time relation table.
2. The method of claim 1, wherein before writing the new cached file to disk, generating a snapshot of the file corresponding to the current point in time, further comprising the steps of:
and copying the copy of the original file in a disk.
3. The method of claim 2, wherein copying the copy of the original file in disk comprises:
and judging whether at least one file snapshot exists in the disk, and if not, copying the copy of the original file in the disk.
4. A backup device residing in an operating system of a computing device, the computing device including a disk, the disk including a snapshot storage device thereon, the backup device comprising:
the reading module is suitable for reading an original file in the disk into an internal memory to obtain a cache file;
the write-in module is suitable for receiving one or more write-in operations on the cache file, and modifying the cache file according to the write-in operations to obtain a new cache file;
the snapshot generating module is suitable for determining the interval time between the current time point and the time point corresponding to the last file snapshot, judging whether the interval time exceeds the preset time, and if the interval time exceeds the preset time, writing the new cache file into a disk to generate the file snapshot corresponding to the current time point; the method comprises the steps of establishing a snapshot storage device, wherein the snapshot storage device is suitable for establishing association among a file snapshot, a current time point and an index node of an original file to generate a file snapshot and time relation table, and storing the file snapshot and the time relation table in the snapshot storage device, wherein the file snapshot and time relation table comprises a plurality of time points, each time point is associated with one or more snapshots of the original file, so that the snapshot of the original file at each time point is determined according to the file snapshot and time relation table, the snapshot storage device is further suitable for storing directory snapshot information corresponding to each directory, and the directory snapshot information comprises the time points and the index node corresponding to one or more directory snapshots; and
the write-back module is suitable for writing the new cache file back to an original file in the disk;
wherein the backup device is further adapted to:
receiving an access request for a target directory snapshot based on a directory name;
acquiring corresponding directory snapshot information from a snapshot storage device based on the directory name;
acquiring corresponding file information based on each index node in the directory snapshot information, and generating a directory file and time relation table based on time points corresponding to one or more directory snapshots and corresponding file information;
and generating a target directory snapshot and time relation table based on the directory file and time relation table and the file snapshot and time relation table, and returning to the target directory snapshot and time relation table.
5. A computing device, comprising:
at least one processor; and
a memory storing program instructions, wherein the program instructions are configured to be adapted to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any of claims 1-3.
6. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method of any of claims 1-3.
CN202111291528.5A 2021-11-03 2021-11-03 File backup method and device and computing equipment Active CN113742140B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210142422.7A CN114490192A (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment
CN202111291528.5A CN113742140B (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111291528.5A CN113742140B (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment

Related Child Applications (1)

Application Number Title Priority Date Filing Date
CN202210142422.7A Division CN114490192A (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment

Publications (2)

Publication Number Publication Date
CN113742140A CN113742140A (en) 2021-12-03
CN113742140B true CN113742140B (en) 2022-03-18

Family

ID=78727281

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210142422.7A Pending CN114490192A (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment
CN202111291528.5A Active CN113742140B (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202210142422.7A Pending CN114490192A (en) 2021-11-03 2021-11-03 File backup method and device and computing equipment

Country Status (1)

Country Link
CN (2) CN114490192A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577329A (en) * 2013-10-18 2014-02-12 华为技术有限公司 Snapshot management method and device
US8874524B1 (en) * 2012-06-22 2014-10-28 Emc Corporation Handling copy on first write data for snapshot purposes
CN108733761A (en) * 2014-12-27 2018-11-02 华为技术有限公司 A kind of data processing method apparatus and system
CN113297007A (en) * 2021-02-08 2021-08-24 阿里巴巴集团控股有限公司 Data processing method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101295276B (en) * 2008-06-20 2010-06-09 中国科学院计算技术研究所 Magnetic disk data backup system and method
US8635187B2 (en) * 2011-01-07 2014-01-21 Symantec Corporation Method and system of performing incremental SQL server database backups
CN109491961B (en) * 2018-10-22 2022-02-18 郑州云海信息技术有限公司 File system snapshot method and snapshot device
CN110515767A (en) * 2019-08-09 2019-11-29 济南浪潮数据技术有限公司 Snapshot data backup method, device, equipment and readable storage medium storing program for executing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8874524B1 (en) * 2012-06-22 2014-10-28 Emc Corporation Handling copy on first write data for snapshot purposes
CN103577329A (en) * 2013-10-18 2014-02-12 华为技术有限公司 Snapshot management method and device
CN108733761A (en) * 2014-12-27 2018-11-02 华为技术有限公司 A kind of data processing method apparatus and system
CN113297007A (en) * 2021-02-08 2021-08-24 阿里巴巴集团控股有限公司 Data processing method and device

Also Published As

Publication number Publication date
CN113742140A (en) 2021-12-03
CN114490192A (en) 2022-05-13

Similar Documents

Publication Publication Date Title
US8904137B1 (en) Deduplication system space recycling through inode manipulation
CN112988252B (en) Operating system starting method and computing device
US10891074B2 (en) Key-value storage device supporting snapshot function and operating method thereof
CN113568566B (en) Method for seamless migration of simple storage service by index object, main device and storage server
CN113032032B (en) System management method and device, computing equipment and readable storage medium
CN113157290B (en) Multi-system installation method, computing equipment and storage medium
CN113553010A (en) Optical disc file checking method, optical disc recording method and computing device
US10783073B2 (en) Chronologically ordered out-of-place update key-value storage system
CN114860670A (en) File operation method of user space file system and user space file system
CN113568787A (en) Power failure protection method, computing device and storage medium
CN114942863A (en) Cascade snapshot processing method, device and equipment and storage medium
CN114691226A (en) Multi-operating-system switching operation method, computing device and storage medium
CN113742140B (en) File backup method and device and computing equipment
CN113377289A (en) Cache management method, system, computing device and readable storage medium
CN115150392B (en) Remote file copying method, system, computing equipment and storage medium
WO2022222351A1 (en) Method for installing operating system, and computing device
CN114546678A (en) Method for copying and pasting data, computing equipment and readable storage medium
US20190332685A1 (en) Set-based mutual exclusion using object metadata tags in a storage appliance
CN114691549A (en) File writing method and device and computing equipment
CN113535650A (en) File naming method and computing device
CN113655960A (en) Optical disc readability repairing method and computing device
CN109857719B (en) Distributed file processing method, device, computer equipment and storage medium
CN113761075A (en) Method, device, equipment and computer readable medium for switching databases
US11755425B1 (en) Methods and systems for synchronous distributed data backup and metadata aggregation
CN114528257A (en) Method for centrally pasting files, computing equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant