henesyinit from lsubb0c8bdb6 years agoHistory
229 lines · 6.4 KB · Text
RawDownload
.TH REPL 8.SH NAMEprune, scandb, syncdb \- peer to peer replica management.SH SYNOPSIS.B repl/prune.IR repl ....br.B repl/scandb[.B -tv][.B -p.I nb][.B -n.I id][.B -r.I replid][.B -i.I excldir].I dir.I db.br.B repl/syncdb[.B -12lnrv].I dir1.I dir2.I db1.I db2[.IR dir ...].SH DESCRIPTIONThese programs implement a peer-to-peer replica management systemfor file trees. Each peer is called a replica and holds both thereplicated file tree and a data base. The data base containsa textual representation of the file tree together with the historyof updates for each file as described below.Any number of replicas can be defined andany pair can be synchronized at any time. There is no centralizedserver nor there is a synchronization order required to detectconflicts..PPReplication is done using causal histories as defined by Lamport.Each file entry in the data base holdsa history of change events.When a replica creates, changes, or deletesa file, a change event is addedto the file's history. A change event is a single characterthat identifies the replica that did the change. The character islower case for creation, data changes, and metadata changes. Thecharacter is upper case for deletion events..PPTo synchronize a file between two replicas, their histories forthe file are compared. The file is consideredup to date if the histories are equal. If one of them is a prefix of theother, it is considered out of date with respect to the other. In thiscase the file and its history are updated in the other replica. If thehistories differ, but no one is a prefix of the other, there wasa concurrent update and a conflict is reported..PP.I Scandbis used to scan the file tree at.I dirfor changes. It builds a new data base that corresponds to thetree in disk and compares it with.IR db .The program prunes from the scan process any directory not modifiedsince the last scan performed. Flag.B -tdisables such prunning and is intended for use in file systemsthat do not propagate modification times from the changed fileup to the root directory of the file system..PPThe history for a file in the new data base is that found in.I dbperhaps followed by a change event (when the file has changed)..PPOption.B -ncan be used when there is no.I dbfile. This happens when defining a new replica.The option argument is the name for the replica and must be a lowercase letter. The change histories in the new data basewill contain a single event (a change in the replica being defined)..PPOption.B -rcan be used to define a new replica with name.I replidwhile creating an initial data base for name.IR id .This is useful to build a data base for an already updatedreplica that has been copied by other means. See the example below..PPFlag.B -vmakes the program verbose. It will report any change event noticed..PPTo ignore a directory give its name to option.B -iusing an relative path name starting at the replica directory.The directory contents will be ignored. The option can be usedmultiple times to ignore multiple directories. Be careful togive the.B sameignore arguments to all the replicas..PPTo prune the history, you can use.B -pand pass the identifier (a number) for the prune event. Such identifiermust be used at all the replicas. See the discussion below..PP.I Syncdbis used to synchronize replicas. Its arguments are the twodirectories and data bases for the replicas being synchronized..I Syncdboperates as said above to detect updates and conflicts. It copies,creates, and deletes files to bring both replicas to a synchronizedstate. If any.I diris supplied, relative to the top-dir of a replica, synchronization applies only to it..PPFlag.B -vmakes the program report any change made. Flag.B -nperforms a dry run to report changes between both replicaswithout synchronizing them.The flag.B -lcan be used to syncrhonize just the left replica (in command lineorder) with respect to the other. Flag.B -rdoes the same for the right replica..PPFlags.B -1and.B -2can be used to resolve conflicts in favor of the first replica (the left one)and in favor of the second one (the right one).When there are different conflicts to be gained by different replicas,one replica can be updated by hand, and then used as the prefered tosettle down all the conflicts..PPTo prune file histories follow this procedure..IP 1Be sure that all the peers are synchronized..IP 2Use.I pruneto prune all the peers. You can pass the names for all the.I replconfiguration files..LPThis program calls.I scandbfor each replica using the.B -pflag. The effect isto remove all but the last event in the histories for files within the database.Any other procedure would be very costly or complex,because it would require finding the maximum common prefix for eachhistory and removing it from all the replicas..PPDatabase files are exclusive-open text files that contain the replicaidentifier in the first line, followed by one line per file entry.Each entry contains the file name, the update history,the user and group identifers, file permissions (8 hex digits),modificationtime (8 hex digits), file length (decimal), and Qid version. The file namestarts with '/' and is relativeto the top directory of the replicated file tree. All fields are separatedby space. Entries for deleted files have their history terminated on uppercase..SH EXAMPLEThis defines for the system file tree, excluding.B /usrand.BR /dist ,a replica called.BR a .The same is done for.B /usr/nemoexcluding the directory.B /usr/nemo/distand.BR /usr/nemo/tmp ..EX	; repl/scandb -n a -i usr -i dist /root /dist/sys.db	; repl/scandb -n a -i tmp -i dist $home $home/dist/home.db .EE.LP.LPNow we can replicate both the system and.B /usr/nemointo a new laptop by defining two replicas,named.BR b ,and synchronizing them..EX	# at the laptop, booted from the network.	; mount -c /dev/sdC0/fossil /n/fossil	; repl/scandb -n b /n/fossil /dist/nautilus.db	; replica/syncdb /root /fossil /dist/sys.db /dist/nautilus.db	; mkdir /fossil/$home /fossil/$home/dist	; repl/scandb -n b -i tmp -i dist /fossil/$home $home/dist/laptop.db	; replica/syncdb (/ /fossil)^$home $home/dist/^(home.db laptop.db) .EE.SH SOURCE.B /sys/src/cmd/repl.SH SEE ALSO.IR repl (1),.IR replica (1)..SH BUGSAppend only files are not synchronized to prevent duplicationof file contents.