CN108810173A - A kind of file synchronisation method, device, equipment and computer readable storage medium - Google Patents

A kind of file synchronisation method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN108810173A
CN108810173A CN201810843164.9A CN201810843164A CN108810173A CN 108810173 A CN108810173 A CN 108810173A CN 201810843164 A CN201810843164 A CN 201810843164A CN 108810173 A CN108810173 A CN 108810173A
Authority
CN
China
Prior art keywords
server
file
sync server
public
sync
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.)
Granted
Application number
CN201810843164.9A
Other languages
Chinese (zh)
Other versions
CN108810173B (en
Inventor
曾庆隆
吕庆春
彭飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuba Co Ltd
Original Assignee
Wuba Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Wuba Co Ltd filed Critical Wuba Co Ltd
Priority to CN201810843164.9A priority Critical patent/CN108810173B/en
Publication of CN108810173A publication Critical patent/CN108810173A/en
Application granted granted Critical
Publication of CN108810173B publication Critical patent/CN108810173B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network 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 present invention provides a kind of file synchronisation method, device, equipment and computer readable storage medium, wherein method includes:Server generates public, private key key pair, and public key is added to specified sync server;Server establishes the information transfer channel between server and sync server according to the procotol of setting in the way of the verification of public and private key;Using preset synchronization means, by information transfer channel by the update file synchronization in server to sync server.Utilize technical solution provided by the invention, configuration file need not be added when carrying out file synchronization, solve the problems, such as to configure when carrying out file synchronization using daemon patterns in the prior art cumbersome, while technical scheme of the present invention need not be manually entered password can establish information transfer channel between server and sync server.

Description

A kind of file synchronisation method, device, equipment and computer readable storage medium
Technical field
The present invention relates to data processing field, more particularly to a kind of file synchronisation method, device, equipment and computer-readable Storage medium.
Background technology
The case where file synchronization is frequently encountered in development process, between server.Rsync is the next data of linux It replicates and synchronous tool, it can be in synchrodata on the same stage or between more machines.Rsync makes this using itself highly effective algorithm File between ground and long-range two hosts reaches synchronous, this algorithm only transmits the different piece of two files, rather than every Secondary all whole part transmission, therefore speed is quite fast.For reduce bandwidth, rsync send and receive end to data using compression conciliate Press algorithm.
In the prior art, file synchronization is carried out using the daemon patterns under rsync, what is walked is the channels socket.Tool Body way is:Server-side (receiving terminal) starts daemon finger daemons, monitors in port 873, then client (transmitting terminal) is straight Chain link is connected to 873 ports, by certification, and then synchronous documents.Server-side and client are required for addition configuration file Rsyncd.conf defines the information such as synchronous user, synchronous directory path, cryptogam inside configuration file.Work as use When daemon patterns under rsync carry out file synchronization, it is required for addition configuration file in transmitting terminal and receiving terminal, it is also necessary to tie up A cryptogam is protected, configuration is comparatively laborious.
Invention content
In order to solve the problems, such as that it is cumbersome that the when of using daemon patterns to carry out file synchronization in the prior art configures, the present invention is real It applies example and provides a kind of file synchronisation method, device, equipment and computer readable storage medium.
The one side of embodiment according to the present invention provides a kind of file synchronisation method, including:
Server generates public, private key key pair, and public key is added to specified sync server;
Server according to setting procotol, in the way of the verification of public and private key, establish the server with it is described same Walk the information transfer channel between server;
Using preset synchronization means, by described information transmission channel by the update file synchronization in the server extremely The sync server.
Optionally, in the file synchronisation method described in the embodiment of the present invention, in the way of the verification of public and private key, institute is established The information transfer channel between server and the sync server is stated, including:
The sync server is received using the data after the public key encryption, utilizes the public, private key cipher key pair Private key is sent to the sync server to the data deciphering, and by the data after decryption;
After receiving the link order that the sync server is sent, the server and the sync server are established Between information transfer channel.
Optionally, in the file synchronisation method described in the embodiment of the present invention, by described information transmission channel by institute After stating the update file synchronization to the sync server in server, further include:
Obtain synchronized result of the update file in the sync server;
When the synchronized result be synchronize failed when, by described information transmission channel by the update file retransmission extremely The sync server.
Optionally, in the file synchronisation method described in the embodiment of the present invention, by described information transmission channel by institute After stating update file retransmission to the sync server, further include:
When retransmitting failed, the address of the sync server and the update file are recorded, and according to preset side Formula is fed back.
Optionally, in the file synchronisation method described in the embodiment of the present invention, by described information transmission channel by institute When stating update file synchronization to the sync server in server, further include:By the update file in the synchronous clothes Synchronous directory in business device is sent to the sync server.
Optionally, in the file synchronisation method described in the embodiment of the present invention, the procotol includes:ssh;And/or The synchronization means includes:rsync.
The other side of embodiment according to the present invention provides a kind of file synchronizer, including public, private key key To generating processing module, information transfer channel establishes module and file synchronization module:
The public, private key key pair generates processing module, is added to for generating public, private key key pair, and by public key Specified sync server;
Described information transmission channel establishes module, for the procotol according to setting, in the way of the verification of public and private key, Establish the information transfer channel between the server and the sync server;
The file synchronization module, for utilizing preset synchronization means, by described information transmission channel by the clothes The update file synchronization being engaged in device is to the sync server.
Optionally, in the file synchronizer described in the embodiment of the present invention, described information transmission channel establishes module tool Body is used for:
The sync server is received using the data after the public key encryption, utilizes the public, private key cipher key pair Private key is sent to the sync server to the data deciphering, and by the data after decryption;
After receiving the link order that the sync server is sent, the server and the sync server are established Between information transfer channel.
Optionally, further include synchronized result acquisition module in the file synchronizer described in the embodiment of the present invention:
The synchronized result acquisition module, for obtaining synchronous knot of the update file in the sync server Fruit;
The file synchronization module, for when the synchronized result is to synchronize failed, being transmitted by described information logical Road is by the update file retransmission to the sync server.
Optionally, further include feedback module in the file synchronizer described in the embodiment of the present invention:
The feedback module, the address for when retransmitting failed, recording the sync server and update text Part, and fed back according to preset mode.
Optionally, in the file synchronizer described in the embodiment of the present invention, the file synchronization module is additionally operable to:By institute It states synchronous directory of the update file in the sync server and is sent to the sync server.
Optionally, in the file synchronizer described in the embodiment of the present invention, the procotol includes:ssh;And/or The synchronization means includes:rsync.
According to the present invention in terms of the third of embodiment, a kind of file synchronization equipment, the file synchronization equipment are provided Including:Memory, processor and it is stored in the computer program that can be run on the memory and on the processor, it is described The step of computer program realizes file synchronisation method as described above when being executed by the processor.
4th aspect of embodiment according to the present invention, additionally provides a kind of computer readable storage medium, the calculating It is stored with computer program on machine readable storage medium storing program for executing, text as described above is realized when the computer program is executed by processor The step of part synchronous method.
The embodiment of the present invention has the beneficial effect that:
File synchronisation method, device, equipment and computer readable storage medium provided in an embodiment of the present invention, utilization are public and private Key verification mode realizes being connected without password for information transfer channel, recycles synchronization means by information transfer channel by server In update file synchronization to sync server, need not add configuration file when carrying out file synchronization, solve existing skill Cumbersome problem is configured when carrying out file synchronization using daemon patterns in art, while password need not be manually entered can to build Vertical information transfer channel between server and sync server.
Above description is only the general introduction of technical solution of the embodiment of the present invention, in order to better understand the embodiment of the present invention Technological means, and can be implemented in accordance with the contents of the specification, and in order to allow above and other mesh of the embodiment of the present invention , feature and advantage can be clearer and more comprehensible, the special specific implementation mode for lifting the embodiment of the present invention below.
Description of the drawings
By reading the detailed description of hereafter preferred embodiment, various other advantages and benefit are common for this field Technical staff will become clear.Attached drawing only for the purpose of illustrating preferred embodiments, and is not considered as to the present invention The limitation of embodiment.And throughout the drawings, the same reference numbers will be used to refer to the same parts.In the accompanying drawings:
Fig. 1 is the flow diagram of file synchronisation method in first embodiment of the invention;
Fig. 2 is the flow diagram of file synchronisation method in second embodiment of the invention;
Fig. 3 is the flow diagram of file synchronisation method in third embodiment of the invention;
Fig. 4 is the flow diagram of file synchronisation method in fourth embodiment of the invention;
Fig. 5 is the structural schematic diagram of file synchronizer in fifth embodiment of the invention;
Fig. 6 is the structural schematic diagram of file synchronizer in sixth embodiment of the invention;
Fig. 7 is the flow diagram of file synchronisation method in example of the embodiment of the present invention 1.
Specific implementation mode
Exemplary embodiment of the present invention is more fully described below with reference to accompanying drawings.Although showing the present invention in attached drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the present invention without should be by embodiments set forth here It is limited.It is to be able to be best understood from the present invention on the contrary, providing these embodiments, and can be by the scope of the present invention Completely it is communicated to those skilled in the art.It should be appreciated that specific embodiment described herein is only used to explain this hair It is bright, it is not used to uniquely limit the present invention.
First embodiment according to the present invention provides a kind of file synchronisation method, is applied to server.Fig. 1 is this hair The flow diagram of file synchronisation method in bright first embodiment, as shown in Figure 1, the file synchronization side of first embodiment of the invention Method includes the following steps:
S101:Server generates public, private key key pair, and public key is added to specified sync server.
In embodiments of the present invention, sync server refers to receiving the server of update file.Specified sync server Refer to the sync server for needing to carry out file synchronization determined according to the sync server list to prestore in server.Such as According to the sync server for needing to carry out file synchronization that the sync server list that prestores in server A determines be server B, Server C and server D, then server B, server C and server D are specified sync server.
It is exemplary, server generate public, private key key pair, and by public key be added to sync server can be used it is following Technical solution:Server generates ssh public, private key key pairs, order line ssh-keygen, such as ssh-keygen-t rsa-C " Ssh description "-f~/.ssh/libSync_rsa, libSync_rsa are the public and private key name specified, in order to avoid with having The public and private key name conflicts of ssh, can generate public key libSync_rsa.pub and private key libSync_rsa two under~/.ssh catalogues File.Public key is added to sync server, order ssh-copy-id is executed, specifies public key file, such as ssh-copy-id-i ~/.ssh/libSync_rsa.pub user@dest_ip add if it is first time, one can be generated in sync server A authorized_keys files, content are public key file content, are otherwise to be appended to authorized_keys files.It will Ssh private keys are added to local, order ssh-add are executed, such as ssh-add~/.ssh/libSync_rsa.
S102:Server establishes the server and institute according to the procotol of setting in the way of the verification of public and private key State the information transfer channel between sync server.
Optionally, in embodiments of the present invention, the procotol includes:ssh.Wherein, ssh is a kind of procotol, Encrypted login for intercomputer.
S103:Using preset synchronization means, by described information transmission channel by the update file in the server It is synchronized to the sync server.
Optionally, in embodiments of the present invention, the synchronization means includes:rsync.Rsync is calculated by the diff of itself Method, synchronous is update part, can't be all copied over All Files, synchronizing speed is especially fast.
The file synchronisation method that first embodiment of the invention provides realizes information transfer channel using public and private key verification mode Connected without password, recycle synchronization means by information transfer channel by the update file synchronization in server to synchronous service Device need not add configuration file when carrying out file synchronization, solve in the prior art when using daemon patterns into style of writing Cumbersome problem is configured when part synchronization, while password need not be manually entered can to establish between server and sync server Information transfer channel.
According to the second embodiment of the present invention, a kind of file synchronisation method is provided, server is applied to.Fig. 2 is this hair The flow diagram of file synchronisation method in bright second embodiment, as shown in Fig. 2, the file synchronization side of second embodiment of the invention Method includes the following steps:
S201:Server generates public, private key key pair, and public key is added to specified sync server.
S202:Server establishes the server and institute according to the procotol of setting in the way of the verification of public and private key State the information transfer channel between sync server.
S203:Using preset synchronization means, by described information transmission channel by the update file in the server It is synchronized to the sync server.
S204:Synchronized result of the update file in the sync server is obtained, when the synchronized result is same When walking failed, by described information transmission channel by the update file retransmission to the sync server.
Described retransmit includes retransmitting and delaying at once re-transmission.Wherein, it retransmits at once and refers to that when synchronized result be to synchronize not When success, file retransmission will be updated at once to the sync server;Delay re-transmission refer to when synchronized result be it is synchronous not at When work(, file retransmission will be updated again to the sync server after waiting for preset time (such as 10 minutes).
It optionally, in embodiments of the present invention, will more by information transfer channel when synchronized result is to synchronize failed New file is retransmitted to the sync server at once;When synchronized result is to synchronize successfully, determined according to sync server list Next sync server establishes the information transfer channel between the server and next sync server, style of writing of going forward side by side Part synchronizes.
It optionally, in embodiments of the present invention, will more by information transfer channel when synchronized result is to synchronize failed New file, which is delayed, is retransmitted to the sync server;When synchronized result is to synchronize successfully, determined according to sync server list Next sync server establishes the information transfer channel between the server and next sync server, style of writing of going forward side by side Part synchronizes.
It optionally, in embodiments of the present invention, will more by information transfer channel when synchronized result is to synchronize failed New file is retransmitted to the sync server at once, when it is to synchronize successfully to retransmit result at once, according to sync server list It determines next sync server, establishes the information transfer channel between the server and next sync server, go forward side by side Row file synchronization;When it is to synchronize failed to retransmit result at once, update file is delayed by information transfer channel and is retransmitted to The sync server determines next synchronous clothes when it is to synchronize successfully to delay re-transmission result according to sync server list Business device, establishes the information transfer channel between the server and next sync server, and carry out file synchronization.
Optionally, in embodiments of the present invention, by described information transmission channel by the update file retransmission to institute After stating sync server, further include:When retransmitting failed, address and the update text of the sync server are recorded Part, and fed back according to preset mode, repaired so as to relevant staff or manually retransmitted.Wherein, preset side Formula includes but not limited to for mail.
The file synchronisation method that second embodiment of the invention provides can not only utilize public and private key verification mode to realize that information passes Defeated channel is connected without password, can also utilize synchronization means by information transfer channel by the update file synchronization in server To sync server, solve the problems, such as to configure when carrying out file synchronization using daemon patterns in the prior art cumbersome;And And when there is file update in server, can will update file real-time synchronization to it is in need progress file synchronization it is specified It in sync server, is also based on and the monitoring of synchronized result is retransmitted, it is ensured that file synchronization success.
According to the third embodiment of the invention, a kind of file synchronisation method is provided, server is applied to.Fig. 3 is this hair The flow diagram of file synchronisation method in bright 3rd embodiment, as shown in figure 3, the file synchronization side of third embodiment of the invention Method includes the following steps:
S301:Server generates public, private key key pair, and public key is added to specified sync server.
S302:Server establishes the server and institute according to the procotol of setting in the way of the verification of public and private key State the information transfer channel between sync server.
S303:Using preset synchronization means, by described information transmission channel by the update file in the server It is synchronized to the sync server, while synchronous directory of the update file in the sync server being sent to described Sync server.
That is, the preset synchronization means of server by utilizing (such as rsync), by update file, update file same Synchronous directory in step server is sent to synchronous clothes simultaneously by the information transfer channel between server and sync server Business device.Exemplary, for rsync by the diff algorithms of itself, synchronous is update part, can't All Files it is all copied It goes, synchronizing speed is especially fast.As executed:rsync-avz-e ssh–delete–exclude excFile srcPath user@ dest_ip:Rsync_dir/, wherein srcPath is transmitting terminal file directory (updating file), and dest_ip takes for receiving terminal Business device ip, user are login account, and rsync_dir is that file synchronization catalogue (updates synchronization of the file in sync server Catalogue), delete is indicated if transmitting terminal has deletion file, receiving terminal also to delete, and exclude excFile indicate not same Past file or catalogue are walked, such as .git catalogues are filtered out.
The file synchronisation method that third embodiment of the invention provides can not only utilize public and private key verification mode to realize that information passes Defeated channel is connected without password, using synchronization means by information transfer channel by the update file synchronization in server to synchronization Server solves the problems, such as to configure when carrying out file synchronization using daemon patterns in the prior art cumbersome;And it can be with Synchronous directory of the file in sync server will be updated in information transfer channel is sent to the sync server, that is, It says, synchronous directory need not be configured in configuration file, and modification is more flexible.
According to the fourth embodiment of the invention, a kind of file synchronisation method is provided, server is applied to.Fig. 4 is this hair The flow diagram of file synchronisation method in bright fourth embodiment, as shown in figure 4, the file synchronization side of fourth embodiment of the invention Method includes the following steps:
S401:Server generates public, private key key pair, and public key is added to specified sync server.
S402:The sync server is received using the data after the public key encryption, utilizes the public, private key key The private key of centering is sent to the sync server to the data deciphering, and by the data after decryption.
Optionally, in embodiments of the present invention, the data after receiving the sync server using the public key encryption Before, further include:Encrypted instruction is sent to the sync server, to indicate that the sync server utilizes preset data The public key is encrypted.
S403:After receiving the link order that the sync server is sent, establish the server with it is described synchronous Information transfer channel between server.
S404:Using preset synchronization means, by described information transmission channel by the update file in the server It is synchronized to the sync server.
The file synchronisation method that fourth embodiment of the invention provides realizes that information is transmitted in the way of public and private key encryption and decryption Channel is connected without password, at the same using synchronization means by information transfer channel by the update file synchronization in server to same Walk server, solve the problems, such as in the prior art when using daemon patterns carry out file synchronization when configure it is cumbersome, while this The technical solution of invention, which need not be manually entered password, can establish information transfer channel between server and sync server.
The fifth embodiment of the present invention provides a kind of file synchronizer, is applied to server.Fig. 5 is the present invention the The structural schematic diagram of file synchronizer in five embodiments, as described in Figure 5, the file synchronizer packet of fifth embodiment of the invention It includes public, private key key pair and generates processing module 50, information transfer channel and establish module 52 and file synchronization module 54, it is right below Each module is described in detail.
The public, private key key pair generates processing module 50, is added for generating public, private key key pair, and by public key To specified sync server.
Described information transmission channel establishes module 52, for the procotol according to setting, the side verified using public and private key Formula establishes the information transfer channel between the server and the sync server.
As a kind of specific implementation mode, the procotol includes ssh.
As a kind of specific implementation mode, described information transmission channel is established module 52 and is specifically used for:
The sync server is received using the data after the public key encryption, utilizes the public, private key cipher key pair Private key is sent to the sync server to the data deciphering, and by the data after decryption;
After receiving the link order that the sync server is sent, the server and the sync server are established Between information transfer channel.
The file synchronization module 54 will be described by described information transmission channel for utilizing preset synchronization means Update file synchronization in server is to the sync server.
Optionally, the file synchronization module 54 is additionally operable to:The update file is same in the sync server Step catalogue is sent to the sync server, and synchronization of the file in sync server can will be updated in information transfer channel Catalogue is sent to the sync server, that is to say, that synchronous directory need not be configured in configuration file, and modification is more Flexibly.
As a kind of specific implementation mode, the synchronization means includes rsync.
Optionally, the file synchronizer described in fifth embodiment of the invention further includes synchronized result acquisition module:It is described Synchronized result acquisition module, for obtaining synchronized result of the update file in the sync server;The file is same Module is walked, for when the synchronized result is to synchronize failed, by described information transmission channel by the update file weight Reach the sync server, technical scheme of the present invention can be based on retransmitting the monitoring of synchronized result, it is ensured that file Synchronize success.
Described retransmit includes retransmitting and delaying at once re-transmission.Wherein retransmit at once refer to when synchronized result be it is synchronous not at When work(, file retransmission will be updated at once to the sync server;It delays re-transmission and refers to that when synchronized result be to synchronize not successfully When, file retransmission will be updated again to the sync server after waiting for preset time (such as 10 minutes).
Optionally, the file synchronizer described in fifth embodiment of the invention further includes feedback module:The feedback module, Address for when retransmitting failed, recording the sync server and update file, and carried out instead according to preset mode Feedback is repaired so as to relevant staff or is manually retransmitted.
The file synchronizer that fifth embodiment of the invention provides realizes information transfer channel using public and private key verification mode Connected without password, recycle synchronization means by information transfer channel by the update file synchronization in server to synchronous service Device, solve the problems, such as in the prior art when using daemon patterns carry out file synchronization when configure it is cumbersome, while the present invention Technical solution, which need not be manually entered password, can establish information transfer channel between server and sync server.
Sixth embodiment of the invention provides a kind of file synchronization equipment.Fig. 6 is that file is same in sixth embodiment of the invention The structural schematic diagram for walking equipment, as shown in fig. 6, file synchronization equipment includes:Memory 62, processor 64 and it is stored in described deposit On reservoir 62 and the computer program that can be run on the processor 64, when the computer program is executed by the processor Realize following steps:Server generates public, private key key pair, and public key is added to specified sync server;Server is pressed According to the procotol of setting the letter between the server and the sync server is established in the way of the verification of public and private key Cease transmission channel;
Using preset synchronization means, by described information transmission channel by the update file synchronization in the server extremely The sync server.More specifical realization method is as described in first embodiment to fourth embodiment, and details are not described herein.
Seventh embodiment of the invention additionally provides a kind of computer readable storage medium, and meter is stored on the storage medium Calculation machine program, the computer program realize following steps when being executed by processor:Server generates public, private key key pair, and Public key is added to specified sync server;Server is built according to the procotol of setting in the way of the verification of public and private key Vertical information transfer channel between the server and the sync server;Using preset synchronization means, pass through the letter Transmission channel is ceased by the update file synchronization in the server to the sync server.More specifical realization method such as the Described in one embodiment to fourth embodiment, details are not described herein.Wherein, computer readable storage medium includes but not limited to be: ROM, RAM, disk or CD etc..
Illustrate the embodiment of the present invention in order to more detailed, provide example 1, Fig. 7 is file in example of the embodiment of the present invention 1 The flow diagram of synchronous method, as shown in fig. 7, example 1 includes the following steps:
1, server (such as server A) generates ssh public, private keys key pair (being known as public private key pair in the figure 7), order Row ssh-keygen, such as ssh-keygen-t rsa-C " ssh description "-f~/.ssh/libSync_rsa, LibSync_rsa is specified public and private key name, in order to avoid with the public and private key name conflicts of existing ssh, can be generated under~/.ssh catalogues Two file of public key libSync_rsa.pub and private key libSync_rsa.
2, the public key of generation is added to all sync servers (such as server B, server C and server D), executed Ssh-copy-id is ordered, public key file is specified, such as ssh-copy-id-i~/.ssh/libSync_rsa.pub user@ Dest_ip is added if it is first time, and an authorized_keys file can be generated in sync server, and content is public affairs Otherwise key file content is to be appended to authorized_keys files.
3, ssh private keys are added to local (i.e. server A), order ssh-add are executed, such as ssh-add~/.ssh/ libSync_rsa。
If 4, server A has file update, triggering file synchronization operation to execute 5.
5, according to server list (i.e. sync server list, such as ip lists) successively to all sync servers (in reality Server B, server C and server D are referred in example 1) carry out file synchronization.Such as when to server B progress file synchronization When, execute order rsync, at this moment rsync directly walk the channels ssh (i.e. server A by public and private key verify in the way of the clothes established The information transfer channel being engaged between device A and server B), the login password that need not input server B executes file synchronization behaviour Make, for rsync by the diff algorithms of itself, synchronous is update part, can't All Files be all copied over, synchronizing speed It is especially fast.As executed:rsync-avz-e ssh–delete–exclude excFile srcPath user@dest_ip: Rsync_dir/, wherein srcPath is transmitting terminal file directory, and dest_ip is receiving terminal server ip, and user is to log in account Number, rsync_dir is file synchronization catalogue, and delete is indicated if transmitting terminal has deletion file, receiving terminal also to delete, Exclude excFile expressions are not synchronized past file or catalogue, and such as .git catalogues are filtered out.
6, rsync synchronized results are monitored, $ is obtained?Value, such as ret=$?, 0 is successfully returned, is unsuccessfully non-zero.If it is successful, Continue rsync and be synchronized to the next sync server (i.e. server C) determined according to server list, executes 5;Otherwise it executes It once retransmits at once and (is known as re-synchronization in the figure 7).
7, it monitors and is retransmitted at once as a result, if it is successful, executing 5;Otherwise, it reattempts and primary delay re-transmission and (be known as in the figure 7 Delay synchronization), such as execute the synchronization to current sync server again after ten minutes.
8, it such as delays and retransmits successfully, execute 5;Otherwise, server and file directory information are recorded, it is possible to only need same again Walk partial list.
9, summarize synchronization failure information, send out mail notification related personnel, the same the end of the step of server itself, related personnel carries out Technical reparation executes the synchronizing information of failure one time again.
In embodiment provided by the present invention, it should be understood that disclosed device and method, it can also be by other Mode realize.The apparatus embodiments described above are merely exemplary, for example, the flow chart and block diagram in attached drawing are shown The device of multiple embodiments according to the present invention, the architectural framework in the cards of method and computer program product, function And operation.In this regard, each box in flowchart or block diagram can represent one of a module, section or code Point, a part for the module, section or code includes one or more for implementing the specified logical function executable Instruction.It should also be noted that at some as in the realization method replaced, the function of being marked in box can also be attached to be different from The sequence marked in figure occurs.For example, two continuous boxes can essentially be basically executed in parallel, they also may be used sometimes To execute in the opposite order, this is depended on the functions involved.It is also noted that each of block diagram and or flow chart The combination of box in box and block diagram and or flow chart, function or the dedicated of action are based on as defined in execution The system of hardware is realized, or can be realized using a combination of dedicated hardware and computer instructions.
In addition, each function module in each embodiment of the present invention can integrate to form an independent portion Point, can also be modules individualism, can also two or more modules be integrated to form an independent part.
In short, the foregoing is merely illustrative of the preferred embodiments of the present invention, it is not intended to limit the scope of the present invention. All within the spirits and principles of the present invention, any modification, equivalent replacement, improvement and so on should be included in the present invention's Within protection domain.

Claims (14)

1. a kind of file synchronisation method, which is characterized in that the method includes:
Server generates public, private key key pair, and public key is added to specified sync server;
Server establishes the server and the synchronous clothes according to the procotol of setting in the way of the verification of public and private key Information transfer channel between business device;
Using preset synchronization means, by described information transmission channel by the update file synchronization in the server to described Sync server.
2. the method as described in claim 1, which is characterized in that by public and private key verification in the way of, establish the server with Information transfer channel between the sync server, including:
The sync server is received using the data after the public key encryption, utilizes the private key of the public, private key cipher key pair It is sent to the sync server to the data deciphering, and by the data after decryption;
After receiving the link order that the sync server is sent, establish between the server and the sync server Information transfer channel.
3. the method as described in claim 1, which is characterized in that will be in the server by described information transmission channel After updating file synchronization to the sync server, further include:
Obtain synchronized result of the update file in the sync server;
When the synchronized result is to synchronize failed, by described information transmission channel by the update file retransmission to described Sync server.
4. method as claimed in claim 3, which is characterized in that by described information transmission channel by the update file weight After reaching the sync server, further include:
When retransmitting failed, record the address of the sync server and the update file, and according to preset mode into Row feedback.
5. the method as described in claim 1, which is characterized in that will be in the server by described information transmission channel When updating file synchronization to the sync server, further include:By synchronization of the update file in the sync server Catalogue is sent to the sync server.
6. such as Claims 1 to 5 any one of them method, which is characterized in that the procotol includes:ssh;And/or institute Stating synchronization means includes:rsync.
7. a kind of file synchronizer, which is characterized in that described device includes that public, private key key pair generates processing module, information Transmission channel establishes module and file synchronization module:
The public, private key key pair generates processing module, for generating public, private key key pair, and public key is added to specified Sync server;
Described information transmission channel establishes module, is established in the way of the verification of public and private key for the procotol according to setting Information transfer channel between the server and the sync server;
The file synchronization module, for utilizing preset synchronization means, by described information transmission channel by the server In update file synchronization to the sync server.
8. device as claimed in claim 7, which is characterized in that described information transmission channel is established module and is specifically used for:
The sync server is received using the data after the public key encryption, utilizes the private key of the public, private key cipher key pair It is sent to the sync server to the data deciphering, and by the data after decryption;
After receiving the link order that the sync server is sent, establish between the server and the sync server Information transfer channel.
9. device as claimed in claim 7, which is characterized in that further include synchronized result acquisition module:
The synchronized result acquisition module, for obtaining synchronized result of the update file in the sync server;
The file synchronization module will by described information transmission channel when for synchronizing failed when the synchronized result The update file retransmission is to the sync server.
10. device as claimed in claim 9, which is characterized in that further include feedback module:
The feedback module, for when retransmitting failed, recording the address of the sync server and the update file, and It is fed back according to preset mode.
11. device as claimed in claim 7, which is characterized in that the file synchronization module is additionally operable to:By the update file Synchronous directory in the sync server is sent to the sync server.
12. such as claim 7~11 any one of them device, which is characterized in that the procotol includes:ssh;And/or The synchronization means includes:rsync.
13. a kind of file synchronization equipment, which is characterized in that the file synchronization equipment includes:It memory, processor and is stored in On the memory and the computer program that can run on the processor, the computer program are executed by the processor The step of Shi Shixian such as claim 1~6 any one of them file synchronisation methods.
14. a kind of computer readable storage medium, which is characterized in that computer program is stored on the storage medium, it is described It is realized when computer program is executed by processor as described in any one of claim 1~6 the step of file synchronisation method.
CN201810843164.9A 2018-07-27 2018-07-27 File synchronization method, device, equipment and computer readable storage medium Active CN108810173B (en)

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 true CN108810173A (en) 2018-11-13
CN108810173B 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 (6)

* Cited by examiner, † Cited by third party
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
US20160055167A1 (en) * 2008-03-13 2016-02-25 Blue Coat Systems, Inc. Composite Execution of Rename Operations in Wide Area File Systems
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160055167A1 (en) * 2008-03-13 2016-02-25 Blue Coat Systems, Inc. Composite Execution of Rename Operations in Wide Area File Systems
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
CN108810173B (en) 2022-02-25

Similar Documents

Publication Publication Date Title
US9430655B1 (en) Split tokenization
US11343081B2 (en) Synchronizable hardware security module
CN107888562A (en) Interconnect serobila architecture
EP2405621A1 (en) A method of time synchronization communication
US6643773B1 (en) Apparatus and method for authenticating messages in a multicast
CN111339199B (en) Block chain key recovery method and device
CN116601912A (en) Post-secret provisioning service providing encryption security
US10887294B2 (en) Synchronizable hardware security module
CN110740038B (en) Blockchain and communication method, gateway, communication system and storage medium thereof
US20200099672A1 (en) Mechanism for encryption key distribution in computer networks
CN113841359A (en) Method and apparatus for propagating tiles in a blockchain network
CN111241593A (en) Data synchronization method and device for block chain nodes
US20180053009A1 (en) Method for secure data management in a computer network
CN106330465A (en) Processing method, server and system for distributed timestamp
WO2022179304A1 (en) Secure communication method, apparatus, and system for dc interconnection
CN112507019A (en) PBFT consensus system and method based on intelligent contracts
CN111246396B (en) Complete machine burning method and system based on UDP local area network
CN109165199A (en) A kind of file synchronisation method, device, equipment and computer readable storage medium
US20230162186A1 (en) Block propagation with poisoned transactions in a blockchain network
CN112131041A (en) Method, apparatus and computer program product for managing data placement
CN104168110B (en) A kind of method of symmetric key online updating
CN108134777B (en) Communication encryption system based on timestamp
CN110943996B (en) Management method, device and system for business encryption and decryption
CN108810173A (en) A kind of file synchronisation method, device, equipment and computer readable storage medium
CN115987660A (en) VPN device communication method, device and storage medium

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