NAME
|
prune, scandb, syncdb – peer to peer replica management |
SYNOPSIS
|
repl/prune repl... repl/scandb [ –tv ] [ –p nb ] [ –n id ] [ –r replid ] [ –i excldir ] dir db repl/syncdb [ –12lnrv ] dir1 dir2 db1 db2 [ dir... ] |
DESCRIPTION
|
These programs implement a peer–to–peer replica management system
for file trees. Each peer is called a replica and holds both the
replicated file tree and a data base. The data base contains a
textual representation of the file tree together with the history
of updates for each file as described below. Any number of
replicas can be defined and any pair can be synchronized at any
time. There is no centralized server nor there is a synchronization
order required to detect conflicts. Replication is done using causal histories as defined by Lamport. Each file entry in the data base holds a history of change events. When a replica creates, changes, or deletes a file, a change event is added to the file's history. A change event is a single character that identifies the replica that did the change. The character is lower case for creation, data changes, and metadata changes. The character is upper case for deletion events. To synchronize a file between two replicas, their histories for the file are compared. The file is considered up to date if the histories are equal. If one of them is a prefix of the other, it is considered out of date with respect to the other. In this case the file and its history are updated in the other replica. If the histories differ, but no one is a prefix of the other, there was a concurrent update and a conflict is reported. Scandb is used to scan the file tree at dir for changes. It builds a new data base that corresponds to the tree in disk and compares it with db. The program prunes from the scan process any directory not modified since the last scan performed. Flag –t disables such prunning and is intended for use in file systems that do not propagate modification times from the changed file up to the root directory of the file system. The history for a file in the new data base is that found in db perhaps followed by a change event (when the file has changed). Option –n can be used when there is no db file. This happens when defining a new replica. The option argument is the name for the replica and must be a lower case letter. The change histories in the new data base will contain a single event (a change in the replica being defined). Option –r can be used to define a new replica with name replid by stealing a data base for a replica with name id. This is useful to build a data base for an already updated replica that has been copied by other means. After the old replica files (and database) have been copied, option –r would rename the (copied) database to pretend it belongs to a new replica. Flag –v makes the program verbose. It will report any change event noticed. To ignore a directory give its name to option –i using an relative path name starting at the replica directory. The directory contents will be ignored. The option can be used multiple times to ignore multiple directories. Be careful to give the same ignore arguments to all the replicas. To prune the history, you can use –p and pass the identifier (a number) for the prune event. Such identifier must be used at all the replicas. See the discussion below. Syncdb is used to synchronize replicas. Its arguments are the two directories and data bases for the replicas being synchronized. Syncdb operates as said above to detect updates and conflicts. It copies, creates, and deletes files to bring both replicas to a synchronized state. If any dir is supplied, relative to the top–dir of a replica, synchronization applies only to it. Flag –v makes the program report any change made. Flag –n performs a dry run to report changes between both replicas without synchronizing them. The flag –l can be used to syncrhonize just the left replica (in command line order) with respect to the other. Flag –r does the same for the right replica. Flags –1 and –2 can 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 to settle down all the conflicts.
To prune file histories follow this procedure. This program calls scandb for each replica using the –p flag. The effect is to 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 each history and removing it from all the replicas.
Database files are exclusive–open text files that contain the replica
identifier 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), modification
time (8 hex digits), file length (decimal), and Qid version. The
file name starts with '/' and is relative to the top directory
of the replicated file tree. All fields are separated by space.
Entries for deleted files have their history terminated on uppercase. |
EXAMPLE
This defines for the system file tree, excluding /usr and /dist,
a replica called a. The same is done for /usr/nemo excluding the
directory /usr/nemo/dist and /usr/nemo/tmp.
|
SOURCE
|
/sys/src/cmd/repl |
SEE ALSO
|
repl(1), replica(1). |
BUGS
|
Append only files are not synchronized to prevent duplication
of file contents. |