A method and system for obtaining remote backup file source path
By sending file information instructions and parsing the specified file during the remote backup process, and obtaining the source path of the backup file, the problem of complex and low success rate acquisition in the existing technology is solved, and efficient and general information acquisition is achieved.
Patent Information
- Application Number
- CN202411197817.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-29
AI Technical Summary
The lack of effective methods for obtaining the source path of backup files in existing remote backup technologies, resulting in complex queries, time-consuming and low success rate of information acquisition.
During the remote backup process, the first terminal sends file information instructions to the second terminal, including information such as file name, source path, etc., and generates a specified file in the second terminal for content analysis, and obtains the source path and identification of the backup file, thereby Establish a correspondence between the source path and the backup file path.
It realizes simple and efficient acquisition of backup file source paths, improves query efficiency and universality, and solves the problem of low success rate of information acquisition in the prior art.
Smart Images

Figure CN118708408B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of file backup, and in particular to a method for obtaining a remote backup file source path and a storage system. Background Art
[0002] Remote backup involves copying data from one location (usually a production environment) to another location (usually a backup environment).
[0003] In remote backup technology, files stored in a local device are generally synchronized to a remote device to implement file backup to avoid file damage or loss.
[0004] If it is a distributed storage system, the files in the local device will be distributed and stored in multiple remote devices to achieve multiple backups of the files.
[0005] In the existing remote backup technical solutions, usually only the focus is on whether the file is successfully backed up and how many copies are backed up, but not the source path of the file, that is, the original generation or storage location of the file. Therefore, in the prior art, it is not necessary to obtain the source path of the file during the remote backup process, so the existing remote data synchronization tools are generally not designed with the function of obtaining the source path of the backup file.
[0006] Even in the scenario where the source path of the backup file needs to be obtained, the technicians try to obtain the source path of the backup file by querying the remote synchronization log on the local device or the remote device.
[0007] The disadvantages of this approach are:
[0008] First, in most cases, the source path must be obtained by manually querying the remote synchronization log, which is inconvenient and time-consuming. It is also complicated for ordinary people who are not familiar with log query methods.
[0009] Second, the contents recorded in the remote synchronization logs are different. The source path of the backup file is not a necessary content recorded in the logs. Therefore, the logs of the local device and the remote device may not record the source path of the backup file, resulting in a low success rate of information acquisition.
[0010] Third, remote data synchronization tools have different versions. Different versions of tools correspond to different log information or different query methods, which makes it difficult to achieve universality in log query methods.
[0011] Therefore, in the prior art, there is a lack of effective methods for obtaining the source path of the backup file. Summary of the invention
[0012] The main purpose of the present invention is to provide a method for obtaining a remote backup file source path and a storage system, aiming to solve the problem in the prior art that there is a lack of an effective method for obtaining a backup file source path.
[0013] To achieve the above object, the present invention provides a method for obtaining a remote backup file source path, comprising the following steps:
[0014] When the first terminal detects the remote backup instruction, the first terminal sends a file information instruction of the file to be synchronized to the second terminal through the remote connection tool, wherein the file information instruction includes the second terminal identifier, the backup file name, the first terminal identifier, the source path of the file to be synchronized, and the specified file name;
[0015] Detecting a newly added file information instruction at a second terminal corresponding to the second terminal identifier;
[0016] When the second terminal detects the file information instruction, a file with a specified file name is generated in a specified directory, and the file with the specified file name includes: a backup file path, a first terminal identifier, and a source path of the file to be synchronized;
[0017] When the second terminal detects that a file with a specified file name is newly created in the specified directory, the second terminal parses the content of the file with the specified file name to obtain parsed content, wherein the parsed content includes the backup file path, the first terminal identifier and the source file path of the file to be synchronized.
[0018] Optionally, the method further includes:
[0019] Sending a remote synchronization instruction to the second terminal through a remote synchronization tool at the first terminal to back up the file to be synchronized to the second terminal, wherein the remote synchronization instruction includes: a source file path of the file to be synchronized, a second terminal identifier, and a backup file path;
[0020] After the synchronization of the file to be synchronized is completed, generating a backup file of the file to be synchronized in the designated directory of the second terminal;
[0021] The source path of the backup file and the first terminal identifier are obtained from the parsed content.
[0022] Optionally, when the second terminal detects that a file with a specified file name is newly created in the specified directory, after the step of parsing the content of the file with the specified file name to obtain the parsed content, the method further includes:
[0023] Generate cache information according to the parsed content and store it in a cache space of the second terminal;
[0024] Delete the file with the specified file name.
[0025] The step of acquiring the source path of the backup file and the first terminal identifier from the parsed content includes:
[0026] The parsed content is obtained from the cache space to obtain the source path of the backup file and the first terminal identifier from the parsed content.
[0027] Optionally, the first terminal is a camera; and the file to be synchronized is an image file captured by the camera.
[0028] Optionally, the file information instruction also includes: at least one of: the acquisition time of the file to be synchronized, the longitude and latitude of the first terminal, and the physical location of the first terminal.
[0029] Optionally, the first terminal and the second terminal respectively run a Linux operating system, the remote connection tool is SSH, and the remote synchronization tool is Rsync; the first terminal and the second terminal respectively perform a detection function through an Inotify module.
[0030] Optionally, the method further includes:
[0031] Acquire multiple second terminals included in the remote backup instruction;
[0032] The step of sending a file information instruction of a file to be synchronized to the second terminal through a remote connection tool when the first terminal detects a remote backup instruction comprises:
[0033] When the first terminal detects the remote backup instruction, the first terminal sends a file information instruction of the to-be-synchronized file to each second terminal included in the remote backup instruction through the remote connection tool.
[0034] Optionally, the method further includes:
[0035] On the second terminal, a first sequence list is formed for backup files whose source paths come from the same first terminal, wherein the first sequence list includes source path pointer units and first time pointer units, which are equal to the number of backup files managed by the first sequence list, and each backup file managed by the first sequence list is respectively generated with a source path pointer unit and a first time pointer unit, wherein the source path pointer unit is used to indicate the source path sequence of the corresponding backup file among all the backup files managed by the first sequence list, and the first time pointer unit is used to indicate the collection time sequence of the corresponding backup file among all the backup files managed by the first sequence list;
[0036] On the second terminal, a second sequence list is formed for all backup files received by the second terminal, wherein the second sequence list includes first terminal pointer units, second time pointer units and geographic location pointer units, which are equal to the number of backup files managed by the second sequence list respectively, and each backup file managed by the second sequence list is respectively generated with a first terminal pointer unit, a second time pointer unit and a geographic location pointer unit, the first terminal pointer unit is used to indicate the first terminal order of the corresponding backup file among all backup files managed by the second sequence list, the second time pointer unit is used to indicate the collection time order of the corresponding backup file among all backup files managed by the second sequence list, and the geographic location pointer unit is used to indicate the geographic location order of the corresponding backup file among all backup files managed by the second sequence list.
[0037] Optionally, the method further includes:
[0038] Calculating the query frequency of each pointer type in the query instruction received by each second terminal to determine the pointer type with the highest query frequency;
[0039] Determine the order of the file backup in the second terminal according to the pointer type with the highest query frequency;
[0040] When the second terminal detects a newly added file information instruction, the first sequence table and the second sequence table are updated according to the to-be-synchronized file corresponding to the newly added file information instruction;
[0041] At the second terminal, a file backup waiting sequence is formed according to the received file information instruction;
[0042] The file backup waiting sequence is reordered according to the file backup sorting basis, and the file backup order in the second terminal is arranged according to the reordered file backup waiting sequence.
[0043] To achieve the above objectives, the present invention also proposes a storage system, comprising at least one first terminal and at least one second terminal. The storage system adopts the method of obtaining the remote backup file source path to send the files to be synchronized stored in the first terminal to the second terminal to form a backup file.
[0044] In the technical solution of the present invention, when a remote backup instruction is received, the first terminal sends a file information instruction to the second terminal through a remote connection tool, sends the file information instruction to the second terminal corresponding to the second terminal identifier, determines the file name of the file to be synchronized to the second terminal through the backup file name in the file information instruction, marks the original storage terminal of the file to be synchronized through the first terminal identifier in the file information instruction, and determines the original storage path of the file to be synchronized in the original storage terminal through the source file path of the file to be synchronized in the file information instruction; when the second terminal corresponding to the second terminal identifier detects the newly added file information instruction, generates a file with the file name specified in the file information instruction in the specified directory of the second terminal, wherein the file with the specified file name includes: the backup file path, the first terminal identifier, and the source file path of the file to be synchronized. If the second terminal detects that a file with a specified file name is newly created in the specified directory, the content of the file with the specified file name is parsed, and the backup file path, the first terminal identifier, and the source file path of the file to be synchronized are obtained, thereby obtaining the source file path of the file to be synchronized, and also obtaining the backup file path corresponding to the source file path, and then, after the file to be synchronized is backed up, the source file path of the backup file can be determined, and the corresponding relationship between the source file path and the backup file path can be established according to the information in the file with the specified file name. Therefore, the technical solution of the present invention is conducive to solving the problem of the lack of an effective method for obtaining the source path of the backup file in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a flowchart of the method for obtaining a remote backup file source path in the first embodiment of the present invention.
[0046] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0047] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0048] In the following description, suffixes such as "unit", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "unit", "component" or "unit" can be used in a mixed manner.
[0049] See also Figure 1 In a first embodiment of the present invention, a method for obtaining a remote backup file source path is provided, comprising the following steps:
[0050] Step S10, when the first terminal detects the remote backup instruction, the first terminal sends a file information instruction of the file to be synchronized to the second terminal through the remote connection tool, wherein the file information instruction includes the second terminal identifier, the backup file name, the first terminal identifier, the source file path of the file to be synchronized, and the specified file name;
[0051] Step S20, detecting a newly added file information instruction at the second terminal corresponding to the second terminal identifier;
[0052] Step S30, when the second terminal detects the file information instruction, a file with a specified file name is generated in a specified directory, and the file with the specified file name includes: a backup file path, a first terminal identifier, and a source file path of the file to be synchronized;
[0053] Step S40, when the second terminal detects that a file with the specified file name is newly created in the specified directory, the content of the file with the specified file name is parsed to obtain parsed content, wherein the parsed content includes the backup file path, the first terminal identifier and the source file path of the file to be synchronized.
[0054] In the technical solution of the present invention, when a remote backup instruction is received, the first terminal sends a file information instruction to the second terminal through a remote connection tool, sends the file information instruction to the second terminal corresponding to the second terminal identifier, determines the file name of the file to be synchronized to the second terminal through the backup file name in the file information instruction, marks the original storage terminal of the file to be synchronized through the first terminal identifier in the file information instruction, and determines the original storage path of the file to be synchronized in the original storage terminal through the source file path of the file to be synchronized in the file information instruction; when the second terminal corresponding to the second terminal identifier detects the newly added file information instruction, generates a file with the file name specified in the file information instruction in the specified directory of the second terminal, wherein the file with the specified file name includes: the backup file path, the first terminal identifier, and the source file path of the file to be synchronized. If the second terminal detects that a file with a specified file name is newly created in the specified directory, the content of the file with the specified file name is parsed, and the backup file path, the first terminal identifier, and the source file path of the file to be synchronized are obtained, thereby obtaining the source file path of the file to be synchronized, and also obtaining the backup file path corresponding to the source file path, and then, after the file to be synchronized is backed up, the source file path of the backup file can be determined, and the corresponding relationship between the source file path and the backup file path can be established according to the information in the file with the specified file name. Therefore, the technical solution of the present invention is conducive to solving the problem of the lack of an effective method for obtaining the source path of the backup file in the prior art.
[0055] Specifically, the first terminal in the present invention is a sending terminal of the file to be synchronized, which can generally be an initial storage device of the file to be synchronized (the initial storage device can be an initial generating device of the file to be synchronized), and can be understood as a near-end device. The second terminal in the present invention is a backup terminal of the file to be synchronized, that is, a receiving and backup terminal of the file to be synchronized, and can be understood as a remote device.
[0056] The first terminal may back up files to at least one second terminal. The number of the first terminals is not limited here and may be one or more.
[0057] Furthermore, the first terminal identifier is an identifier used to mark a specific first terminal, and the second terminal identifier is an identifier used to mark a specific second terminal. The identifier can be an IP address or ID number of the terminal, or other methods that can mark, all of which are similarly included in the protection scope of the present invention.
[0058] The technical solution proposed by the present invention can be realized by only developing functions in a targeted manner based on existing software functions, without requiring additional software and hardware support. The application is convenient and simple, and the method of querying the source file path is effective and highly versatile.
[0059] Based on the first embodiment of the method for obtaining a remote backup file source path of the present invention, in a second embodiment of the method for obtaining a remote backup file source path of the present invention, the method further includes:
[0060] Step S50, sending a remote synchronization instruction to the second terminal through a remote synchronization tool at the first terminal to back up the files to be synchronized to the second terminal, wherein the remote synchronization instruction includes: a source file path of the files to be synchronized, a second terminal identifier, and a backup file path;
[0061] Step S60, after the synchronization of the to-be-synchronized file is completed, generating a backup file of the to-be-synchronized file in the designated directory of the second terminal;
[0062] Step S70: Acquire the source file path of the backup file and the first terminal identifier from the parsed content.
[0063] Specifically, when a remote backup instruction is detected, the first terminal identifier and the source file path of the file to be synchronized and other information are first sent to the second terminal by sending a file information instruction through steps S10 to S40, and stored in the specified directory in the form of a file with a specified file name. Then, the parsed content is obtained at the second terminal through content parsing to obtain the initial storage device, source file path and backup file path of the file to be synchronized.
[0064] After detecting that steps S10 to S40 are executed, the first terminal sends the file to be synchronized to the second terminal through steps S50 to S60, and forms a backup file in the second terminal. Specifically, the file name and path of the backup file have been set through the file information instruction.
[0065] Through step S70, the source file path of the backup file, the corresponding initial storage device and the backup file path can be obtained.
[0066] Based on the second embodiment of the method for obtaining a remote backup file source path of the present invention, in a third embodiment of the method for obtaining a remote backup file source path of the present invention, after step S40, the method further includes:
[0067] Step S80, generating cache information according to the parsed content and storing it in the cache space of the second terminal;
[0068] Step S90, deleting the file with the specified file name.
[0069] In this embodiment, the original storage device and the source file path of the file to be synchronized can be sent to the second terminal in the form of instructions without occupying additional storage space of the second terminal.
[0070] Specifically, the parsed content is stored in the cache space of the second terminal in the form of cache information, and when the cache is successful, the file with the specified file name can be deleted.
[0071] Specifically, step S90 may be executed after step S80 is completed, or after step S70 is completed.
[0072] Based on the above technical solution of caching the parsed content into the cache space, the step S70 includes:
[0073] Step S71: acquiring the parsed content from the cache space, so as to acquire the source file path of the backup file and the first terminal identifier from the parsed content.
[0074] Based on the first to third embodiments of the method for obtaining a remote backup file source path of the present invention, in the fourth embodiment of the method for obtaining a remote backup file source path of the present invention:
[0075] Specifically, the first terminal is a camera; and the file to be synchronized is an image file captured by the camera.
[0076] Furthermore, the file information instruction also includes: at least one of the acquisition time of the file to be synchronized, the longitude and latitude of the first terminal, and the physical location of the first terminal.
[0077] Furthermore, the first terminal and the second terminal respectively run a Linux operating system, the remote connection tool is SSH, and the remote synchronization tool is Rsync; the first terminal and the second terminal respectively perform a detection function through an Inotify module.
[0078] In this embodiment, a specific implementation method of a remote backup solution focusing on the source path is proposed. Specifically, the first terminal is a camera, and the file to be synchronized is an image file captured by the camera. In this embodiment, the number of first terminals is generally multiple, and at least one camera is set at each different position, so that multiple first terminals form a monitoring system.
[0079] At the same time, the image files collected by each camera can be backed up to one of the second terminals, or backed up to multiple second terminals in a distributed storage manner.
[0080] In the implementation scenario of a monitoring system, only by knowing which camera the backup image file was collected by can we understand what happened at each camera location, thereby realizing the traceability function of the monitoring system more quickly.
[0081] For example, when a user reads an image file backed up in the second terminal, he finds that there is an event that needs to be investigated in the image file. At this time, he needs to know the source path of the image file, and find out which camera captured the image through the source path, so as to locate the physical position of the camera.
[0082] Furthermore, in the specific scenario of a monitoring system formed by multiple first terminals, the file information instruction sent by the first terminal to the second terminal may also include more information, such as: the collection time of the file to be synchronized, the longitude and latitude of the first terminal, and at least one of the physical location of the first terminal, wherein the physical location refers to the positioning location, for example, No. D, Street C, District B, City A.
[0083] Among them, the acquisition time of the file to be synchronized is conducive to determining the generation time of the image file, the longitude and latitude of the first terminal is conducive to locating the longitude and latitude position of the first terminal, and the physical position of the first terminal is also conducive to quickly locating the first terminal.
[0084] SSH (Secure Shell) is a protocol for secure remote login and other secure network services over an insecure network; Rsync (Remote Synchronization) is an open source local remote data synchronization tool that can achieve full and incremental data synchronization; Inotify is a Linux kernel feature that monitors the file system and issues relevant event alerts in a timely manner through a dedicated application. The first terminal is the device that runs the Rsync command and starts the synchronization process; the second terminal is the other device that the Rsync command connects to, that is, the location where the file or directory will be copied or synchronized.
[0085] Rsync itself does not provide a method for obtaining the original path (source path) of the synchronized file, and Rsync is a very good local and remote data synchronization tool. Failure to obtain the source path information of the synchronized file will affect the user experience of Rsync. The present invention provides a method for providing the source path of Rsync synchronized files through SSH. The method can be implemented by only doing some targeted development based on the existing system.
[0086] In this embodiment, the specific implementation steps of the present invention are as follows:
[0087] Step 1: Before Rsync synchronizes files, a file information instruction of the file to be synchronized is sent to the second terminal via SSH. In this embodiment, the following file information instruction may be used:
[0088] ssh -q user@remote machine IP + "echo backup file name, first terminal IP: source file path > specified file name".
[0089] Step 2: After executing the file information instruction, a file with a specified file name will be generated on the second terminal. The file contains the following contents: backup file path, first terminal IP, and source file path;
[0090] Step 3: After the second terminal monitors the generation of a file with a specified file name through the Inotify module, it parses the file content and caches the parsed content, and deletes the file with the specified file name.
[0091] Step 4: After sending the file information instruction, the first terminal sends a remote synchronization instruction to the second terminal through Rsync to synchronize the file to be synchronized to the second terminal. The remote synchronization instruction is as follows:
[0092] rsync -avz -p source file path user@second terminal IP:backup file path;
[0093] Step 5: After Rsync completes synchronization, a backup file of the file to be synchronized will be generated in the directory specified by the second terminal. The file name and the file storage path can be specified in the remote synchronization instruction respectively.
[0094] Step 6: After the second terminal monitors the generation of the backup file, it can obtain the IP address of the first terminal where the source file is located and the source path stored on the first terminal from the cached information according to the information of the synchronization file.
[0095] Based on the first to fourth embodiments of the method for obtaining a remote backup file source path of the present invention, in a fifth embodiment of the method for obtaining a remote backup file source path of the present invention, the method further includes:
[0096] Step S100, obtaining multiple second terminals included in the remote backup instruction;
[0097] Step S10 includes: when the first terminal detects the remote backup instruction, sending a file information instruction of the to-be-synchronized file to each second terminal included in the remote backup instruction through a remote connection tool.
[0098] Specifically, a remote backup instruction may trigger multiple remote backup events. In the present invention, for the same remote backup event, a file information instruction is sent to each second terminal that needs to perform backup, wherein the file information instruction sent to each second terminal includes the corresponding second terminal identifier; and a remote synchronization instruction is also used to back up the files to be synchronized to each second terminal that performs backup. These two instructions will be sent to the same second terminal in a one-to-one correspondence. That is, the same second terminal will receive the file information instruction and the remote synchronization instruction that is the same as the remote backup event corresponding to the file information instruction.
[0099] Furthermore, the source file path in the file information instruction has a one-to-one correspondence with the backup file path in the remote synchronization instruction, and the corresponding backup file path can be found according to the source file path.
[0100] Based on the fourth embodiment of the method for obtaining a remote backup file source path of the present invention, in a sixth embodiment of the method for obtaining a remote backup file source path of the present invention, the method further includes:
[0101] Step S110, on the second terminal, for the backup files whose source file paths are from the same first terminal, a first sequence list is formed, wherein the first sequence list includes source path pointer units and first time pointer units, which are equal to the number of backup files managed by the first sequence list, and each backup file managed by the first sequence list is respectively generated with a source path pointer unit and a first time pointer unit, wherein the source path pointer unit is used to indicate the source path sequence of the corresponding backup file among all the backup files managed by the first sequence list, and the first time pointer unit is used to indicate the collection time sequence of the corresponding backup file among all the backup files managed by the first sequence list;
[0102] Step S120: On the second terminal, a second sequence list is formed for all backup files received by the second terminal, wherein the second sequence list includes first terminal pointer units, second time pointer units and geographic location pointer units, which are equal to the number of backup files managed by the second sequence list, and each backup file managed by the second sequence list is respectively generated with a first terminal pointer unit, a second time pointer unit and a geographic location pointer unit, the first terminal pointer unit is used to indicate the first terminal order of the corresponding backup file among all backup files managed by the second sequence list, the second time pointer unit is used to indicate the collection time order of the corresponding backup file among all backup files managed by the second sequence list, and the geographic location pointer unit is used to indicate the geographic location order of the corresponding backup file among all backup files managed by the second sequence list.
[0103] In this embodiment, on the second terminal, the backup files are managed according to the first sequence list and the second sequence list.
[0104] The first sequence list is used to manage backup files whose source file paths come from the same first terminal. Therefore, the number of first sequence lists in the second terminal is equal to the number of first terminals from which the backup files stored in the second terminal come.
[0105] The second sequence table is used to manage backup files whose source file paths come from different first terminals.
[0106] Specifically, each first sequence table is used to manage backup files from the same first terminal. The source path pointer unit can be used to sort the backup files from the same first terminal but with different source paths according to the set source path sorting rules, so that the backup files from the same first terminal can be managed in order according to the different source paths; and the first time pointer unit can also be used to sort the backup files from the same first terminal but with different acquisition times according to the acquisition time, so that the backup files from the same first terminal can be managed in order according to the acquisition time, which is convenient for finding files in time order (for example, when the first terminal is a camera, the first time pointer unit of the first sequence table can be used to sort each image file backed up from the first terminal to the second terminal according to the shooting time). The source path sorting rules of each first terminal can be set at the second terminal. After setting, the pointer value of the source path pointer unit can be displayed according to the set source path order.
[0107] Further, the second sequence table of the second terminal is used to manage all the backup files received by the second terminal. Each received backup file can be sorted according to the set first terminal sorting rule (such as the first terminal ID number or IP address) through the first terminal pointer unit (the same backup files of the first terminal have the same pointer data corresponding to the first terminal pointer unit), so that each backup file can be managed in sequence according to the source first terminal; and each received backup file can also be sorted according to the acquisition time through the second time pointer unit, so that each received backup file can be managed in sequence according to the acquisition time, which is convenient for searching. The sorting rule of each first terminal can be set in the second terminal. After setting, the pointer data of the first terminal pointer unit can be displayed in the set first terminal sequence. Further, each received backup file can also be sorted according to the geographical location through the geographical location pointer unit, so that each received backup file can be managed in sequence according to the geographical location, which is convenient for partition search. The sorting rule of the geographical location can be set in the second terminal. After setting, the pointer data of the geographical location pointer unit can be displayed in the set geographical location sequence.
[0108] Further, a query instruction is sent to the second terminal, where the query instruction includes the pointer type to be queried and a query pointer range corresponding to the pointer type to be queried.
[0109] For example, when the pointer type queried by the query instruction is the first terminal pointer of the second sequence table, and the query sequence range corresponding to the queried pointer type is the first terminal whose first terminal pointer is 1 to 5, the returned query result is:
[0110] For the backup files managed by the second sequence list, the backup files whose first terminal pointer data are 1 to 5 are returned, and the first terminal pointer data corresponding to the returned backup files are also returned.
[0111] For another example, when the pointer type queried by the query instruction is the first time pointer of each first sequence table, and the query sequence range corresponding to the queried pointer type is the first time pointer 3 to 10, the returned query result is:
[0112] For each backup file managed by the first sequence list, the backup files with the first time pointer data of 3 to 10 are returned, and the first time pointer data corresponding to the returned backup files in the corresponding first sequence list are returned.
[0113] Based on the sixth embodiment of the method for obtaining a remote backup file source path of the present invention, in a seventh embodiment of the method for obtaining a remote backup file source path of the present invention, the method further includes:
[0114] Step S130, calculating the query frequency of each pointer type in the query instruction received by each second terminal to determine the pointer type with the highest query frequency; wherein the pointer types include: a source path pointer unit, a first time pointer unit, a first terminal pointer unit, a second time pointer unit and a geographic location pointer unit;
[0115] Step S140, determining a file backup sorting basis in the second terminal according to the pointer type with the highest query frequency;
[0116] Step S150, when the second terminal detects a newly added file information instruction, the first sequence list and the second sequence list are updated according to the to-be-synchronized file corresponding to the newly added file information instruction;
[0117] Step S160, forming a file backup waiting sequence at the second terminal according to the received file information instruction;
[0118] Step S170: reorder the file backup waiting sequence according to the file backup sorting basis, and arrange the file backup order in the second terminal according to the reordered file backup waiting sequence.
[0119] For example, when the second time pointer is the most frequently queried one in the query instructions received by a second terminal, it means that when the second terminal is querying, the user is most concerned about the order of the collection time of all the backup files received by the second terminal. Therefore, the order of the file backup in the second terminal determined in step S140 is to back up all the files waiting to be backed up by the second terminal in the order of the collection time. At this time, although the files to be synchronized have not been backed up to the second terminal, the first sequence list and the second sequence list can be updated according to the newly added file information instruction. At the second terminal, all the unsynchronized files are added to the file backup waiting sequence, and then according to step S170, the various files in the file backup waiting sequence are reordered according to the pointer data of the second time pointer unit in the second sequence list, and a reordered file backup waiting sequence is obtained. Subsequently, the file backup can be performed according to the reordered file backup waiting sequence.
[0120] If the file backup waiting sequence is in the order, according to the added time of the file information instruction, the file backup waiting sequence is formed (it should be noted that the order of the added time is not necessarily the same as the collection order of the files to be synchronized): file 1 to be synchronized, file 2 to be synchronized, and file 3 to be synchronized.
[0121] The unsynchronized files are arranged according to the pointer data of the second time pointer unit, and the corresponding pointer data are:
[0122] File 1 to be synchronized - the pointer data of the second time pointer unit is 30;
[0123] File 2 to be synchronized - the pointer data of the second time pointer unit is 28;
[0124] File 3 to be synchronized - the pointer data of the second time pointer unit is 29;
[0125] At this time, according to the file backup sorting basis, the file backup waiting sequence is re-sorted as: to-be-synchronized file 2, to-be-synchronized file 3, with synchronization file 1.
[0126] Therefore, when the second terminal performs file backup, the order from front to back is: to-be-synchronized file 2, to-be-synchronized file 3, and synchronized file 1.
[0127] To achieve the above objectives, the present invention also proposes a storage system, comprising at least one first terminal and at least one second terminal, wherein the storage system adopts the method for obtaining the source path of the remote backup file to store the source file path of the file to be synchronized in the first terminal to the second terminal.
[0128] Specifically, the storage system may be a distributed storage system.
[0129] The solution proposed by the present invention only needs to be based on the existing software functions of the Linux system, and does not require additional software and hardware support; the solution does not rely on Rsync log information and can be compatible with various versions; SSH command information can be customized according to different needs and has good scalability.
[0130] Furthermore, in other embodiments, it may also include:
[0131] A solution to achieve the same effect by executing different commands through SSH;
[0132] Methods to extend the solution by executing different commands through SSH;
[0133] The present invention is also applicable to a solution that uses other software such as SCP to realize a remote synchronization function, but also sends synchronization file information through SSH instructions.
[0134] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device to enter the method described in each embodiment of the present invention.
[0135] In the description of this specification, the description with reference to the terms "an embodiment", "another embodiment", "other embodiments", or "first embodiment to Xth embodiment" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, method steps or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0136] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0137] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0138] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for obtaining the source path of a remote backup file. It is characterized in that The steps include: When the first terminal detects the remote backup instruction, the first terminal sends a file information instruction of the file to be synchronized to the second terminal through the remote connection tool, wherein the file information instruction includes the second terminal identifier, the backup file name, the first terminal identifier, the source file path of the file to be synchronized, and the specified file name; Detecting a newly added file information instruction at a second terminal corresponding to the second terminal identifier; When the second terminal detects the file information instruction, a file with a specified file name is generated in a specified directory, and the file with the specified file name includes: a backup file path, a first terminal identifier, and a source file path of the file to be synchronized; When the second terminal detects that a file with a specified file name is newly created in the specified directory, the second terminal parses the content of the file with the specified file name to obtain parsed content, wherein the parsed content includes the backup file path, the first terminal identifier and the source file path of the file to be synchronized; The method further comprises: Sending a remote synchronization instruction to the second terminal through a remote synchronization tool at the first terminal to back up the file to be synchronized to the second terminal, wherein the remote synchronization instruction includes: a source file path of the file to be synchronized, a second terminal identifier, and a backup file path; After the synchronization of the file to be synchronized is completed, generating a backup file of the file to be synchronized in the designated directory of the second terminal; Acquire the source file path of the backup file and the first terminal identifier from the parsed content; On the second terminal, a first sequence list is formed for backup files whose source file paths are from the same first terminal, wherein the first sequence list includes source path pointer units and first time pointer units, which are equal to the number of backup files managed by the first sequence list, and each backup file managed by the first sequence list is respectively generated with a source path pointer unit and a first time pointer unit, wherein the source path pointer unit is used to indicate the source path sequence of the corresponding backup file among all the backup files managed by the first sequence list, and the first time pointer unit is used to indicate the collection time sequence of the corresponding backup file among all the backup files managed by the first sequence list; On the second terminal, a second sequence list is formed for all backup files received by the second terminal, wherein the second sequence list includes first terminal pointer units, second time pointer units and geographic location pointer units, which are equal to the number of backup files managed by the second sequence list respectively, and each backup file managed by the second sequence list is respectively generated with a first terminal pointer unit, a second time pointer unit and a geographic location pointer unit, the first terminal pointer unit is used to indicate the first terminal order of the corresponding backup file among all backup files managed by the second sequence list, the second time pointer unit is used to indicate the collection time order of the corresponding backup file among all backup files managed by the second sequence list, and the geographic location pointer unit is used to indicate the geographic location order of the corresponding backup file among all backup files managed by the second sequence list.
2. The method for obtaining a remote backup file source path according to claim 1, It is characterized in that After the step of parsing the content of the file with the specified file name to obtain the parsed content when the second terminal detects that a file with the specified file name is newly created in the specified directory, the method further includes: Generate cache information according to the parsed content and store it in a cache space of the second terminal; Delete the file with the specified file name; The step of acquiring the source file path of the backup file and the first terminal identifier from the parsed content includes: The parsed content is obtained from the cache space to obtain the source file path of the backup file and the first terminal identifier from the parsed content.
3. The method for obtaining a remote backup file source path according to claim 1, It is characterized in that The first terminal is a camera; the file to be synchronized is an image file captured by the camera.
4. The method for obtaining a remote backup file source path according to claim 3, It is characterized in that The file information instruction also includes: at least one of the acquisition time of the file to be synchronized, the longitude and latitude of the first terminal, and the physical location of the first terminal.
5. The method for obtaining a remote backup file source path according to claim 1, It is characterized in that The first terminal and the second terminal respectively run Linux operating systems, the remote connection tool is SSH, and the remote synchronization tool is Rsync; the first terminal and the second terminal respectively perform detection functions through Inotify modules.
6. The method for obtaining a remote backup file source path according to claim 1, It is characterized in that The method further comprises: Acquire multiple second terminals included in the remote backup instruction; The step of sending a file information instruction of a file to be synchronized to the second terminal through a remote connection tool when the first terminal detects a remote backup instruction comprises: When the first terminal detects the remote backup instruction, the first terminal sends a file information instruction of the to-be-synchronized file to each second terminal included in the remote backup instruction through the remote connection tool.
7. The method for obtaining a remote backup file source path according to claim 1, It is characterized in that The method further comprises: Calculating the query frequency of each pointer type in the query instruction received by each second terminal to determine the pointer type with the highest query frequency; Determine the order of the file backup in the second terminal according to the pointer type with the highest query frequency; When the second terminal detects a newly added file information instruction, the first sequence table and the second sequence table are updated according to the to-be-synchronized file corresponding to the newly added file information instruction; At the second terminal, a file backup waiting sequence is formed according to the received file information instruction; The file backup waiting sequence is reordered according to the file backup sorting basis, and the file backup order in the second terminal is arranged according to the reordered file backup waiting sequence.
8. A storage system, It is characterized in that The storage system comprises at least one first terminal and at least one second terminal, wherein the storage system adopts the method for obtaining the source path of the remote backup file described in any one of claims 1 to 7 to store the source file path of the file to be synchronized in the first terminal to the second terminal.
Citation Information
Patent Citations
Method and device for file backup based on local area network
CN104503864A
Cross-platform remote data backup and restoration methods
CN106776116A
File backup method and device
CN116775374A
