replica 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. .TH REPLICA 1
  2. .SH NAME
  3. changes, pull, push, scan \- client-server replica management
  4. .SH SYNOPSIS
  5. .B replica/pull
  6. [
  7. .B -cnsv
  8. ]
  9. .I name
  10. [
  11. .I path
  12. ...
  13. ]
  14. .br
  15. .B replica/push
  16. [
  17. .B -nv
  18. ]
  19. .I name
  20. [
  21. .I path
  22. ...
  23. ]
  24. .br
  25. .B replica/changes
  26. .I name
  27. [
  28. .I path
  29. ...
  30. ]
  31. .br
  32. .B replica/scan
  33. .I name
  34. [
  35. .I path
  36. ...
  37. ]
  38. .SH DESCRIPTION
  39. These shell scripts provide a simple log-based client-server replica management.
  40. The server keeps a log of changes made to its file system,
  41. and clients synchronize by reading the log and applying these changes locally.
  42. .PP
  43. These scripts are a polished interface to the low-level tools described in
  44. .IR replica (8).
  45. See
  46. .IR replica (8)
  47. for details on the inner workings of replica management.
  48. These tools were written primarily as the fourth
  49. edition Plan 9 distribution mechanism, but they
  50. have wider applicability.
  51. For example, they could be used to synchronize one's
  52. home directory between a laptop and a central file server.
  53. .PP
  54. Replicas are described by configuration files.
  55. The
  56. .I name
  57. in all the replica commands is a configuration
  58. file. Paths that do not begin with
  59. .BR / ,
  60. .BR ./ ,
  61. or
  62. .B ../
  63. are assumed to be relative to
  64. .BR $home/lib/replica .
  65. Configuration files are described below.
  66. .PP
  67. .I Replica/scan
  68. is the only one of these programs that does not
  69. need to be run on the client.
  70. It scans the server file system for changes
  71. and appends entries for those changes into the server log.
  72. Typically it is run on a machine with a fast network
  73. connection to the server file system.
  74. .PP
  75. .I Replica/pull
  76. copies changes from the server to the client,
  77. while
  78. .I replica/push
  79. copies changes from the client to the server.
  80. (Both run on the client.)
  81. If a list of
  82. .I paths
  83. is given, only changes to those paths or their children are copied.
  84. The
  85. .B -v
  86. flag causes
  87. .I pull
  88. or
  89. .I push
  90. to print a summary of what it is doing.
  91. Each status line is of the form
  92. .ift .sp 0.5
  93. .ifn .sp
  94. \h'0.25i'
  95. .I verb
  96. .I path
  97. .I serverpath
  98. .I mode
  99. .I uid
  100. .I gid
  101. .I mtime
  102. .I length
  103. .ift .sp 0.5
  104. .ifn .sp
  105. .I Verb
  106. describes the event:
  107. addition of a file
  108. .RB ( a ),
  109. deletion of a file
  110. .RB ( d ),
  111. a change to a file's contents
  112. .RB ( c ),
  113. or a change to a file's metadata
  114. .RB ( m ).
  115. .I Path
  116. is the file path on the client;
  117. .I serverpath
  118. is the file path on the server.
  119. .IR Mode ,
  120. .IR uid ,
  121. .IR gid ,
  122. and
  123. .I mtime
  124. are the file's metadata as in the
  125. .B Dir
  126. structure (see
  127. .IR stat (5)).
  128. For deletion events, the metadata is that of the deleted file.
  129. For other events, the metadata is that after the event.
  130. The
  131. .B -n
  132. flag causes
  133. .I pull
  134. or
  135. .I push
  136. to print the summary but not actually carry out the actions.
  137. .PP
  138. .I Push
  139. and
  140. .I pull
  141. are careful to notice simultaneous changes to a file or
  142. its metadata on both client and server.
  143. Such simultaneous changes are called
  144. .IR conflicts .
  145. Here, simultaneous does not mean at the same instant
  146. but merely that both changes were carried out without knowledge
  147. of the other.
  148. For example, if a client and server both make changes to a file
  149. without an intervening
  150. .I push
  151. or
  152. .IR pull ,
  153. the next
  154. .I push
  155. or
  156. .I pull
  157. will report an update/update conflict.
  158. If a conflict is detected, both files are left the same.
  159. The
  160. .B -c
  161. flag to
  162. .I pull
  163. causes updates to be resolved using the client's copy,
  164. while
  165. .B -s
  166. specifies the server's copy.
  167. Typically these flags are only used when
  168. invoking
  169. .I pull
  170. with a specific list of files that are known
  171. to be conflicting.
  172. .PP
  173. .I Replica/changes
  174. prints a list of local changes made on the client
  175. that have not yet been pushed to the server.
  176. It is like
  177. .I push
  178. with the
  179. .B -n
  180. flag, except that it does not check for conflicts
  181. and thus does not require the server to be available.
  182. .PP
  183. The replica configuration file is an
  184. .IR rc (1)
  185. script that must define the following functions and variables:
  186. .TP
  187. .B servermount
  188. A function that mounts the server; run on both client and server.
  189. .TP
  190. .B serverupdate
  191. A function that rescans the server for changes.
  192. Typically this command dials a CPU server known
  193. to be close to the file server and runs
  194. .I replica/scan
  195. on that well-connected machine.
  196. .TP
  197. .B serverroot
  198. The path to the root of the replicated file
  199. system on the server, as it will be in the name space
  200. after running
  201. .BR servermount .
  202. .TP
  203. .B serverlog
  204. The path to the server's change log, after running
  205. .BR servermount .
  206. .TP
  207. .B serverproto
  208. The path to the proto file describing the server's files,
  209. after running
  210. .BR servermount .
  211. Only used by
  212. .IR scan .
  213. .TP
  214. .B serverdb
  215. The path to the server's file database, after running
  216. .BR servermount .
  217. Only used by
  218. .IR scan .
  219. .TP
  220. .B clientmount
  221. A function to mount the client file system; run only on the client.
  222. .TP
  223. .B clientroot
  224. The path to the root of the replicated file system on the client,
  225. after running
  226. .BR clientmount .
  227. .TP
  228. .B clientlog
  229. The path to the client's copy of the server log file.
  230. The client log is maintained by
  231. .IR pull .
  232. .TP
  233. .B clientproto
  234. The path to the proto file describing the client's files.
  235. Only used by
  236. .IR changes .
  237. Often just a copy of
  238. .BR $serverproto .
  239. .TP
  240. .B clientdb
  241. The path to the client's file database, after running
  242. .BR clientmount .
  243. .TP
  244. .B clientexclude
  245. A (potentially empty) list of paths to exclude from
  246. synchronization. A typical use of this is to exclude
  247. the client database and log files.
  248. These paths are relative to the root of the replicated file system.
  249. .PD
  250. .PP
  251. As an example, the Plan 9 distribution replica configuration looks like:
  252. .EX
  253. fn servermount { 9fs sources; bind /n/sources/plan9 /n/dist }
  254. fn serverupdate { status='' }
  255. serverroot=/n/dist
  256. s=/n/dist/dist/replica
  257. serverlog=$s/plan9.log
  258. serverproto=$s/plan9.proto
  259. fn clientmount { 9fs kfs }
  260. clientroot=/n/kfs
  261. c=/n/kfs/dist/replica
  262. clientlog=$c/client/plan9.log
  263. clientproto=$c/plan9.proto
  264. clientdb=$c/client/plan9.db
  265. clientexclude=(dist/replica/client)
  266. .EE
  267. .PP
  268. (Since the Plan 9 developers run
  269. .I scan
  270. manually to update the log, the clients need not do anything
  271. to rescan the file system.
  272. Thus
  273. .B serverupdate
  274. simply returns successfully.)
  275. .PP
  276. The fourth edition Plan 9 distribution uses these
  277. tools to synchronize installations with the central
  278. server at Bell Labs.
  279. The replica configuration files and metadata are kept
  280. in
  281. .BR /dist/replica .
  282. To update your system, make sure you are connected
  283. to the internet and run
  284. .EX
  285. disk/kfscmd allow
  286. replica/pull /dist/replica/network
  287. disk/kfscmd disallow
  288. .EE
  289. .PP
  290. To see a list of changes made to the local file system
  291. since installation, run
  292. .EX
  293. replica/changes /dist/replica/network
  294. .EE
  295. (Although the script is called
  296. .IR network ,
  297. since
  298. .I changes
  299. is a local-only operation, the network need not be configured.)
  300. .SH SOURCE
  301. .B /rc/bin/replica
  302. .SH SEE ALSO
  303. .IR replica (8)