CN108810173B - File synchronization method, device, equipment and computer readable storage medium - Google Patents
File synchronization method, device, equipment and computer readable storage medium Download PDFInfo
- Publication number
- CN108810173B CN108810173B CN201810843164.9A CN201810843164A CN108810173B CN 108810173 B CN108810173 B CN 108810173B CN 201810843164 A CN201810843164 A CN 201810843164A CN 108810173 B CN108810173 B CN 108810173B
- Authority
- CN
- China
- Prior art keywords
- server
- synchronization
- file
- information transmission
- transmission channel
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/04—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
- H04L63/0428—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a file synchronization method, a device, equipment and a computer readable storage medium, wherein the method comprises the following steps: the server generates a public key and private key pair and adds the public key to a specified synchronous server; the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol; and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool. By utilizing the technical scheme provided by the invention, configuration files are not required to be added during file synchronization, the problem of complicated configuration when a daemon mode is adopted for file synchronization in the prior art is solved, and meanwhile, the technical scheme provided by the invention can establish an information transmission channel between the server and the synchronization server without manually inputting passwords.
Description
Technical Field
The present invention relates to the field of data processing, and in particular, to a file synchronization method, apparatus, device, and computer-readable storage medium.
Background
During the development process, the file synchronization is often encountered between servers. rsync is a tool for linux next data replication and synchronization, and can synchronize data between the same machine or machines. rsync synchronizes files between two hosts, local and remote, using its own efficient algorithm that transfers only different portions of two files, rather than in whole copies each time, and is therefore quite fast. To reduce bandwidth, rsync uses compression and decompression algorithms on the data at the sending and receiving ends.
In the prior art, a daemon mode in rsync is adopted for file synchronization, and a socket channel is used. The specific method comprises the following steps: the server (receiver) starts the daemon process to monitor at the port 873, then the client (transmitter) is directly linked to the port 873, and the file is synchronized through authentication. The server and the client need to add a configuration file rsynccd. When a daemon mode under the rsync is adopted for file synchronization, configuration files need to be added at a sending end and a receiving end, a password file also needs to be maintained, and configuration is complex.
Disclosure of Invention
In order to solve the problem of complex configuration when a daemon mode is adopted for file synchronization in the prior art, embodiments of the present invention provide a file synchronization method, apparatus, device, and computer-readable storage medium.
According to an aspect of an embodiment of the present invention, there is provided a file synchronization method, including:
the server generates a public key and private key pair and adds the public key to a specified synchronous server;
the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol;
and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool.
Optionally, in the file synchronization method according to the embodiment of the present invention, establishing an information transmission channel between the server and the synchronization server by using a public-private key verification method includes:
receiving data encrypted by the synchronous server by using the public key, decrypting the data by using a private key in the public key and private key pair, and sending the decrypted data to the synchronous server;
and after receiving a connection instruction sent by the synchronous server, establishing an information transmission channel between the server and the synchronous server.
Optionally, in the file synchronization method according to the embodiment of the present invention, after synchronizing the update file in the server to the synchronization server through the information transmission channel, the method further includes:
acquiring a synchronization result of the update file in the synchronization server;
and when the synchronization result is that the synchronization is not successful, retransmitting the update file to the synchronization server through the information transmission channel.
Optionally, in the file synchronization method according to the embodiment of the present invention, after retransmitting the update file to the synchronization server through the information transmission channel, the method further includes:
and when the retransmission is unsuccessful, recording the address of the synchronous server and the update file, and feeding back the address and the update file according to a preset mode.
Optionally, in the file synchronization method according to the embodiment of the present invention, when synchronizing the update file in the server to the synchronization server through the information transmission channel, the method further includes: and sending the synchronous directory of the updated file in the synchronous server to the synchronous server.
Optionally, in the file synchronization method according to the embodiment of the present invention, the network protocol includes: ssh; and/or, the synchronization tool comprises: rsync.
According to another aspect of the embodiments of the present invention, there is provided a file synchronization apparatus, including a public key and private key pair generation processing module, an information transmission channel establishing module, and a file synchronization module:
the public key and private key pair generation processing module is used for generating a public key and private key pair and adding a public key to a specified synchronous server;
the information transmission channel establishing module is used for establishing an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol;
and the file synchronization module is used for synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool.
Optionally, in the file synchronization apparatus according to the embodiment of the present invention, the information transmission channel establishing module is specifically configured to:
receiving data encrypted by the synchronous server by using the public key, decrypting the data by using a private key in the public key and private key pair, and sending the decrypted data to the synchronous server;
and after receiving a connection instruction sent by the synchronous server, establishing an information transmission channel between the server and the synchronous server.
Optionally, in the file synchronization apparatus according to the embodiment of the present invention, the file synchronization apparatus further includes a synchronization result obtaining module:
the synchronization result acquisition module is used for acquiring the synchronization result of the update file in the synchronization server;
and the file synchronization module is used for retransmitting the update file to the synchronization server through the information transmission channel when the synchronization result is that the synchronization is not successful.
Optionally, in the file synchronization apparatus according to the embodiment of the present invention, the file synchronization apparatus further includes a feedback module:
and the feedback module is used for recording the address of the synchronous server and the update file when the retransmission is unsuccessful, and feeding back the address and the update file according to a preset mode.
Optionally, in the file synchronization apparatus according to the embodiment of the present invention, the file synchronization module is further configured to: and sending the synchronous directory of the updated file in the synchronous server to the synchronous server.
Optionally, in the file synchronization apparatus according to the embodiment of the present invention, the network protocol includes: ssh; and/or, the synchronization tool comprises: rsync.
According to a third aspect of the embodiments of the present invention, there is provided a file synchronization apparatus including: memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the file synchronization method as described above.
According to a fourth aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the file synchronization method as described above.
The embodiment of the invention has the following beneficial effects:
according to the file synchronization method, the device, the equipment and the computer readable storage medium provided by the embodiment of the invention, password-free connection of an information transmission channel is realized by utilizing a public-private key verification mode, an updated file in a server is synchronized to a synchronization server through the information transmission channel by utilizing a synchronization tool, a configuration file is not required to be added during file synchronization, the problem of complicated configuration during file synchronization by adopting a daemon mode in the prior art is solved, and meanwhile, the information transmission channel between the server and the synchronization server can be established without manually inputting a password.
The foregoing description is only an overview of the technical solutions of the embodiments of the present invention, and the embodiments of the present invention can be implemented according to the content of the description in order to make the technical means of the embodiments of the present invention more clearly understood, and the detailed description of the embodiments of the present invention is provided below in order to make the foregoing and other objects, features, and advantages of the embodiments of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the embodiments of the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flowchart illustrating a file synchronization method according to a first embodiment of the present invention;
FIG. 2 is a flowchart illustrating a file synchronization method according to a second embodiment of the present invention;
FIG. 3 is a flowchart illustrating a file synchronization method according to a third embodiment of the present invention;
FIG. 4 is a flowchart illustrating a file synchronization method according to a fourth embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a file synchronization apparatus according to a fifth embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a file synchronization apparatus according to a sixth embodiment of the present invention;
FIG. 7 is a flowchart illustrating a file synchronization method in example 1 according to the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention solely thereto.
According to a first embodiment of the present invention, a file synchronization method is provided and applied to a server. Fig. 1 is a schematic flow chart of a file synchronization method according to a first embodiment of the present invention, and as shown in fig. 1, the file synchronization method according to the first embodiment of the present invention includes the following steps:
s101: the server generates a public-private key pair and adds the public key to the designated sync server.
In the embodiment of the present invention, the synchronization server refers to a server that receives an update file. The designated synchronization server refers to a synchronization server which needs to perform file synchronization and is determined according to a synchronization server list pre-stored in the server. For example, the synchronization servers that need to perform file synchronization, which are determined according to the synchronization server list pre-stored in the server a, are the server B, the server C, and the server D, and then the server B, the server C, and the server D are all designated synchronization servers.
For example, the server generates a public key and a private key pair, and adds the public key to the synchronization server, which may adopt the following technical solutions: the server generates a ssh public key and private key pair, a command line ssh-keygen, such as ssh-keygen-t rsa-C "ssh description" -f-/. ssh/libSync _ rsa, libSync _ rsa is a designated public private key name, so as to avoid conflict with the existing ssh public private key name, and two files of a public key libSync _ rsa.pub and a private key libSync _ rsa can be generated in a-/. ssh directory. Adding a public key to a synchronization server, executing a command ssh-copy-id, and specifying a public key file, such as ssh-copy-id-i-/. ssh/libSync _ rsa.pub user @ dest _ ip, if the addition is for the first time, generating an authorized _ keys file on the synchronization server, wherein the content is the content of the public key file, and if the addition is not, adding the encrypted _ keys file. The ssh private key is added locally and the command ssh-add is executed, such as ssh-add-/. ssh/libSync _ rsa.
S102: and the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol.
Optionally, in this embodiment of the present invention, the network protocol includes: ssh. Ssh is a network protocol used for encrypted login between computers.
S103: and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool.
Optionally, in an embodiment of the present invention, the synchronization tool includes: rsync. The rsync synchronizes the updated part through a diff algorithm of the rsync, all files are not copied, and the synchronizing speed is extremely high.
The file synchronization method provided by the first embodiment of the present invention utilizes a public-private key verification method to achieve password-free connection of an information transmission channel, and then utilizes a synchronization tool to synchronize an updated file in a server to a synchronization server through the information transmission channel, and does not need to add a configuration file when performing file synchronization, thereby solving the problem of complex configuration when performing file synchronization by adopting a daemon mode in the prior art, and simultaneously, the information transmission channel between the server and the synchronization server can be established without manually inputting a password.
According to a second embodiment of the present invention, a file synchronization method is provided and applied to a server. Fig. 2 is a schematic flow chart of a file synchronization method according to a second embodiment of the present invention, and as shown in fig. 2, the file synchronization method according to the second embodiment of the present invention includes the following steps:
s201: the server generates a public-private key pair and adds the public key to the designated sync server.
S202: and the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol.
S203: and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool.
S204: and acquiring a synchronization result of the update file in the synchronization server, and retransmitting the update file to the synchronization server through the information transmission channel when the synchronization result is that the synchronization is not successful.
The retransmissions include immediate retransmissions and delayed retransmissions. The immediate retransmission refers to that when the synchronization result is that the synchronization is not successful, the update file is immediately retransmitted to the synchronization server; the delayed retransmission refers to retransmitting the update file to the synchronization server after waiting for a preset time (for example, 10 minutes) when the synchronization result is that the synchronization is not successful.
Optionally, in the embodiment of the present invention, when the synchronization result is that synchronization is unsuccessful, the update file is immediately retransmitted to the synchronization server through the information transmission channel; and when the synchronization result is that the synchronization is successful, determining the next synchronization server according to the synchronization server list, establishing an information transmission channel between the server and the next synchronization server, and synchronizing the files.
Optionally, in the embodiment of the present invention, when the synchronization result is that synchronization is unsuccessful, the update file is delayed and retransmitted to the synchronization server through the information transmission channel; and when the synchronization result is that the synchronization is successful, determining the next synchronization server according to the synchronization server list, establishing an information transmission channel between the server and the next synchronization server, and synchronizing the files.
Optionally, in the embodiment of the present invention, when the synchronization result is that synchronization is unsuccessful, the updated file is immediately retransmitted to the synchronization server through the information transmission channel, and when the immediate retransmission result is that synchronization is successful, a next synchronization server is determined according to the synchronization server list, an information transmission channel between the server and the next synchronization server is established, and file synchronization is performed; and when the immediate retransmission result is that the synchronization is not successful, delaying and retransmitting the updated file to the synchronization server through the information transmission channel, and when the delayed retransmission result is that the synchronization is successful, determining the next synchronization server according to the synchronization server list, establishing the information transmission channel between the server and the next synchronization server, and synchronizing the file.
Optionally, in this embodiment of the present invention, after retransmitting the update file to the synchronization server through the information transmission channel, the method further includes: and when the retransmission is unsuccessful, recording the address of the synchronous server and the updated file, and feeding back according to a preset mode so as to facilitate repair or manual retransmission of related workers. The preset mode includes, but is not limited to, mail.
The file synchronization method provided by the second embodiment of the present invention not only can utilize a public-private key verification method to implement password-free connection of an information transmission channel, but also can utilize a synchronization tool to synchronize an updated file in a server to a synchronization server through the information transmission channel, thereby solving the problem of complex configuration when a daemon mode is adopted to perform file synchronization in the prior art; when the server has a file update, the updated file can be synchronized to all specified synchronization servers needing file synchronization in real time, and retransmission can be carried out based on monitoring of synchronization results, so that the successful file synchronization is ensured.
According to a third embodiment of the present invention, a file synchronization method is provided and applied to a server. Fig. 3 is a schematic flow chart of a file synchronization method according to a third embodiment of the present invention, and as shown in fig. 3, the file synchronization method according to the third embodiment of the present invention includes the following steps:
s301: the server generates a public-private key pair and adds the public key to the designated sync server.
S302: and the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol.
S303: and synchronizing the update file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool, and simultaneously sending the synchronization directory of the update file in the synchronization server to the synchronization server.
That is, the server simultaneously transmits the update file, the synchronization directory of the update file in the synchronization server, to the synchronization server through an information transmission channel between the server and the synchronization server by using a preset synchronization tool (e.g., rsync). For example, rsync synchronizes the update part through its diff algorithm, and not all files are copied, and the synchronization speed is extremely fast. The method comprises the following steps: rsync-avz-e ssh-delete-exception-exceudedcfile srcPath user @ dest _ ip rsyncdir/, where srcPath is a sender file directory (i.e. an update file), dest _ ip is a receiver server ip, user is a login account, rsync _ dir is a file synchronization directory (i.e. a synchronization directory of an update file in a synchronization server), delete indicates that the receiver needs to delete if the sender has a deleted file, and exception expile indicates a file or directory that is not synchronized in the past, such as filtering out git directories.
The file synchronization method provided by the third embodiment of the present invention not only can utilize a public-private key verification method to implement password-free connection of an information transmission channel, but also can utilize a synchronization tool to synchronize an updated file in a server to a synchronization server through the information transmission channel, thereby solving the problem of complex configuration when a daemon mode is adopted to perform file synchronization in the prior art; and the synchronous directory of the update file in the synchronous server can be sent to the synchronous server in the information transmission channel, that is, the synchronous directory does not need to be configured in the configuration file, and the modification is more flexible.
According to a fourth embodiment of the present invention, a file synchronization method is provided, which is applied to a server. Fig. 4 is a schematic flow chart of a file synchronization method according to a fourth embodiment of the present invention, and as shown in fig. 4, the file synchronization method according to the fourth embodiment of the present invention includes the following steps:
s401: the server generates a public-private key pair and adds the public key to the designated sync server.
S402: and receiving the data encrypted by the synchronous server by using the public key, decrypting the data by using a private key in the public key and private key pair, and sending the decrypted data to the synchronous server.
Optionally, in this embodiment of the present invention, before receiving the data encrypted by the synchronization server using the public key, the method further includes: and sending an encryption instruction to the synchronous server to instruct the synchronous server to encrypt preset data by using the public key.
S403: and after receiving a connection instruction sent by the synchronous server, establishing an information transmission channel between the server and the synchronous server.
S404: and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool.
The file synchronization method provided by the fourth embodiment of the present invention utilizes public and private key encryption and decryption to achieve password-free connection of an information transmission channel, and simultaneously utilizes a synchronization tool to synchronize an updated file in a server to a synchronization server through the information transmission channel, thereby solving the problem of complex configuration when a daemon mode is adopted to perform file synchronization in the prior art.
A fifth embodiment of the present invention provides a file synchronization apparatus, which is applied to a server. Fig. 5 is a schematic structural diagram of a file synchronization apparatus according to a fifth embodiment of the present invention, and as shown in fig. 5, the file synchronization apparatus according to the fifth embodiment of the present invention includes a public key and private key pair generation processing module 50, an information transmission channel establishing module 52, and a file synchronization module 54, which are described in detail below.
The public key and private key pair generation processing module 50 is configured to generate a public key and private key pair and add the public key to the specified synchronization server.
The information transmission channel establishing module 52 is configured to establish an information transmission channel between the server and the synchronization server in a public and private key verification manner according to a set network protocol.
In one embodiment, the network protocol comprises ssh.
As a specific implementation manner, the information transmission channel establishing module 52 is specifically configured to:
receiving data encrypted by the synchronous server by using the public key, decrypting the data by using a private key in the public key and private key pair, and sending the decrypted data to the synchronous server;
and after receiving a connection instruction sent by the synchronous server, establishing an information transmission channel between the server and the synchronous server.
The file synchronization module 54 is configured to synchronize the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool.
Optionally, the file synchronization module 54 is further configured to: the synchronous directory of the updated file in the synchronous server is sent to the synchronous server, and the synchronous directory of the updated file in the synchronous server can be sent to the synchronous server in an information transmission channel, that is, the synchronous directory does not need to be configured in a configuration file, and the modification is more flexible.
As a specific embodiment, the synchronization tool includes rsync.
Optionally, the file synchronization apparatus according to the fifth embodiment of the present invention further includes a synchronization result obtaining module: the synchronization result acquisition module is used for acquiring the synchronization result of the update file in the synchronization server; the file synchronization module is used for retransmitting the updated file to the synchronization server through the information transmission channel when the synchronization result is that the synchronization is not successful.
The retransmissions include immediate retransmissions and delayed retransmissions. The immediate retransmission refers to that when the synchronization result is that the synchronization is not successful, the update file is immediately retransmitted to the synchronization server; the delayed retransmission refers to retransmitting the update file to the synchronization server after waiting for a preset time (for example, 10 minutes) when the synchronization result is that the synchronization is not successful.
Optionally, the file synchronization apparatus according to the fifth embodiment of the present invention further includes a feedback module: and the feedback module is used for recording the address of the synchronous server and the updated file when the retransmission is unsuccessful, and feeding back the address and the updated file according to a preset mode so as to facilitate repair or manual retransmission of related workers.
The file synchronization apparatus according to the fifth embodiment of the present invention utilizes a public-private key verification method to achieve password-free connection of an information transmission channel, and then utilizes a synchronization tool to synchronize an updated file in a server to a synchronization server through the information transmission channel, so as to solve the problem of complex configuration when a daemon mode is used for file synchronization in the prior art.
A sixth embodiment of the present invention provides a file synchronization apparatus. Fig. 6 is a schematic structural diagram of a file synchronization apparatus in a sixth embodiment of the present invention, and as shown in fig. 6, the file synchronization apparatus includes: a memory 62, a processor 64 and a computer program stored on the memory 62 and executable on the processor 64, the computer program when executed by the processor implementing the steps of: the server generates a public key and private key pair and adds the public key to a specified synchronous server; the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol;
and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool. More specific implementation manners are as described in the first to fourth embodiments, and are not described herein again.
The seventh embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, where the computer program when executed by a processor implements the steps of: the server generates a public key and private key pair and adds the public key to a specified synchronous server; the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol; and synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool. More specific implementation manners are as described in the first to fourth embodiments, and are not described herein again. Among the computer-readable storage media are, but not limited to: ROM, RAM, magnetic or optical disks, and the like.
To explain the embodiment of the present invention in more detail, an example 1 is given, fig. 7 is a schematic flow chart of a file synchronization method in the example 1 of the embodiment of the present invention, as shown in fig. 7, the example 1 includes the following steps:
1. a server (e.g., server a) generates a ssh public-private key pair (referred to as a public-private key pair in fig. 7), a command line ssh-keygen, such as ssh-keygen-t rsa-C "ssh description" -f-/. ssh/libSync _ rsa, libSync _ rsa is a designated public-private key name, so as to avoid collision with the existing ssh public-private key name, and two files, namely, public key libSync _ rsa.pub and private key libSync _ rsa, are generated under the directory of-/. ssh.
2. Adding the generated public key to all the synchronization servers (such as server B, server C and server D), executing a command ssh-copy-id, and specifying a public key file, such as ssh-copy-id-i-/. ssh/libSync _ rsa.pubuser @ dest _ ip.
3. The ssh private key is added locally (i.e., server A), and the command ssh-add is executed, such as ssh-add-/. ssh/libSync _ rsa.
4. And if the server A has file updating, triggering file synchronization operation and executing 5.
5. All synchronization servers (referred to as server B, server C and server D in example 1) are file synchronized in turn according to the server list (i.e. the synchronization server list, such as the ip list). For example, when performing file synchronization on a server B, executing a command rsync, where the rsync directly walks through an ssh channel (i.e., an information transmission channel between the server a and the server B, which is established by the server a in a public and private key verification manner), and performs file synchronization operation without inputting a login password of the server B, and the rsync synchronizes an update part through a diff algorithm of the rsync, so that not all files are copied, and the synchronization speed is extremely high. The method comprises the following steps: rsync-avz-e ssh-delete-exception-exceudedcfile srcPath user @ dest _ ip rsync _ dir/, where srcPath is a sender file directory, dest _ ip is a receiver server ip, user is a login account, rsync _ dir is a file synchronization directory, delete indicates that if a sender deletes a file, the receiver also deletes the file, and exception-exceudecfile indicates a file or a directory that is not synchronized in the past, such as filtering out a git directory.
6. Listen for rsync sync result, $? A value, such as ret $? Successfully returns 0 and fails to be other than 0. If successful, continuing rsync synchronization to the next synchronization server (i.e. server C) determined according to the server list, and executing step 5; otherwise an immediate retransmission is performed (called resynchronization in fig. 7).
7. Monitoring an immediate retransmission result, and if the immediate retransmission result is successful, executing step 5; otherwise, a deferred retransmission (referred to as deferred synchronization in fig. 7) is attempted again, e.g., 10 minutes later to perform synchronization to the current synchronization server.
8. If the delayed retransmission is successful, executing 5; otherwise, server and file directory information is recorded, possibly requiring only partial directories to be resynchronized.
9. And summarizing synchronization failure information, sending a mail to notify relevant personnel, finishing the synchronization of the server, carrying out technical repair on the relevant personnel, and executing the failed synchronization information again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
In short, the above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (12)
1. A method for file synchronization, the method comprising:
the server generates a public key and private key pair and adds the public key to a specified synchronous server;
the server establishes an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol;
synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool;
establishing an information transmission channel between the server and the synchronous server by using a public and private key verification mode, wherein the method comprises the following steps:
receiving data encrypted by the synchronous server by using the public key, decrypting the data by using a private key in the public key and private key pair, and sending the decrypted data to the synchronous server;
and after receiving a connection instruction sent by the synchronous server, establishing an information transmission channel between the server and the synchronous server.
2. The method of claim 1, after synchronizing the update file in the server to the synchronization server through the information transmission channel, further comprising:
acquiring a synchronization result of the update file in the synchronization server;
and when the synchronization result is that the synchronization is not successful, retransmitting the update file to the synchronization server through the information transmission channel.
3. The method of claim 2, further comprising, after retransmitting the update file to the synchronization server over the information transfer channel:
and when the retransmission is unsuccessful, recording the address of the synchronous server and the update file, and feeding back the address and the update file according to a preset mode.
4. The method of claim 1, wherein, when synchronizing the update file in the server to the synchronization server through the information transmission channel, further comprising: and sending the synchronous directory of the updated file in the synchronous server to the synchronous server.
5. The method of any of claims 1 to 4, wherein the network protocol comprises: ssh; and/or, the synchronization tool comprises: rsync.
6. A file synchronization device is characterized in that the device comprises a public key and private key pair generation processing module, an information transmission channel establishing module and a file synchronization module:
the public key and private key pair generation processing module is used for generating a public key and private key pair and adding a public key to a specified synchronous server;
the information transmission channel establishing module is used for establishing an information transmission channel between the server and the synchronous server by utilizing a public and private key verification mode according to a set network protocol;
the file synchronization module is used for synchronizing the updated file in the server to the synchronization server through the information transmission channel by using a preset synchronization tool;
the information transmission channel establishing module is specifically configured to:
receiving data encrypted by the synchronous server by using the public key, decrypting the data by using a private key in the public key and private key pair, and sending the decrypted data to the synchronous server;
and after receiving a connection instruction sent by the synchronous server, establishing an information transmission channel between the server and the synchronous server.
7. The apparatus of claim 6, further comprising a synchronization result acquisition module to:
the synchronization result acquisition module is used for acquiring the synchronization result of the update file in the synchronization server;
and the file synchronization module is used for retransmitting the update file to the synchronization server through the information transmission channel when the synchronization result is that the synchronization is not successful.
8. The apparatus of claim 7, further comprising a feedback module:
and the feedback module is used for recording the address of the synchronous server and the update file when the retransmission is unsuccessful, and feeding back the address and the update file according to a preset mode.
9. The apparatus of claim 6, wherein the file synchronization module is further to: and sending the synchronous directory of the updated file in the synchronous server to the synchronous server.
10. The apparatus of any of claims 6 to 9, wherein the network protocol comprises: ssh; and/or, the synchronization tool comprises: rsync.
11. A file synchronization apparatus characterized by comprising: memory, processor and computer program stored on the memory and executable on the processor, the computer program when executed by the processor implementing the steps of the file synchronization method according to any of claims 1 to 5.
12. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the file synchronization method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810843164.9A CN108810173B (en) | 2018-07-27 | 2018-07-27 | File synchronization method, device, equipment and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810843164.9A CN108810173B (en) | 2018-07-27 | 2018-07-27 | File synchronization method, device, equipment and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108810173A CN108810173A (en) | 2018-11-13 |
CN108810173B true CN108810173B (en) | 2022-02-25 |
Family
ID=64078429
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810843164.9A Active CN108810173B (en) | 2018-07-27 | 2018-07-27 | File synchronization method, device, equipment and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108810173B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102801559A (en) * | 2012-08-03 | 2012-11-28 | 南京富士通南大软件技术有限公司 | Intelligent local area network data collecting method |
CN105141568A (en) * | 2014-05-28 | 2015-12-09 | 腾讯科技(深圳)有限公司 | Safe communication channel establishment method and system, client and server |
CN106713363A (en) * | 2017-02-27 | 2017-05-24 | 北京亚太东方通信网络有限公司 | Method for constructing interactive network service based on global transmission sharing |
CN107623743A (en) * | 2017-10-09 | 2018-01-23 | 山东浪潮通软信息科技有限公司 | A kind of remote document access method, service end and system |
CN107992354A (en) * | 2017-11-14 | 2018-05-04 | 网易无尾熊(杭州)科技有限公司 | For reducing the method and device of memory load |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9135284B1 (en) * | 2008-03-13 | 2015-09-15 | Blue Coat Systems, Inc. | Composite execution of rename operations in wide area file systems |
-
2018
- 2018-07-27 CN CN201810843164.9A patent/CN108810173B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102801559A (en) * | 2012-08-03 | 2012-11-28 | 南京富士通南大软件技术有限公司 | Intelligent local area network data collecting method |
CN105141568A (en) * | 2014-05-28 | 2015-12-09 | 腾讯科技(深圳)有限公司 | Safe communication channel establishment method and system, client and server |
CN106713363A (en) * | 2017-02-27 | 2017-05-24 | 北京亚太东方通信网络有限公司 | Method for constructing interactive network service based on global transmission sharing |
CN107623743A (en) * | 2017-10-09 | 2018-01-23 | 山东浪潮通软信息科技有限公司 | A kind of remote document access method, service end and system |
CN107992354A (en) * | 2017-11-14 | 2018-05-04 | 网易无尾熊(杭州)科技有限公司 | For reducing the method and device of memory load |
Also Published As
Publication number | Publication date |
---|---|
CN108810173A (en) | 2018-11-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10554392B2 (en) | Cryptographic key distribution | |
EP1866766B1 (en) | Automatic reconnect and reacquisition in a computer investigation system | |
US20090119504A1 (en) | Intercepting and split-terminating authenticated communication connections | |
US20060075474A1 (en) | Service providing system, information processing apparatus, service providing server and service providing method | |
US10050944B2 (en) | Process to access a data storage device of a cloud computer system with the help of a modified Domain Name System (DNS) | |
US11784811B2 (en) | Storage of cryptographic information | |
US11210178B2 (en) | Synchronization storage solution after an offline event | |
WO2005055514A1 (en) | Methods, systems and computer program products for automatic rekeying in an authentication environment | |
CN109120611B (en) | User authentication method, apparatus, system and medium for address generation server | |
CN112468571B (en) | Intranet and extranet data synchronization method and device, electronic equipment and storage medium | |
KR20170081504A (en) | Method and apparatus for deduplication of encrypted data | |
JP2012137975A (en) | Relay processor, control method for the same and program | |
CN112053477B (en) | Control system, method and device of intelligent door lock and readable storage medium | |
CN113810373B (en) | Ceph visual one-key deployment method based on national cryptographic algorithm | |
CN115174081A (en) | Key synchronization method and system for VSM cold migration | |
JP5795554B2 (en) | File synchronization system using differential encryption, method and program thereof | |
JPH1020779A (en) | Key changing method in open key cipher system | |
CN108810173B (en) | File synchronization method, device, equipment and computer readable storage medium | |
JP2005303676A (en) | Image forming device, paired key generating method, and computer program | |
CN112689016B (en) | Intelligent device control method, device and storage medium | |
CN109165199A (en) | A kind of file synchronisation method, device, equipment and computer readable storage medium | |
CN103973674A (en) | Method and device for synchronizing host and backup information | |
JP2005032184A (en) | Software providing method and system | |
CN116991633B (en) | Data backup processing method, device and equipment | |
CN111130796A (en) | Secure online cloud storage method in instant messaging |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |