A file backup method, device and computing equipment
By reading disk files into memory from the operating system, caching file modifications, and generating file snapshots at predetermined time intervals, the system solves the problems of automation and storage efficiency in existing file backup technologies, and achieves real-time dual backup of multiple file systems.
Patent Information
- Application Number
- CN202210142422.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-03
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2041-11-03
AI Technical Summary
In existing technologies, file backup methods cannot achieve automated, real-time backup across multiple file systems, and backup files occupy a large amount of space, with simple backup relationships and a lack of systematization.
The system reads disk files into memory from the operating system, caches file modifications, and generates file snapshots at predetermined time intervals. Combined with a snapshot storage device to record the file modification process, it achieves automated backup.
It enables automated file backup across multiple file systems, reducing unnecessary snapshot data, saving storage space, and retaining the original file data to form a dual backup.
Smart Images

Figure CN114490192B_ABST
Abstract
Description
[0001] This application is a divisional application of the invention patent application 2021112915285 filed on November 3, 2021. TECHNICAL FIELD
[0002] The present application relates to the technical field of computer and operating system, in particular to a file backup method, backup device and computing device. BACKGROUND
[0003] As a terminal device of information system, computer often has a large amount of file data on its operating system. In order to prevent accidental loss or modification of system files, the operating system usually provides backup tools for backing up directories or files.
[0004] One of the prior art technical solutions is to realize file backup through the snapshot function provided by the file system. For example, the btrfs file system can generate snapshots through the subvolume method, and the snapshot file is used as the backup file. This technical solution can only realize the backup of files in the file system through the snapshot function provided by the file system itself, which limits the snapshot function to a specific file system. For example, in the Linux system, only the btrfs file system supports the snapshot function, but the ext3, ext4, xfs, fat, vfat and other file systems do not support the snapshot function. In the OS operating system, the file system is usually a mixture of multiple file systems, so this solution cannot realize file backup. In addition, the above technical solution needs to manually create backup files through tools, and the backup files cannot be generated automatically in real time.
[0005] Another technical solution is to copy the entire file through cp, rsync and other copy tools, make incremental copy of the changed files based on the first complete copy, and use the copied files as backup files. This solution has large backup space and needs to manually create backup files through tools. The backup files cannot be generated in real time, and the backup directory and the backup file are a single corresponding relationship. The backup of files and directories is not systematic.
[0006] Therefore, a file backup method is needed to solve the problems in the above technical solutions. SUMMARY
[0007] Therefore, the present application provides a file backup method and device to try to solve or at least alleviate the above problems.
[0008] According to an aspect of the present application, there is provided a file backup method, executed in an operating system of a computing device, comprising the steps of: reading an original file in a disk into a memory to obtain a cache file; receiving one or more write operations on the cache file, modifying the cache file according to the write operations to obtain a new cache file; writing the new cache file to the disk to generate a file snapshot corresponding to a current time point; and writing back the new cache file to the original file in the disk.
[0009] Optionally, in the file backup method according to the present application, the step of writing the new cache file to the disk to generate a file snapshot corresponding to a current time point comprises the steps of: determining an interval time between the current time point and a time point corresponding to a last file snapshot; judging whether the interval time exceeds a predetermined time; and if yes, writing the new cache file to the disk to generate a file snapshot corresponding to the current time point.
[0010] Optionally, in the file backup method according to the present application, before the step of writing the new cache file to the disk to generate a file snapshot corresponding to a current time point, there is further included a step of copying a copy of the original file in the disk.
[0011] Optionally, in the file backup method according to the present application, the step of copying a copy of the original file in the disk comprises the steps of: judging whether there is at least one file snapshot in the disk; and if not, copying the copy of the original file in the disk.
[0012] Optionally, in the file backup method according to the present application, after the step of generating a file snapshot corresponding to a current time point, there is included a step of associating the file snapshot, the current time point, and an inode of the original file to generate a file snapshot and time relationship table; wherein the file snapshot and time relationship table comprises a plurality of time points, each of which is associated with one or more snapshots of original files.
[0013] Optionally, in the file backup method according to the present application, the disk comprises a snapshot storage device, and the file snapshot and time relationship 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, the directory snapshot information comprising time points and inodes corresponding to one or more directory snapshots.
[0014] Optionally, in the file backup method according to the present application, the method further comprises the steps of: receiving an access request of a target directory snapshot based on a directory name; obtaining corresponding directory snapshot information from the snapshot storage device based on the directory name; obtaining corresponding file information based on each index node in the directory snapshot information, and generating a directory file and time relationship table based on the corresponding time point of one or more directory snapshots and the corresponding file information; generating a target directory snapshot and time relationship table based on the directory file and time relationship table and the file snapshot and time relationship table, and returning the target directory snapshot and time relationship table.
[0015] Optionally, in the file backup method according to the present application, the step of generating a target directory snapshot and time relationship table based on the directory file and time relationship table and the file snapshot and time relationship table comprises: filtering in the file snapshot and time relationship table based on the file information corresponding to each time point in the directory file and time relationship table to obtain one or more file snapshots corresponding to each time point, to obtain a directory snapshot corresponding to each time point; and generating the target directory snapshot and time relationship table based on the directory snapshot corresponding to each time point.
[0016] According to an aspect of the present application, there is provided a backup device residing in an operating system, comprising: a reading module adapted to read an original file in a disk into a memory to obtain a cache file; a writing module adapted to receive one or more write operations on the cache file, modify the cache file according to the write operations to obtain a new cache file; a snapshot generation module adapted to write the new cache file into the disk to generate a file snapshot corresponding to a current time point; and a write-back module adapted to write back the new cache file to the original file in the disk.
[0017] According to an aspect of the present application, 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, and the program instructions comprise instructions for performing the file backup method as described above.
[0018] According to an aspect of the present application, 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.
[0019] According to the technical scheme of the present application, a file backup method and device are provided, which respectively generate file snapshots for 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 a copy of the original file is copied in the disk to permanently retain the initial data of the original file in the disk. In this way, automatic double backup of the file modification process and the initial file is realized. It should be pointed out that the backup method of the present application is executed in an operating system and is applicable to various file systems and is not limited to a specific file system.
[0020] In addition, according to the technical scheme of the present application, when the interval time between the write operation and the last write operation exceeds a predetermined time, a file snapshot is generated as a backup file according to the write operation on the cache file, so as to avoid occupying the disk space by generating a large amount of unnecessary snapshot data.
[0021] The above description is only a summary of the technical scheme of the present application. In order to more clearly understand the technical means of the present application, the present application can be implemented according to the content of the specification, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS
[0022] 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. These aspects are indicative of various ways in which the principles disclosed herein can be practiced and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The foregoing and other objects, features, and advantages of the disclosure will be apparent from the following description of certain aspects as described below in connection with the accompanying drawings. Aspects of the disclosure will be described with accompanying drawings, which serve to explain various principles of the disclosure. The same reference numerals in different drawings represent the same or similar functionalities.
[0023] Figure 1 A schematic diagram of a computing device 100 according to one embodiment of the present application is shown;
[0024] Figure 2 A flowchart of a file backup method 200 according to one embodiment of the present application is shown;
[0025] Figure 3 A process diagram of generating a file snapshot according to one embodiment of the present application is shown;
[0026] Figure 4 A schematic diagram of a file snapshot and time relationship table according to one embodiment of the present application is shown;
[0027] Figure 5 A schematic diagram of a directory file and time relationship table according to one embodiment of the present application is shown;
[0028] Figure 6A schematic diagram of a target directory snapshot and time relationship table according to an embodiment of the present invention is shown; and
[0029] Figure 7 A schematic diagram of a backup device 700 according to an embodiment of the present invention is shown. Detailed Implementation
[0030] Exemplary embodiments of the present disclosure will now be described in more detail 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 implemented 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.
[0031] Figure 1 This is a schematic block diagram of an example computing device 100.
[0032] like Figure 1 As shown, in the basic configuration 102, the computing device 100 typically includes a system memory 106 and one or more processors 104. A memory bus 108 can be used for communication between the processors 104 and the system memory 106.
[0033] Depending on the desired configuration, processor 104 can be any type of processor, including but not limited to: microprocessor (UP), microcontroller (UC), digital information processor (DSP), or any combination thereof. Processor 104 may include one or more levels of cache such as L1 cache 110 and L2 cache 112, processor core 114, and registers 116. Example processor core 114 may include an arithmetic logic unit (ALU), floating-point unit (FPU), digital signal processing core (DSP core), or any combination thereof. Example memory controller 118 may be used with processor 104, or in some implementations, memory controller 118 may be an internal part of processor 104.
[0034] Depending on the desired configuration, system memory 106 can 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 operating system 120, one or more applications 122, and program data 124. In some embodiments, application 122 may be arranged to execute instructions on the operating system using program data 124 by one or more processors 104.
[0035] The computing device 100 also includes storage 132, which can include removable storage 136 and non-removable storage 138.
[0036] The computing device 100 can also include a storage interface bus 134. The storage interface bus 134 enables communication between the storage 132 (e.g., removable storage 136 and non-removable storage 138) and the basic configuration 102 via the bus / interface controller 130. At least a portion of the operating system 120, the application programs 122, and the data 124 can be stored in the removable storage 136 and / or the non-removable storage 138 and loaded into the system memory 106 via the storage interface bus 134 when a computing device 100 is booted or an application 122 is loaded into the computing device 100.
[0037] The computing device 100 can 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. Example output devices 142 include a graphics processing unit 148 and an audio processing unit 150. They can be configured to facilitate communication to various external devices such as a display or speakers via one or more A / V ports 152. Example peripheral interfaces 144 can include a serial interface controller 154 or a parallel interface controller 156, which can be configured to facilitate communication to various external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripheral devices (e.g., printer, scanner, etc.) via one or more I / O ports 158. An example communication device 146 can include a network controller 160, which can 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.
[0038] The network communication link can be one example of a communication media. Communication media can typically be embodied by computer readable instructions, data structures, program modules, and / or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and can include any information delivery media. A "modulated data signal" can be a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media can include wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, radio frequency (RF), microwave, infrared (IR) and other wireless media. The term computer readable media as used herein can include both storage media and communication media.
[0039] The computing device 100 can be implemented as a personal computer including desktop and notebook configurations. Of course, the computing device 100 can also be implemented as part of a small form factor portable (or mobile) electronic device such as a cell phone, a digital camera, a personal digital assistant (PDA), a personal media player device, a wireless web browsing device, a personal headset, an application-specific device, or a hybrid device that can include any of the above functions. The computing device 100 can even be implemented as a server, such as a file server, a database server, an application server, and a web server, etc. Embodiments of the present application are not limited in this regard.
[0040] In an embodiment according to the present application, the computing device 100 is configured to perform the file backup method 200 according to the present application. In this embodiment, the operating system 120 of the computing device 100 contains a plurality of program instructions for performing the file backup method 200 according to the present application, which can instruct the processor to perform the file backup method 200 according to the present application, so that the computing device 100 can perform the file backup method 200 according to the present application to backup files of each file system.
[0041] According to an embodiment of the present application, the operating system 120 contains a backup device 700, which contains a plurality of program instructions for performing the file backup method 200 according to the present application, so that the file backup method 200 according to the present application can be performed in the backup device 700, and the backup device 700 can perform the file backup method 200 according to the present application to backup files of each file system.
[0042] Figure 2 A flow chart of the file backup method 200 according to an embodiment of the present application is shown. The file backup method 200 can be performed in an operating system of a computing device, such as the computing device 100 described above. The operating system can be implemented as a Linux operating system, for example.
[0043] It should be noted that in specific embodiments, the file backup method 200 according to the present application is described in detail only with respect to a Linux operating system. However, it should be understood that the file backup method 200 according to the present application is not limited to the specific type of operating system in which the method is performed, and those skilled in the art will understand that the method can be implemented in other types of operating systems, such as a Windows operating system, without the need for inventive labor. Any type of operating system that can perform the file backup method 200 according to the present application to backup files of each file system is within the scope of the present application.
[0044] In an embodiment of the present application, the computing device 100 includes a disk adapted to store file data, and the kernel of the operating system is connected to the disk to read data in the disk.
[0045] Figure 2 As shown, the method 200 starts from step S210.
[0046] In step S210, the kernel of the operating system reads the original file in the disk, reads the original file in the disk to the memory of the computing device to obtain a cache file. Here, the initial cache file without modification is the same as the original file data.
[0047] In step S220, one or more write operations on the cache file are received, and the cache file is modified according to the write operation to obtain a new cache file.
[0048] Here, it should be noted that the write operation on the cache file can be performed once or more, and the time of each write operation is different, and the data in the new cache file obtained after each write operation changes relative to the data in the cache file before the current write operation.
[0049] Subsequently, in step S230, the new cache 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 the time point at which the file snapshot is generated. In an implementation, the cache file is written to the disk through the write-back queue or sync system in the kernel, and the write-back queue or sync system can call do_writepages() in the kernel to write the data (cache file) in the memory to the disk.
[0050] According to an embodiment, a predetermined time can be set in advance, and when the interval time between the write operation and the last write operation exceeds the predetermined time, the file snapshot is generated as a backup file according to the write operation on the cache file, so as to avoid occupying the disk space by generating a large amount of unnecessary snapshot data.
[0051] Specifically, before generating the file snapshot corresponding to the current time point, the time point corresponding to the last file snapshot can be obtained from the snapshot storage device. Then, the interval time between the current time point and the time point corresponding to the last file snapshot is determined, and it is judged whether the interval time exceeds the predetermined time. If it exceeds the predetermined time, the new cache file is written to the disk to generate a file snapshot corresponding to the current time point. If it does not exceed the predetermined time, it means that the interval time is short, and the operation of writing the new cache file to the disk to generate the file snapshot is not performed, and the file snapshot corresponding to the current time point is not generated, which is beneficial to save storage space.
[0052] Finally, in step S240, the new cache file is written back to the original file in the disk.
[0053] In addition, in one embodiment, a copy of the original file can be copied in the disk before step S230 is performed. Specifically, before step S230 is performed, it is determined whether at least one file snapshot exists in the snapshot data storage device of the disk. If no file snapshot exists (indicating that this is the first write operation to the cache file), a copy of the original file is copied in the disk.
[0054] If at least one file snapshot exists, it indicates that this write operation is not the first write operation to the cache file, and it also indicates that the operation of copying the copy of the original file in the disk has been performed previously, so that it is not necessary to copy the copy of the original file in the disk again, and the new cache file is directly written in the disk to generate a file snapshot corresponding to the current time point.
[0055] It should be noted that the present application generates file snapshots respectively for write operations of a user at various time points, so that the modification process data of a file at various time points can be recorded, and the initial original file data is permanently retained in the disk by copying the copy of the original file in the disk. In this way, dual backup of the modification process of the file and the initial file is realized.
[0056] Figure 3 A process diagram of generating file snapshots according to one embodiment of the present application is shown. The process of generating multiple file snapshots for one original file fileA at multiple time points is described in detail below with reference to Figure 3
[0057] As shown in Figure 3 Step one, the original file fileA in the disk is read into the cache, and the initial cache file is denoted as Cache. At this time, the Cache file data is the same as the file data of fileA.
[0058] Step two, at a time point t1, a first write operation to the initial cache file Cache is received, and the cache file Cache is modified according to the first write operation to obtain a first new cache file Cache t1.
[0059] Step three, the original file fileA is copied in the disk to obtain a copy of the original file fileA COPY.
[0060] Step four, the first new cache file Cache t1 is written in the disk to generate a snapshot snapshot t1 of the original file fileA corresponding to the time point t1.
[0061] Step five can be performed synchronously when step four is performed.
[0062] Step five, write back the first new cache file Cache t1 to the original file fileA in the disk, thus updating the original file.
[0063] Step six, record the correspondence between the time point t1 and the snapshot snapshot t1, and store it in the snapshot storage device (database).
[0064] Step seven, at the time point t2, receive a write operation on the first new cache file Cache t1 (i.e. the second write operation on the cache file), modify the first new cache file Cache t1 according to the write operation, and obtain the second new cache file Cache t2.
[0065] Subsequently, as described in the foregoing steps four to six, write the second new cache file Cache t2 to the disk to generate the snapshot snapshot t2 corresponding to the time point t2. Write back the second new cache file Cache t2 to the fileA in the disk. And record the correspondence between the time point t2 and the snapshot snapshot t2, and store it in the snapshot storage device (database).
[0066] Next, at the time point t3, a write operation on the second new cache file Cache t2 (i.e. the third write operation on the cache file) can also be received, the second new cache file Cache t2 is modified according to the write operation, and the third new cache file Cache t3 is obtained. Subsequently, as described in the foregoing steps four to six, write the third new cache file Cache t3 to the disk to generate the snapshot snapshot t3 corresponding to the time point t3. Write back the third new cache file Cache t3 to the fileA in the disk. And record the correspondence between the time point t3 and the snapshot snapshot t3, and store it in the snapshot storage device (database).
[0067] Similarly, at the time point tN, a write operation on the cache file is received, the cache file is modified according to the write operation, and a new cache file Cache tN is obtained. Subsequently, as described in the foregoing steps four to six, write Cache tN to the disk to generate the snapshot snapshot tN corresponding to the time point tN. Write back Cache tN to fileA in the disk. And record the correspondence between the time point tN and the snapshot snapshot tN, and store it in the snapshot storage device (database).
[0068] It should be understood that the data of the cache file changes over time as the write operation of the cache file at the time points t1-tN, and the original file fileA in the disk is also constantly updated. The file snapshots snapshot t1-snapshot tN generated at each time point record the modification process data of the file at each time point.
[0069] According to one embodiment, a snapshot storage device is included on the disk. After generating a file snapshot corresponding to the current time point, the file snapshot can be stored in the snapshot storage device of the disk. Specifically, the file snapshot, the time point of snapshot generation (i.e. the current time point), and the inode of the original file are associated to generate a file snapshot and time relationship table, and the file snapshot and time relationship table is stored in the snapshot storage device.
[0070] It should be noted that the file snapshot and time relationship table is generated based on the snapshots of multiple files, the time points of snapshot generation, the inodes of the original files corresponding to the snapshots, and the association relationship therebetween. After generating a file snapshot corresponding to the current time point each time, the file snapshot, the current time point, and the inode of the original file are associated respectively and stored in the file snapshot and time relationship table in the snapshot storage device. In this way, the file snapshot and time relationship table can reflect the association relationship between multiple time points, multiple inodes of original files, and multiple file snapshots corresponding to each original file, in other words, according to the file snapshot and time relationship table, the snapshots of multiple original files at each time point can be determined.
[0071] Figure 4 A schematic diagram of a file snapshot and time relationship table according to one embodiment of the present application is shown.
[0072] As shown in Figure 4 The file snapshot and time relationship table includes multiple time points, such as t1, t2, t3, t4, t5, t6, t7, each of which can be associated with one or more snapshots of original files, and each original file can include file snapshots generated at one or more time points. Here, the original files include fileA, fileB, fileC,..., and fileN. As shown in Figure 4As shown, the snapshots of file A include, for example, Al snapshot generated at time point t1, A2 snapshot generated at time point t2, A3 snapshot generated at time point t4, and A4 snapshot generated at time point t7. The snapshots of file B include, for example, Bl snapshot generated at time point t2, B2 snapshot generated at time point t5. The snapshots of file C include, for example, Cl snapshot generated at time point t1, C2 snapshot generated at time point t3, C3 snapshot generated at time point t5, and C4 snapshot generated at time point t7. The snapshots of file N include, for example, Nl snapshot generated at time point t1, N2 snapshot generated at time point t2, N3 snapshot generated at time point t6.
[0073] According to one embodiment, the snapshot storage device can further store directory snapshot information corresponding to each directory, the directory snapshot information including time points corresponding to one or more directory snapshots, and inode of one or more files corresponding to the directory snapshot. Here, the directory name can be stored in association with the directory snapshot information, so that the corresponding directory snapshot information can be queried based on the directory name.
[0074] In addition, the snapshot storage device can further include file information of one or more files, the file information being stored in association with the inode of the file, so that the corresponding file information can be queried from the snapshot storage device based on the inode of the file.
[0075] In one embodiment, a user can request to access a target directory snapshot corresponding to a directory name by inputting the directory name. Here, the target directory snapshot includes snapshots of all files under the target directory.
[0076] Upon receiving the user's request to access the target directory snapshot based on the directory name, the corresponding directory snapshot information is obtained 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 inode of one or more files corresponding to the directory snapshot.
[0077] Subsequently, the corresponding file information is obtained from the snapshot storage device based on each inode in the directory snapshot information. Based on the time points corresponding to the one or more directory snapshots and the corresponding file information, a directory file and time relationship table is generated. Here, Figure 5 A diagram illustrating a directory file and time relationship table according to one embodiment of the present application is shown.
[0078] As Figure 5As shown, the time points corresponding to the one or more directory snapshots include t1, t2, t3, t4, t5, t6, and t7, each of which is a time point at which a directory snapshot is generated, and each of which corresponds to one or more file information under the directory. For example, the file information corresponding to the t1 time point includes file A, file B, file C, and file N, the file information corresponding to the t2 time point includes file A, file C, and file N, the file information corresponding to the t3 time point includes file B,..., and the file information corresponding to the t7 time point includes file A, file C, and file N.
[0079] Next, based on the directory file-time relationship table (as shown in FIG. 2) and the file snapshot-time relationship table (as shown in FIG. 3), a target directory snapshot-time relationship table is generated, and the target directory snapshot-time relationship table is returned. Figure 5 Figure 4 As shown in FIG. 4, the target directory snapshot-time relationship table is generated based on the directory file-time relationship table (as shown in FIG. 2) and the file snapshot-time relationship table (as shown in FIG. 3). Figure 6 As shown in FIG. 4, the target directory snapshot-time relationship table is generated based on the directory file-time relationship table (as shown in FIG. 2) and the file snapshot-time relationship table (as shown in FIG. 3).
[0080] Specifically, in generating the target directory snapshot-time relationship table, one or more file snapshots corresponding to each time point can be obtained by filtering the file snapshot-time relationship table based on the one or more file information corresponding to each time point in the directory file-time relationship table, and a directory snapshot corresponding to each time point can be obtained based on the one or more file snapshots corresponding to each time point. In this way, the target directory snapshot-time relationship table can be generated based on the directory snapshot corresponding to each time point.
[0081] As shown in FIG. 5, the file information corresponding to the t2 time point includes file A, file C, and file N, and thus the directory snapshot corresponding to the t2 time point is composed of one or more file snapshots closest to the t2 time point. Based on this, the directory snapshot corresponding to the t2 time point includes A2 snapshot, C1 snapshot, and N2 snapshot. Similarly, the directory snapshot corresponding to the t5 time point includes B2 snapshot, C3 snapshot, and N2 snapshot. Figure 5 Figure 6 As shown in FIG. 5, the file information corresponding to the t2 time point includes file A, file C, and file N, and thus the directory snapshot corresponding to the t2 time point is composed of one or more file snapshots closest to the t2 time point. Based on this, the directory snapshot corresponding to the t2 time point includes A2 snapshot, C1 snapshot, and N2 snapshot. Similarly, the directory snapshot corresponding to the t5 time point includes B2 snapshot, C3 snapshot, and N2 snapshot.
[0082] In the finally generated target directory snapshot-time relationship table, one or more file snapshots under the directory corresponding to each time point are included, and the one or more file snapshots form a directory snapshot corresponding to the time point.
[0083] As can be seen, according to the above method, the target directory snapshot-time relationship 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.
[0084] Figure 7 A backup device 700 according to an embodiment of the present application is shown in the schematic diagram. The backup device 700 resides in the operating system of a computing device (e.g. the computing device 100 as described above) and is adapted to perform the file backup method 200 of the present application. The computing device 100 comprises a disk adapted to store file data.
[0085] The backup device 700 comprises 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 is adapted to read the original file in the disk to the memory to obtain a cache file. The writing module 720 is adapted to receive one or more write operations on the cache file, modify the cache file according to the write operations to obtain a new cache file. The snapshot generating module 730 is adapted to write the new cache file to the disk to generate a file snapshot corresponding to the current time point. The write-back module 740 is adapted to write the new cache file back to the original file in the disk.
[0086] It should be noted that the reading module 710 is used to perform the step S210 as described above, the writing module 720 is used to perform the step S220 as described above, the snapshot generating module 730 is used to perform the step S230 as described above, and the write-back module 740 is used to perform the step S240 as described above. 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 can refer to the description of the steps S210-S240 in the method 200 as described above, which will not be repeated here.
[0087] According to the file backup scheme of the present application, a file snapshot corresponding to each time point is generated respectively according to the write operation of the user at each time point, so that the modification process data of the file at each time point can be recorded, and by copying the copy of the original file in the disk, the initial original file data is permanently retained in the disk. In this way, the automatic backup of the file modification process and the initial file is realized. It should be noted that the backup method of the present application is executed in the operating system and is applicable to various file systems, not limited to a specific file system.
[0088] In addition, according to the technical scheme of the present application, when the interval time between the write operation and the last write operation exceeds the predetermined time, the file snapshot is generated as a 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.
[0089] The various techniques described herein can be implemented in connection with hardware or software or, where appropriate, with a combination of both. Thus, the methods and apparatus of the present application, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard disks, USB flash drives, optical tapes, CD-ROMs, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the subject application.
[0090] Where a program code is executed on a programmable computer, the computing device generally includes a processor, a processor readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The storage medium is configured to store program code; the processor is configured to execute instructions in the program code stored in the storage medium to perform the file backup method of the present application.
[0091] In the context of this document, a "storage medium" can be any physical medium that stores information including computer-readable and / or computer- executable instructions. A storage medium can also be any physical medium that stores data including computer-readable and / or computer-executable instructions that can be read by a computer. In this context, a "modulated data signal" can be any signal that has been transformed or modified utilizing a transformation medium to encode information for transmission. Thus, a storage medium can take many forms, including but not limited to, a tangible storage medium, a carrier wave associated with a broadcast or other signal to be transmitted, etc.
[0092] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order to avoid obscuring the understanding of this description.
[0093] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order to avoid obscuring the understanding of this description.
[0094] Similarly, it is to be understood that the embodiments of the present application can be alternately practiced by a single processing circuit, device, article of manufacture, or apparatus rather than as a combination of multiple devices or modules. Any processing circuit described as several separate devices or components can be implemented on one device or component. To clearly illustrate this interchangeability of hardware and software, various components will be described as separate components or devices. However, these components and devices can be implemented on one device or component.
[0095] Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein can be arranged in a device as described in the examples, or alternatively can be located in one or more devices different from the devices in the examples. The modules in the foregoing examples can be combined as one module or further divided into multiple sub-modules.
[0096] Those skilled in the art will appreciate that the modules in the devices in the examples can be adaptively changed and disposed in one or more devices different from the examples. The modules or units or components in the examples can be combined as one module or unit or component, and further can be divided into multiple sub-modules or sub-units or sub-components. Any combination of all the features disclosed in the specification (including the accompanying claims, abstract and drawings), and any method or device so disclosed, can be made unless explicitly stated otherwise. Each feature disclosed in the specification (including the accompanying claims, abstract and drawings) can be replaced by an alternative feature serving the same, equivalent or similar purpose unless explicitly stated otherwise.
[0097] Further, those skilled in the art will appreciate that a combination of features of different embodiments can mean within the scope of the present application and form a different embodiment.
[0098] Further, some of the embodiments described herein are combinations of method or method elements with the processor of a computer system or other apparatus for implementing the method or method elements. Accordingly, those elements implementing the methods or method elements are part of the device for implementing the method or method elements. Further, the disclosure herein of a method or method elements does not imply that only a corresponding device or apparatus is required to implement the method or method elements.
[0099] As used herein, unless otherwise indicated, the use of the ordinal adjectives "first", "second", "third", etc., are to add specificity and difference to a term, and are not intended to indicate a temporal or chronological order or sequence. Except to the extent necessary or implicit from the discussion herein, as readily apparent to those of ordinary skill in the art, no portion of the specification is indicative of an ordering.
[0100] While the present application has been described in connection with limited number of embodiments, those skilled in the art will appreciate that numerous modifications and variations therefrom can be made without departing from the scope of the present application as set forth in the limitations to follow. Moreover, the language used in this specification has been chosen for readability and instructional purposes and can not have been selected to delineate or circumscribe the subject application. Accordingly, the disclosure of the present application is intended to be illustrative, but not limiting, of the scope of the application, which is set forth with particularity in the appended claims.
Claims
1. A file backup method, executed in an operating system of a computing device, the computing device comprising a disk, the disk comprising a snapshot storage, the method comprising the steps of: reading an original file in the disk into a memory to obtain a cache file; receiving one or more write operations on the cache file, modifying the cache file according to the write operations to obtain a new cache file; determining an interval time between a current time point and a time point corresponding to a last file snapshot, judging whether the interval time exceeds a predetermined time, and if so, writing the new cache file into the disk to generate a file snapshot corresponding to the current time point; associating the file snapshot, the current time point, and an inode of the original file to generate a file snapshot and time relationship table, and storing the file snapshot and time relationship table in the snapshot storage; wherein the file snapshot and time relationship table comprises a plurality of time points, each time point being associated with one or more snapshots of original files, so as to query snapshots of original files at various time points based on the file snapshot and time relationship table; the snapshot storage is further adapted to store directory snapshot information corresponding to each directory, the directory snapshot information comprising time points and inodes corresponding to one or more directory snapshots, so as to access a target directory snapshot based on a directory name, wherein accessing the target directory snapshot based on the directory name comprises: receiving an access request for the target directory snapshot based on the directory name, obtaining corresponding directory snapshot information from the snapshot storage based on the directory name; obtaining corresponding file information based on each inode in the directory snapshot information, and generating a directory file and time relationship table based on time points corresponding to one or more directory snapshots and corresponding file information; filtering in the file snapshot and time relationship table based on file information corresponding to each time point in the directory file and time relationship table to obtain one or more file snapshots corresponding to each time point, obtaining a directory snapshot corresponding to each time point based on the one or more file snapshots, and generating the target directory snapshot and time relationship table based on the directory snapshot corresponding to each time point; and writing the new cache file back to the original file in the disk.
2. The method of claim 1, wherein, Before writing the new cache file into the disk to generate a file snapshot corresponding to the current time point, the method further comprises the step of: copying a copy of the original file in the disk.
3. The method of claim 2, wherein, The step of copying the copy of the original file in the disk comprises: 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 apparatus, residing in an operating system of a computing device, the computing device comprising a disk, the disk comprising a snapshot storage, the backup apparatus comprising: a reading module adapted to read an original file in the disk into a memory to obtain a cache file; a writing module adapted to receive one or more write operations on the cache file, modify the cache file according to the write operations to obtain a new cache file; The snapshot generation module is adapted to determine an interval time between a current time point and a time point corresponding to a previous file snapshot, determine whether the interval time exceeds a predetermined time, and if the interval time exceeds the predetermined time, write the new cache file to the disk to generate a file snapshot corresponding to the current time point; and is adapted to: associate the file snapshot, the current time point, and an inode of the original file to generate a file snapshot and time relationship table, and store the file snapshot and time relationship table in the snapshot storage device, wherein the file snapshot and time relationship table includes a plurality of time points, each time point is associated with one or more snapshots of the original file, so as to query the snapshots of the original file at various time points based on the file snapshot and time relationship table; and the snapshot storage device is also adapted to store directory snapshot information corresponding to each directory, the directory snapshot information includes time points and inodes corresponding to one or more directory snapshots, so as to access a target directory snapshot based on a directory name, wherein accessing the target directory snapshot based on the directory name includes: receiving an access request for the target directory snapshot based on the directory name, obtaining corresponding directory snapshot information from the snapshot storage device based on the directory name; obtaining corresponding file information based on each inode in the directory snapshot information, and generating a directory file and time relationship table based on the time points corresponding to one or more directory snapshots and the corresponding file information; filtering in the file snapshot and time relationship table based on the file information corresponding to each time point in the directory file and time relationship table, to obtain one or more file snapshots corresponding to each time point, to obtain a directory snapshot corresponding to each time point, and generating the target directory snapshot and time relationship table based on the directory snapshot corresponding to each time point; and The write-back module is adapted to write back the new cache file to the original file in the disk.
5. A computing device comprising: at least one processor; and a memory storing program instructions configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any one of claims 1-3.
6. A readable storage medium storing program instructions, which when read and executed by a computing device, cause the computing device to perform the method of any one of claims 1-3.
Citation Information
Patent Citations
Metadata snap storage and access method in distributed file system
CN104933133A
Handling copy on first write data for snapshot purposes
US8874524B1