System backup and restoration method, device and electronic equipment
Patent Information
- Application Number
- CN202211124507.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-15
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2042-09-15
AI Technical Summary
[0005]有鉴于此,本发明实施例的目的在于采用提取目标机器的内核与驱动文件的方法,生成带有备份还原工具的最小系统,解决了ARM平台的linux系统下没有备份还原工具的问题和x86架构下的备份还原方法不适用于ARM架构的问题
[0042]In this invention, a root file system directory is created, and the kernel of the current Linux operating system is copied to the corresponding root file system directory. The executable file set and the shared libraries required by the executable files are copied to the root file system directory, and an initrd file is created. Based on the kernel and initrd file of the current Linux operating system, a minimal system is generated. Within the minimal system, the target hard drive containing the system to be backed up and the directory containing the relevant backup files are selected, and system backup is performed; or the target hard drive containing the system to be restored and the directory containing the relevant restore files are selected, and system restore is performed. On the one hand, because the generated minimal system with backup and restore functions has files entirely derived from existing files on the target machine to be backed up or compiled and generated on the target machine, complete driver compatibility can be guaranteed. On the other hand, using a Linux shell script as the execution entry point solves the problem that some tools typically cannot be used across platforms.
Smart Images

Figure CN117743023B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer science and technology, and more specifically, to a system backup and restore method, apparatus, and electronic device. Background Technology
[0002] Currently, system backup and restore tools are not as widespread in Linux environments as they are in Windows. While programs for x86 architectures can be used for backups, programs for x86 architectures cannot run on ARM architectures. Furthermore, current system backup and restore technologies in Linux typically involve backing up or restoring the target system (T) on the host operating system (M) within the host system (M).
[0003] Since the open-source Linux kernel already includes drivers for the vast majority of x86 architectures, no special explanation is needed. As is well known, hardware types under the ARM architecture vary greatly, and the kernel is usually highly customized. If an M-system is compiled using an open-source Linux kernel, although it can boot normally, it cannot actually operate because it lacks drivers for display and input devices. Taking Jingjia Micro, a domestically produced graphics card manufacturer, as an example, its driver code is not open source. An M-system compiled in the conventional way cannot display on machines equipped with this graphics card. Therefore, existing technology has significant limitations on the ARM platform and cannot meet the requirements.
[0004] Furthermore, existing backup and restore tools for Linux platforms can only run on x86 architecture machines and cannot run on ARM architecture machines; they are not fully compatible with the ARM platform. The diversity of ARM platform hardware means that existing technologies cannot be compatible with all drivers and cannot support hardware whose drivers are not open source. Summary of the Invention
[0005] In view of this, the purpose of this invention is to generate a minimal system with backup and restore tools by extracting the kernel and driver files of the target machine, thereby solving the problem that there are no backup and restore tools under the Linux system on the ARM platform and the problem that the backup and restore method under the x86 architecture is not applicable to the ARM architecture.
[0006] A first aspect of the present invention provides a system backup and restore method, the method comprising:
[0007] Create a root file system directory and copy the kernel of the current Linux operating system to the corresponding root file system directory;
[0008] Copy the executable file set and the shared libraries required by the executable files to the root file system directory, and create the initrd file;
[0009] Generate a minimal system based on the current Linux operating system's kernel and initrd file;
[0010] In a minimal system, select the target hard drive containing the system to be backed up and the directory where the backup files are stored, and back up the system to be backed up; or, select the target hard drive containing the system to be restored and the directory where the restore files are stored, and restore the system to be restored.
[0011] Preferably, the steps of copying the executable file set and the shared libraries required by the executable files to the root file system directory, and creating the initrd file, include:
[0012] Copy the executable file set and create links to each executable file in the executable file set to the corresponding root file system directory; the executable file set contains regular system operation commands and operation commands necessary for backup and restore;
[0013] Use a script to sequentially query the shared libraries required by each executable file, and copy the shared libraries required by each executable file to the corresponding root file system directory;
[0014] Using a Linux shell script as the execution entry point, query the drivers that are currently loaded in the Linux operating system, and copy the corresponding driver files to the corresponding root file system directory;
[0015] Copy the contents of other etc and dev files in the current Linux operating system to the corresponding root file system directory;
[0016] Copy the backup and restore program to the / bin directory under the root file system directory;
[0017] The initrd file is created based on the copied set of executable files, the shared libraries required by the executable files, the driver files corresponding to the drivers, the contents of other etc and dev files, and the backup and restore programs.
[0018] Preferably, the backup and restore program is copied to the / bin directory under the root file system directory, including:
[0019] Check if the necessary dependencies for backup and restore exist locally;
[0020] If there are dependent libraries, copy the backup and restore program directly to the / bin directory under the root file system directory;
[0021] If no dependent libraries exist, the backup and restore program will be compiled and copied to the / bin directory under the root file system directory.
[0022] Preferably, a minimal system is generated based on the current Linux operating system's kernel and initrd file, including:
[0023] Configure the grub.cfg file to specify the kernel and initrd file required for the current Linux operating system to boot, and generate an ISO image file to obtain a minimal system.
[0024] Preferably, under a minimal system, select the target hard drive containing the system to be backed up and the directory for storing the backup files, and back up the system; or, select the target hard drive containing the system to be restored and the directory for storing the restore files, and restore the system, including:
[0025] Burn the minimal system to a storage disk, use the storage disk to boot and enter the minimal system;
[0026] In a minimal system, use the backup and restore program to perform a backup operation, select the target hard drive where the system to be backed up is located and the directory where the backup file is stored, and back up the system to be backed up; or, in a minimal system, use the backup and restore program to perform a restore operation, select the target hard drive where the system to be restored is located, select the directory where the restore file is stored, and restore the system to be restored.
[0027] Preferably, select the target hard drive containing the system to be backed up and the directory for storing the backup files, and perform a backup of the system, including:
[0028] Select the target drive letter and specify the drive letter to store the backup files;
[0029] Determine if the target drive letter exists and if there is enough space on the drive letter to store the backup files; if the target drive letter exists and there is enough space on the drive letter to store the backup files, then back up the partition information of the target drive letter and the files in each partition of the target drive letter.
[0030] The backed-up partition information and each partition file are packaged and compressed, and an MD5 checksum is generated. The MD5 checksum, the packaged and compressed partition information and each partition file are then backed up to the drive letter used to store the backup files, thus completing the backup of the system that needs to be backed up.
[0031] Preferably, select the target hard drive where the system to be restored is located, select the directory to store the restore files, and restore the system, including:
[0032] Select the target drive letter and specify the drive letter to store the restored files;
[0033] Check if the restore file exists; if it exists, perform an MD5 checksum on the restore file; if the checksum is successful, decompress the restore file.
[0034] The system reads the partition information and files from the decompressed restore file and determines whether the target drive has enough space. If so, it repartitions the target drive and uses the partition information and files from the decompressed restore file to restore each partition of the target drive, thus completing the system restoration.
[0035] Furthermore, a second aspect of the present invention provides a system backup and restore apparatus, the apparatus comprising:
[0036] The first module, Creation and Copy, creates the root file system directory and copies the kernel of the current Linux operating system to the corresponding root file system directory.
[0037] The second creation and copying module copies the executable file set and the shared libraries required by the executable files to the root file system directory, and creates the initrd file;
[0038] The minimal system generation module generates a minimal system based on the kernel and initrd file of the current Linux operating system.
[0039] The backup and restore module allows you to select the target hard drive containing the system to be backed up and the directory where the backup files are stored in the minimal system, and then back up the system; or, select the target hard drive containing the system to be restored and the directory where the restore files are stored, and then restore the system.
[0040] Furthermore, a third aspect of the present invention provides an electronic device comprising: one or more processors, and a memory for storing one or more computer programs; characterized in that the computer programs are configured to be executed by the one or more processors, and the programs include steps for performing the system backup and restore method described above.
[0041] Furthermore, a fourth aspect of the present invention provides a storage medium storing a computer program; the program is loaded and executed by a processor to implement the steps of the system backup and restore method described above.
[0042] In this invention, a root file system directory is created, and the kernel of the current Linux operating system is copied to the corresponding root file system directory. The executable file set and the shared libraries required by the executable files are copied to the root file system directory, and an initrd file is created. Based on the kernel and initrd file of the current Linux operating system, a minimal system is generated. Within the minimal system, the target hard drive containing the system to be backed up and the directory containing the relevant backup files are selected, and system backup is performed; or the target hard drive containing the system to be restored and the directory containing the relevant restore files are selected, and system restore is performed. On the one hand, because the generated minimal system with backup and restore functions has files entirely derived from existing files on the target machine to be backed up or compiled and generated on the target machine, complete driver compatibility can be guaranteed. On the other hand, using a Linux shell script as the execution entry point solves the problem that some tools typically cannot be used across platforms. Attached Figure Description
[0043] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is a schematic flowchart of the system backup and restore method disclosed in Embodiment 1 of the present invention;
[0045] Figure 2 This is a flowchart of the steps disclosed in Embodiment 1 of the present invention, which involves copying a set of executable files and the shared libraries required by the executable files to the root file system directory and creating an initrd file.
[0046] Figure 3 This is a flowchart of the minimum system generation disclosed in Embodiment 1 of the present invention;
[0047] Figure 4 This is a backup and restore flowchart disclosed in Embodiment 1 of the present invention;
[0048] Figure 5 This is a schematic diagram of the system backup and restore device disclosed in Embodiment 2 of the present invention. Detailed Implementation
[0049] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0050] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0051] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0052] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0053] It should be noted that "multiple" as mentioned in this article refers to two or more.
[0054] The implementation details of the technical solutions in the embodiments of this application are described in detail below:
[0055] Example 1
[0056] Please see Figure 1 , Figure 1 This is a schematic flowchart of a system backup and restore method disclosed in an embodiment of the present invention. Figure 1 As shown in the figure, a system backup and restore method according to an embodiment of the present invention includes:
[0057] S1, create the root file system directory and copy the kernel of the current Linux operating system to the corresponding root file system directory.
[0058] Specifically, in this embodiment, firstly, a root file system directory is created; then, the local Linux kernel is copied: by querying the current system's kernel version, the corresponding kernel is copied to the appropriate directory.
[0059] S2, copy the set of executable files and the shared libraries required by the executable files to the root file system directory, and create the initrd file.
[0060] Preferred, such as Figure 2 As shown, the steps for copying the executable file set and the shared libraries required by the executable files to the root file system directory, and creating the initrd file, include:
[0061] S201, copy the executable file set and create links to each executable file in the executable file set to the corresponding root file system directory; the executable file set contains regular system operation commands and operation commands necessary for backup and restore;
[0062] S202, use a script to sequentially query the shared libraries required by each executable file, and copy the shared libraries required by each executable file to the corresponding root file system directory;
[0063] S203 uses a Linux shell script as the execution entry point to query the drivers that are currently loaded in the Linux operating system and copy the corresponding driver files to the corresponding root file system directory;
[0064] S204: Copy the contents of other etc and dev files in the current Linux operating system to the corresponding root file system directory;
[0065] S205, copy the backup and restore program to the / bin directory under the root file system directory;
[0066] S206. Based on the copied set of executable files, the shared libraries required by the executable files, the driver files corresponding to the drivers, the contents of other etc and dev files, and the backup and restore programs, create the initrd file.
[0067] Specifically, in this embodiment, after copying the local Linux kernel, a root file system needs to be generated. This involves copying a set of executable files and creating links to these executable files. This set is pre-configured and includes common system operation commands and commands necessary for backup and restore. Shared libraries required by the executable files from the previous step are copied. A script sequentially queries the shared libraries required by each file from the previous step and copies them to the corresponding directories. Drivers already loaded in the current system are queried, and the corresponding driver files are copied to the corresponding directories in the root file system. The contents of other etc and dev files are copied to their corresponding directories.
[0068] Preferably, the backup and restore program is copied to the / bin directory under the root file system directory, including: checking whether the required dependency libraries for backup and restore exist locally; if the dependency libraries exist, the backup and restore program is directly copied to the / bin directory under the root file system directory; if the dependency libraries do not exist, the backup and restore program is compiled and then copied to the / bin directory under the root file system directory. An initrd file is created based on the content copied in S201-S205 above.
[0069] S3 generates a minimal system based on the kernel and initrd file of the current Linux operating system.
[0070] Preferably, a minimal system is generated based on the kernel and initrd file of the current Linux operating system, including: configuring the grub.cfg file to specify the kernel and initrd file required for the current Linux operating system to boot, and generating an ISO image file to obtain the minimal system.
[0071] In this embodiment, as Figure 3 The diagram shows a flowchart of the minimum system generation process in this embodiment. After the system begins generating the minimum system, it creates a root file system base directory and copies the local Linux Kernel for subsequent root file system generation. In the root file system generation process, executable files, shared libraries, and drivers are collected, and the contents of other etc and dev files are copied. Backup and restore tools are copied, and final checks are performed on their dependencies. This facilitates the generation of an ISO image file based on the collected and copied information. Specifically, in the ISO image file generation process, the grub.cfg file is configured to specify the kernel and initrd files required for booting the current Linux operating system, thus generating the ISO image file and obtaining the minimum system.
[0072] S4. In the minimal system, select the target hard drive where the system to be backed up is located and the directory where the backup file is stored, and back up the system to be backed up; or, select the target hard drive where the system to be restored is located and the directory where the restore file is stored, and restore the system to be restored.
[0073] Preferably, in step S4, under the minimum system configuration, the target hard drive containing the system to be backed up and the directory for storing the backup files are selected, and the system to be backed up is backed up; or, the target hard drive containing the system to be restored and the directory for storing the restore files are selected, and the system to be restored is restored, including:
[0074] S401: Burn the minimum system to a storage disk, use the storage disk to boot and enter the minimum system;
[0075] S402, under the minimal system, use the backup and restore program to perform a backup operation, select the target hard drive where the system to be backed up is located and the directory where the backup file is stored, and back up the system to be backed up; or, under the minimal system, use the backup and restore program to perform a restore operation, select the target hard drive where the system to be restored is located, select the directory where the restore file is stored, and restore the system to be restored.
[0076] It should be noted that in this example S402, selecting the target hard drive containing the system to be backed up and the directory for storing the backup files, and performing the backup of the system includes:
[0077] Select the target drive letter and specify the drive letter to store the backup files;
[0078] Determine if the target drive letter exists and if there is enough space on the drive letter to store the backup files; if the target drive letter exists and there is enough space on the drive letter to store the backup files, then back up the partition information of the target drive letter and the files in each partition of the target drive letter.
[0079] The backed-up partition information and each partition file are packaged and compressed, and an MD5 checksum is generated. The MD5 checksum, the packaged and compressed partition information, and each partition file are then backed up to the drive letter used to store the backup files, thus completing the backup of the system that needs to be backed up.
[0080] In a minimal system, follow the system prompts to select the target hard drive containing the system to be backed up, select the directory to store the backup files, and execute the system backup. This includes: selecting the target drive letter and specifying the drive letter where the backup files are located; checking if the target drive letter exists and if there is enough space on the drive containing the backup files; if there is enough space, backing up the partition information of the target drive and backing up each partition on the target drive; packaging and compressing the backed-up partition information and partition files, generating an MD5 checksum, and completing the backup. The purpose of generating the MD5 checksum is so that during file sending and copying operations after packaging and compression, a file containing the checksum will be sent along with the file. After receiving this file, an MD5 hash will be performed, and the result will be compared with the sent checksum. If they match, the sent file is considered error-free; otherwise, the file is considered error-free and needs to be resent.
[0081] In this embodiment, in step S402, selecting the target hard drive where the system to be restored is located, selecting the directory where the restoration files are stored, and restoring the system to be restored includes:
[0082] Select the target drive letter and specify the drive letter to store the restored files;
[0083] Determine if the restore file exists; if it exists, perform an MD5 checksum on the restore file; if the checksum is successful, decompress the restore file; read the partition information and files of each partition from the decompressed restore file, and determine if the target drive has enough space; if so, repartition the target drive, and use the partition information and files of each partition from the decompressed restore file to restore each partition of the target drive to complete the system restore.
[0084] Specifically, in this embodiment, as Figure 4 The diagram shows the backup and restore flowchart for this embodiment. The generated minimal system can be burned to a USB drive using ultimatum software or the DD command, and then the USB drive can be used for booting. The pre-built backup and restore program is used, selecting backup as the operation type, selecting the target drive letter (from which backup will be performed), specifying the drive letter where the backup file is located (this drive letter cannot be the same as the target drive letter), and specifying folders to be ignored during backup. The process checks if the target drive letter exists and if there is enough space on the drive containing the backup file. If so, the partition information of the target drive is backed up, and each partition on the target drive is backed up.
[0085] It should be noted that in this embodiment, the generated minimal system is burned to a USB drive using ultimatum software or the DD command. The USB drive is then used to boot the system, and the pre-built-in backup and restore program is used. The operation type is selected as restore, the target drive letter is selected (the restore will be performed from this drive letter), and a backup file is specified (it cannot be the same as the target drive letter). A system prompt appears, warning that continuing the operation will erase the contents of the target drive. The system checks if the backup file exists; if it does, it performs an MD5 checksum test and decompresses the backup file. Further, the backup partition information is read and compared with the target drive letter to determine if there is enough space. If there is enough space, the target drive is repartitioned, and the data in the backup file is used to restore each partition, thus completing the restore process.
[0086] In this embodiment, a Linux shell script is used as the execution entry point to query the currently loaded drivers, extract some necessary files of the current system kernel, and then copy some disk operation-related tools and library files from the local machine. If the required tools are not available on the local machine, they are compiled using pre-prepared source code. These files are used as a root file system to create the ramdisk file required for kernel boot. Finally, the kernel image file is added to generate an ISO image. This image is burned to a USB flash drive or CD, and then the burned boot disk is used to boot the target machine. At this point, a minimal system with backup and restore functions is running on the target machine.
[0087] It should be noted that in this embodiment, the minimum system is fully compatible with current hardware because all files are extracted or compiled from the current system. In addition, the Linux shell script serves as the execution entry point, which solves the problem that some tools cannot be used across platforms.
[0088] After booting from the image generated using this method, the user needs to specify the drive letter of the hard drive containing the system to be backed up and the drive letter of the disk or USB drive where the backup file is stored. Then, the backup process begins. The program first reads the partition information of the target system's hard drive, saves the necessary information, and then clones each partition according to its own format using the open-source tool partclone. The squashfs algorithm is used to compress the backed-up files to minimize system space usage. Finally, the files and their MD5 checksums are saved. The restore process is the reverse of the backup process. First, the user specifies the drive letter of the hard drive containing the system to be restored and the drive letter of the disk or USB drive where the backup file is stored. The program then checks if the backup file exists. If it does, it performs an MD5 checksum verification. If the verification is successful, the file is decompressed, and then the restore operation begins. A prompt appears asking if the disk needs to be repartitioned. After the user confirms, the system restore begins.
[0089] In summary, this embodiment addresses the technical problem that there are currently no one-click backup and restore tools for Linux systems on the ARM platform, and that backup and restore solutions for Linux systems provided by other platforms or patents are not applicable to the ARM platform. On one hand, by generating a minimal system with backup and restore functions, all files are derived from existing files on the target machine or compiled on the target machine, ensuring full driver compatibility. This solves the current lack of backup and restore tools for Linux systems on the ARM architecture and the problem that minimal Linux systems on the ARM platform are often incompatible with its hardware, facilitating data recovery after unexpected system crashes. On the other hand, this embodiment uses a shell script as the entry point, requiring deployment and backup on one machine, but can run on other machines, such as Linux on x86 or ARM platforms, offering stronger cross-platform compatibility. The backed-up files are compressed using the squashfs algorithm, significantly reducing file size.
[0090] Example 2
[0091] This embodiment provides a system backup and restore device. For example... Figure 5 The diagram shown is a structural schematic of the system backup and restore device of this embodiment. The device includes:
[0092] The first creation and copy module 10 creates the root file system directory and copies the kernel of the current Linux operating system to the corresponding root file system directory.
[0093] The second creation and copying module 20 copies the executable file set and the shared libraries required by the executable files to the root file system directory, and creates the initrd file;
[0094] Minimal system generation module 30 generates a minimal system based on the kernel and initrd file of the current Linux operating system;
[0095] The backup and restore module 40, under the minimum system, selects the target hard drive where the system to be backed up is located and the directory where the relevant backup files are stored, and performs system backup; and selects the target hard drive where the system to be restored is located and the directory where the relevant restore files are stored, and performs system restore.
[0096] The second creation and copy module 20 also includes:
[0097] The first copy submodule 21 copies the executable file set and creates links to each executable file in the executable file set to the corresponding root file system directory; the executable file set contains regular system operation commands and operation commands necessary for backup and restore;
[0098] The second copy submodule 22 uses a script to sequentially query the shared libraries required by each executable file and copy the shared libraries required by each executable file to the corresponding root file system directory;
[0099] The third copy submodule 23 uses a Linux shell script as its execution entry point to query the drivers that have been loaded in the current Linux operating system and copy the driver files corresponding to the drivers to the corresponding root file system directory.
[0100] The fourth copy submodule 24 copies the contents of other etc and dev files in the current Linux operating system to the corresponding root file system directory;
[0101] The fifth copy submodule 25 copies the backup and restore program to the / bin directory under the root file system directory;
[0102] Create submodule 26, which creates the initrd file based on the copied set of executable files, the shared libraries required by the executable files, the driver files corresponding to the drivers, the contents of other etc and dev files, and the backup and restore programs.
[0103] Preferably, the fifth copy submodule 25 is also used to: check whether the dependent libraries required for backup and restore exist locally; if the dependent libraries exist, directly copy the backup and restore program to the / bin directory under the root file system directory; if the dependent libraries do not exist, compile the backup and restore program and copy it to the / bin directory under the root file system directory.
[0104] Preferably, a minimal system is generated based on the kernel and initrd file of the current Linux operating system, including: configuring the grub.cfg file to specify the kernel and initrd file required for the current Linux operating system to boot, and generating an ISO image file to obtain the minimal system.
[0105] Preferably, the backup and restore module 40 includes a backup submodule 41 and a restore submodule 42; it is also used to: burn the minimum system to a storage disk, use the storage disk to boot and enter the minimum system;
[0106] Backup submodule 41 is used to perform backup operations using backup and restore programs under a minimal system. It allows users to select the target hard drive containing the system to be backed up and the directory for storing backup files, and then back up the system. Restore submodule 42 is used to perform restore operations using backup and restore programs under a minimal system. It allows users to select the target hard drive containing the system to be restored and the directory for storing restore files, and then restore the system.
[0107] Preferably, the backup submodule 41 is further configured to: select the target drive letter of the target hard drive and specify the drive letter to store the backup files; determine whether the target drive letter exists and whether the space of the drive letter to store the backup files is sufficient; if the target drive letter exists and the space of the drive letter to store the backup files is sufficient, back up the partition information of the target drive letter and the files of each partition of the target drive letter; package and compress the backed-up partition information and each partition file, generate an MD5 checksum, and back up the MD5 checksum and the packaged and compressed partition information and each partition file to the drive letter to store the backup files, so as to complete the backup of the system that needs to be backed up;
[0108] Preferably, the restore submodule 42 is further configured to: select the target drive letter of the target hard disk and specify the drive letter to store the restore file; determine whether the restore file exists; if it exists, perform MD5 verification on the restore file; if the verification is successful, decompress the restore file; read the partition information and each partition file in the decompressed restore file, and determine whether the space of the target drive letter is sufficient; if sufficient, repartition the target drive letter, and use the partition information and each partition file in the decompressed restore file to restore each partition of the target drive letter, so as to complete the restoration of the system that needs to be restored.
[0109] In addition, this embodiment also provides an electronic device, which includes: one or more processors, a memory for storing one or more computer programs; the computer programs are configured to be executed by one or more processors, and the programs include steps for performing the system backup and restore method described above.
[0110] In addition, this embodiment also provides a storage medium storing a computer program; the program is loaded and executed by a processor to implement the above system backup and restore method steps.
[0111] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0112] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.
[0113] The units described as separate components may or may not be physically separate. As will be appreciated by those skilled in the art, the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0114] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0115] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or grid device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0116] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A system backup and restore method, characterized in that, The method includes: Create a root file system directory and copy the kernel of the current Linux operating system to the corresponding root file system directory; Copy the executable file set and the shared libraries required by the executable files to the root file system directory, and create the initrd file; Generate a minimal system based on the kernel of the current Linux operating system and the initrd file; Under the minimum system, select the target hard drive where the system to be backed up is located and the directory where the backup file is stored, and back up the system to be backed up; or, select the target hard drive where the system to be restored is located and the directory where the restore file is stored, and restore the system to be restored; The steps of copying the set of executable files and the shared libraries required by the executable files to the root file system directory and creating the initrd file include: Copy the executable file set and create links to each executable file in the executable file set to the corresponding root file system directory; the executable file set contains regular system operation commands and operation commands necessary for backup and restore; Use a script to sequentially query the shared libraries required by each of the executable files, and copy the shared libraries required by each of the executable files to the corresponding root file system directory; Using a Linux shell script as the execution entry point, query the drivers that have been loaded in the current Linux operating system, and copy the driver files corresponding to the drivers to the corresponding root file system directory; Copy the contents of other etc and dev files in the current Linux operating system to the corresponding root file system directory; Copy the backup and restore program to the / bin directory under the root file system directory; The initrd file is created based on the copied set of executable files, the shared libraries required by the executable files, the driver files corresponding to the drivers, the contents of the other etc files and the dev files, and the backup and restore program; The step of copying the backup and restore program to the / bin directory under the root file system directory includes: Check if the necessary dependencies for backup and restore exist locally; If the aforementioned dependent libraries exist, the backup and restore program will be directly copied to the / bin directory under the root file system directory; If the required dependency library does not exist, the backup and restore program will be compiled and copied to the / bin directory under the root file system directory.
2. The system backup and restore method according to claim 1, characterized in that, The step of generating a minimal system based on the kernel of the current Linux operating system and the initrd file includes: Configure the grub.cfg file to specify the kernel and initrd file required for booting the current Linux operating system, and generate an ISO image file to obtain the minimum system.
3. The system backup and restore method according to claim 2, characterized in that, Under the minimum system, select the target hard drive where the system to be backed up is located and the directory for storing the backup files, and back up the system to be backed up; Alternatively, select the target hard drive containing the system to be restored and the directory where the restore files are stored, and restore the system to be restored, including: The minimum system is burned to a storage disk, and the storage disk is used to boot and enter the minimum system. Under the minimum system, the backup and restore program is used to perform a backup operation, selecting the target hard drive where the system to be backed up is located and the directory where the backup file is stored, and backing up the system to be backed up; or, under the minimum system, the backup and restore program is used to perform a restore operation, selecting the target hard drive where the system to be restored is located, selecting the directory where the restore file is stored, and restoring the system to be restored.
4. The system backup and restore method according to claim 3, characterized in that, The step of selecting the target hard drive where the system to be backed up is located and the directory where the backup files are stored, and backing up the system to be backed up, includes: Select the target drive letter of the target hard drive and specify the drive letter to store the backup files; Determine whether the target drive letter exists and whether the space of the drive letter used to store the backup file is sufficient; if the target drive letter exists and the space of the drive letter used to store the backup file is sufficient, then back up the partition information of the target drive letter and the files of each partition of the target drive letter; The backed-up partition information and each partition file are packaged and compressed, and an MD5 checksum is generated. The MD5 checksum, the packaged and compressed partition information, and each partition file are then backed up to the drive letter used to store the backup files to complete the backup of the system that needs to be backed up.
5. The system backup and restore method according to claim 3, characterized in that, The steps of selecting the target hard drive where the system to be restored is located, selecting the directory where the restore files are stored, and restoring the system to be restored include: Select the target drive letter of the target hard drive and specify the drive letter to store the restored files; Determine if the restore file exists; if it exists, perform an MD5 checksum on the restore file; if the checksum is successful, decompress the restore file. The system reads the partition information and files of each partition from the decompressed recovery file and determines whether the target drive has enough space. If it does, the system repartitions the target drive and uses the partition information and files of each partition from the decompressed recovery file to restore each partition of the target drive, thereby completing the restoration of the system that needs to be restored.
6. A system backup and restore apparatus, used to perform the system backup and restore method steps as described in any one of claims 1-5, characterized in that, The device includes: The first module, Creation and Copy, creates the root file system directory and copies the kernel of the current Linux operating system to the corresponding root file system directory. The second creation and copying module copies the executable file set and the shared libraries required by the executable files to the root file system directory, and creates the initrd file. The minimum system generation module generates a minimum system based on the kernel of the current Linux operating system and the initrd file; The backup and restore module, under the minimum system, selects the target hard drive where the system to be backed up is located and the directory where the backup file is stored, and performs backup of the system to be backed up; or, selects the target hard drive where the system to be restored is located and the directory where the restore file is stored, and restores the system to be restored.
7. An electronic device, the electronic device comprising: One or more processors, a memory for storing one or more computer programs; characterized in that the computer programs are configured to be executed by the one or more processors, the programs including steps for performing the system backup and restore method as described in any one of claims 1-5.
8. A storage medium storing a computer program; the computer program being loaded and executed by a processor to implement the steps of the system backup and restore method as claimed in any one of claims 1-5.
Citation Information
Patent Citations
Method, system and apparatus for implementing failure restoration and data backup
CN101420326A
Backup restoration method and system of Linux operating system and medium
CN110968457A