A file backup method, system, device and storage medium
Patent Information
- Application Number
- CN202410260798.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-07
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]本发明的目的是提供一种文件备份方法、系统、装置及存储介质,用以解决现有文件系统所存放在他管理的分区文件容易被修改加密或盗取等问题
本发明的文件备份方法能防止备份文件被修改、被篡改和被盗取,具有较高的安全性和可靠性。
Smart Images

Figure CN123011594A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of file backup, and specifically relates to a file backup method, system, device and storage medium. Background Technology
[0002] Currently, most data storage systems on the market use the operating system's built-in file system, such as NTFS and FAT in Windows; EXT2, EXT3, EXT4, and XFS in Linux; and HFS and XSAN in macOS. Since the partition management permissions of these built-in file systems are managed by the operating system, if the operating system is compromised by a hacker or virus, the files stored on the partitions it manages can be modified, encrypted, or stolen. Summary of the Invention
[0003] The purpose of this invention is to provide a file backup method, system, device, and storage medium to solve the problems of existing file systems storing partition files under their management being easily modified, encrypted, or stolen.
[0004] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a file backup method, the method comprising: Obtain the unallocated storage space of the storage device of the file system to be backed up; Divide the unallocated storage space and create backup partitions; Create a directory storage area and a data storage area within the backup partition; The backup process uses the directory storage area and data storage area to back up the file data in the file system to be backed up.
[0005] Preferably, a directory storage area and a data storage area are constructed within the backup partition, including: The identifier area and the start area of the backup partition are determined, wherein the identifier area is written with a backup identifier and the start area is written with a start identifier; Offset the address of the starting area to determine the backup management area; Offset the address of the backup management area to determine the directory storage area; Offset the address of the directory storage area to determine the data storage area.
[0006] Preferably, it further includes: offsetting the address of the data storage area to determine the management copy area.
[0007] Preferably, the backup of file data in the file system to be backed up is based on the directory storage area and the data storage area, including: Obtain the backup identifier of the identifier area, and find the starting area based on the backup identifier; Identify the starting marker within the starting area and verify the starting marker; After the initial identifier is successfully verified, the file attributes of the file data are written to the directory storage area, and the data corresponding to the file attributes are written to the data storage area; the file attributes include: file name, file size, and file time.
[0008] Secondly, the present invention provides a file backup system for implementing the above-described file backup method, the system comprising: The acquisition module is used to acquire the unallocated storage space of the storage device of the file system to be backed up; Create a module to partition unallocated storage space and create backup partitions; The building module is used to build the directory storage area and data storage area within the backup partition; The backup module is used to back up file data in the file system to be backed up, based on the directory storage area and the data storage area.
[0009] Preferably, the building module includes: The first determining submodule is used to determine the identifier area and the starting area of the backup partition, wherein the identifier area is written with a backup identifier and the starting area is written with a starting identifier. The second determination submodule is used to offset the address of the starting area to determine the backup management area; The third determination submodule is used to offset the address of the backup management area and determine the directory storage area; The fourth submodule is used to offset the address of the directory storage area to determine the data storage area.
[0010] Preferably, the building module further includes: The fifth submodule is used to offset the address of the data storage area and determine the management copy area.
[0011] Preferably, the backup module includes: The search submodule is used to obtain the backup identifier of the identifier area and search for the starting area based on the backup identifier; The verification submodule is used to identify the starting identifier within the starting area and verify the starting identifier; The write submodule is used to write the file attributes of the file data to the directory storage area and write the data corresponding to the file attributes to the data storage area after the initial identifier verification is successful; the file attributes include: file name, file size and file time.
[0012] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described file backup method.
[0013] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described file backup method.
[0014] Beneficial effects: The file backup method of the present invention can prevent backup files from being modified, tampered with, and stolen, and has high security and reliability. Attached Figure Description
[0015] The accompanying drawings are provided to further illustrate embodiments of the present invention and form part of the specification. They are used together with the following detailed description to explain the embodiments of the present invention, but do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of a file backup method provided in one embodiment of the present invention; Figure 2 This is a block diagram of a file backup system provided in one embodiment of the present invention. Detailed Implementation
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in conjunction with the accompanying drawings and descriptions of the embodiments or the prior art. Obviously, the following description of the structure of the accompanying drawings is only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. It should be noted that the description of these embodiments is for the purpose of helping to understand the present invention, but does not constitute a limitation of the present invention.
[0017] Example 1 Figure 1 This is a flowchart of a file backup method provided in one embodiment of the present invention, such as... Figure 1 As shown, this embodiment provides a file backup method, the method including: Step S101: Obtain the unallocated storage space of the storage device of the file system to be backed up; In this embodiment, the storage device can be a mechanical hard drive, a solid-state drive, etc., and the file system to be backed up can be the NTFS or FAT file system of Windows, the EXT2, EXT3, EXT4, or XFS file system of Linux, and the HFS, XSAN, or other file systems that come with the operating system of macOS.
[0018] In this embodiment, the backup software can access the partition start address of sector 0 of the hard disk plus the sector allocation size address, such as 1C6H to 1CAH + 1CAH to 1CDH, 1D6H to 1DAH + 1DAH to 1DDH. These two address segments are used to calculate the occupied address space. After adding these address spaces, the remaining address can be used to obtain the unallocated storage space.
[0019] Step S102: Divide the unallocated storage space and create a backup partition; In this embodiment, 99 is written at offset address 1E2H in sector 0 as the identifier of this backup partition. Starting from 1E6H, four bytes are taken as the starting address of the backup sector, and starting from 1E9H, four bytes are taken to represent the size of this backup partition.
[0020] Step S103: Construct a directory storage area and a data storage area within the backup partition; In this embodiment, a directory storage area and a data storage area are constructed within the backup partition, including: Step a01: Determine the identifier area and the start area of the backup partition, wherein the identifier area is written with a backup identifier and the start area is written with a start identifier. In this embodiment, the backup identifier is the identifier (99) mentioned above. Step a02: Offset the address of the starting area to determine the backup management area; Step a03: Offset the address of the backup management area to determine the directory storage area; Step a04: Offset the address of the directory storage area to determine the data storage area.
[0021] In this embodiment, the sector address starting from 1E6H is the starting address of the directory storage area and the data storage area. The starting area uses an offset identifier of 4A484A3939000000H with 512=0 as the starting identifier.
[0022] The starting identifier 4A484A3939000000H occupies 8 bytes, then the offset 08H after the starting identifier occupies 4 bytes, which is the area size of this backup management area. The offset 0CH after the starting identifier occupies 4 bytes, which is the area size of this directory storage area. The 8 bytes starting from 14H after the starting identifier are the area size of the data storage area.
[0023] In this embodiment, the starting address of the directory storage area can be calculated by adding the sizes of the various areas in the management area.
[0024] In this embodiment, the backup management area mainly records the partition start identifier and the size of this backup management area, as well as parameters such as the size of the directory storage area and the size of the data storage area. A backup record of the copy address is made in the backup management area, which is generally placed at the end of the sector address (i.e., the management copy area) to avoid accidental file damage. As a further optimization of this embodiment, it also includes: offsetting the address of the data storage area to determine the management copy area; In this embodiment, the first 8 bytes after the start identifier (1C) are the storage address of the management replica area.
[0025] In this embodiment, each file in the directory storage area records four file attributes, namely: file name attribute, file start address attribute, file address storage space attribute, and write time attribute. In this embodiment, the file name occupies 16 bytes in the directory storage area, the file start address occupies 8 bytes in the directory storage area, the file address storage space occupies 8 bytes in the directory storage area, and the write time occupies 4 bytes in the directory storage area.
[0026] Step S104: Back up the file data in the file system to be backed up based on the directory storage area and the data storage area.
[0027] In this embodiment, backing up file data in the file system to be backed up is performed based on the directory storage area and the data storage area, including: Step b01: Obtain the backup identifier of the identifier area and find the starting area based on the backup identifier; Step b02: Identify the starting marker within the starting area and verify the starting marker; Step b03: After the initial identifier is successfully verified, write the file attributes of the file data to the directory storage area and write the data corresponding to the file attributes to the data storage area; the file attributes include: file name, file size and file time.
[0028] In this embodiment, when backing up file data, the file data is written to the corresponding data address according to the file record attributes recorded in the directory storage area. The address unit of each record is 512 bytes, and each address entry is 8 bytes. That is, every 8 bytes in 512 bytes is one address entry. For continuous storage, only the start and end addresses are recorded. For non-contiguous storage, the records are started from the next start record to the end address. In this embodiment, some file data addresses are continuous, so continuous storage can be used. However, some file data addresses are stored in multiple places, so they are not continuous. If they are all together, they are considered continuous. When a file data is not continuous, multiple start addresses are recorded. These multiple start addresses are the starting points of each data segment of the file data.
[0029] In this embodiment, the backup identifier, i.e., the identifier "99" of the backup partition, can be obtained by taking the address 1E2 of sector 0. Then, the starting area is found through the starting address 1E6H, and the starting identifier "4A484A3939000000H" in the starting area is identified. The starting identifier is then verified. If the verification is successful at 4A484A3939000000H, the file name, file size, and file time of the file directory written when backing up the file data are displayed. Finally, the read and write operation instructions are waited for, the file attributes of the file data are written to the directory storage area, and the data corresponding to the file attributes are written to the data storage area, thereby realizing the backup of the file data.
[0030] The backup method in this embodiment is independent of the operating system's file management permissions, preventing the operating system from directly managing the backup software's files and preventing the backup files from being modified, tampered with, or stolen.
[0031] Example 2 Figure 2 This is a block diagram of a file backup system provided in one embodiment of the present invention, such as... Figure 2 As shown, this embodiment provides a file backup system for implementing the file backup method of Embodiment 1. The system includes: The acquisition module is used to acquire the unallocated storage space of the storage device of the file system to be backed up; In this embodiment, the storage device can be a mechanical hard drive, a solid-state drive, etc., and the file system to be backed up can be the NTFS or FAT file system of Windows, the EXT2, EXT3, EXT4, or XFS file system of Linux, and the HFS, XSAN, or other file systems built into the operating system of MAC OS to store data.
[0032] In this embodiment, the backup software can access the two address segments 1C9H to 1CDH and 1D9H to 1DDH in sector 0 of the hard disk, calculate the occupied address space, and then add these address spaces together to obtain the unallocated storage space.
[0033] Create a module to partition unallocated storage space and create backup partitions; In this embodiment, 99 is written at offset address 1E2H in sector 0 as the identifier of this backup partition. Starting from 1E6H, four bytes are taken as the starting address of the backup sector, and starting from 1E9H, four bytes are taken to represent the size of this backup partition.
[0034] The building module is used to build the directory storage area and data storage area within the backup partition; The backup module is used to back up file data in the file system to be backed up, based on the directory storage area and the data storage area.
[0035] As a further optimization of this embodiment, the construction module includes: The first determining submodule is used to determine the identifier area and the starting area of the backup partition, wherein the identifier area is written with a backup identifier and the starting area is written with a starting identifier. The second determination submodule is used to offset the address of the starting area to determine the backup management area; The third determination submodule is used to offset the address of the backup management area and determine the directory storage area; The fourth submodule is used to offset the address of the directory storage area to determine the data storage area.
[0036] In this embodiment, the sector address starting from 1E6H is the starting address of the directory storage area and the data storage area. The starting area uses an offset identifier of 4A484A3939000000H with 512=0 as the starting identifier.
[0037] The starting identifier 4A484A3939000000H occupies 8 bytes, then the offset 08H after the starting identifier occupies 4 bytes, which is the area size of this backup management area. The offset 0CH after the starting identifier occupies 4 bytes, which is the area size of this directory storage area. The 8 bytes starting from 14H after the starting identifier are the area size of the data storage area.
[0038] In this embodiment, the starting address of the directory storage area can be calculated based on the size of the backup management area.
[0039] As a further optimization of this embodiment, the building module also includes: The fifth submodule is used to offset the address of the data storage area and determine the management copy area.
[0040] In this embodiment, the first 8 bytes after the start identifier (1C) are the storage address of the management replica area.
[0041] In this embodiment, each file in the directory storage area records four file attributes, namely: file name attribute, file start address attribute, file address storage space attribute, and write time attribute. In this embodiment, the file name occupies 16 bytes in the directory storage area, the file start address occupies 8 bytes in the directory storage area, the file address storage space occupies 8 bytes in the directory storage area, and the write time occupies 4 bytes in the directory storage area.
[0042] Preferably, the backup module includes: The search submodule is used to obtain the backup identifier of the identifier area and search for the starting area based on the backup identifier; The verification submodule is used to identify the starting identifier within the starting area and verify the starting identifier; The write submodule is used to write the file attributes of the file data to the directory storage area and write the data corresponding to the file attributes to the data storage area after the initial identifier verification is successful; the file attributes include: file name, file size and file time.
[0043] In this embodiment, when backing up file data, the file data is written to the corresponding data address according to the file record attributes recorded in the directory storage area. The address unit of each record is 512 bytes, and each address item is 8 bytes. For consecutive records, only the start and end addresses are recorded. For non-consecutive records, the records are started from the next start record to the end address.
[0044] In this embodiment, the backup identifier, i.e., the identifier "99" of the backup partition, can be obtained by taking the address 1E2 of sector 0. Then, the starting area is found through the starting address 1E6H, and the starting identifier "4A484A3939000000H" in the starting area is identified. The starting identifier is then verified. If the verification is successful at 4A484A3939000000H, the file name, file size, and file time of the directory are displayed. Finally, the system waits for read and write operation instructions, writes the file attributes of the file data to the directory storage area, and writes the data corresponding to the file attributes to the data storage area, thereby realizing the backup of the file data.
[0045] The backup method in this embodiment is independent of the operating system's file management permissions, preventing the operating system from directly managing the backup software's files and preventing the backup files from being modified, tampered with, or stolen.
[0046] This embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the file backup method described above.
[0047] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the file backup method described above.
[0048] The backup method in this embodiment is independent of the operating system's file management permissions, preventing the operating system from directly managing the backup software's files and preventing the backup files from being modified, tampered with, or stolen.
[0049] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0050] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0051] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0052] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A file backup method, characterized in that, The method includes: Obtain the unallocated storage space of the storage device of the file system to be backed up; Divide the unallocated storage space and create backup partitions; Create a directory storage area and a data storage area within the backup partition; The backup process uses the directory storage area and data storage area to back up the file data in the file system to be backed up.
2. The file backup method according to claim 1, characterized in that, Within the backup partition, construct a directory storage area and a data storage area, including: The identifier area and the start area of the backup partition are determined, wherein the identifier area is written with a backup identifier and the start area is written with a start identifier; Offset the address of the starting area to determine the backup management area; Offset the address of the backup management area to determine the directory storage area; Offset the address of the directory storage area to determine the data storage area.
3. The file backup method according to claim 2, characterized in that, Also includes: Offset the address of the data storage area to determine the management copy area.
4. The file backup method according to claim 2, characterized in that, Backing up files in the file system to be backed up is based on the directory storage area and the data storage area, including: Obtain the backup identifier of the identifier area, and find the starting area based on the backup identifier; Identify the starting marker within the starting area and verify the starting marker; After the initial identifier is successfully verified, the file attributes of the file data are written to the directory storage area, and the data corresponding to the file attributes are written to the data storage area; the file attributes include: file name, file size, and file time.
5. A file backup system for implementing the file backup method according to any one of claims 1-4, characterized in that, The system includes: The acquisition module is used to acquire the unallocated storage space of the storage device of the file system to be backed up; Create a module to partition unallocated storage space and create backup partitions; The building module is used to build the directory storage area and data storage area within the backup partition; The backup module is used to back up file data in the file system to be backed up, based on the directory storage area and the data storage area.
6. The file backup system according to claim 5, characterized in that, The building module includes: The first determining submodule is used to determine the identifier area and the starting area of the backup partition, wherein the identifier area is written with a backup identifier and the starting area is written with a starting identifier. The second determination submodule is used to offset the address of the starting area to determine the backup management area; The third determination submodule is used to offset the address of the backup management area and determine the directory storage area; The fourth submodule is used to offset the address of the directory storage area to determine the data storage area.
7. The file backup system according to claim 6, characterized in that, The building module also includes: The fifth submodule is used to offset the address of the data storage area and determine the management copy area.
8. The file backup system according to claim 6, characterized in that, The backup module includes: The search submodule is used to obtain the backup identifier of the identifier area and search for the starting area based on the backup identifier; The verification submodule is used to identify the starting identifier within the starting area and verify the starting identifier; The write submodule is used to write the file attributes of the file data to the directory storage area and write the data corresponding to the file attributes to the data storage area after the initial identifier verification is successful; the file attributes include: file name, file size and file time.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the file backup method according to any one of claims 1-4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the file backup method according to any one of claims 1-4.
