clsync.1 19 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. .\" Sorry for my English
  2. .\" --Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
  3. .\"
  4. .\" Thanks to oldlaptop [https://github.com/oldlaptop] for help with spelling
  5. .\"
  6. .TH CLSYNC 1 "JULY 2013" Linux "User Manuals"
  7. .SH NAME
  8. clsync \- live sync tool, written in GNU C
  9. .SH SYNOPSIS
  10. .B clsync [ options ]
  11. .I watch\-dir
  12. .I sync\-handler
  13. .B [
  14. .I rules\-file
  15. .B ]
  16. .B [
  17. .I dest-dir
  18. .B ]
  19. .SH DESCRIPTION
  20. .B clsync
  21. executes
  22. .I sync\-handler
  23. with appropriate arguments on FS events in directory
  24. .I watch\-dir
  25. using the
  26. .BR inotify (7)
  27. Linux kernel subsystem.
  28. Extended regex\-rules to filter what files and
  29. directories to sync may be placed in
  30. .I rules\-file
  31. .SH OPTIONS
  32. .B \-b, \-\-background
  33. .RS 8
  34. Daemonize, forcing clsync to fork() on start.
  35. .PP
  36. .RE
  37. .B \-H, \-\-config\-file
  38. .I config\-file\-path
  39. .RS 8
  40. Use configuration from file
  41. .IR config\-file\-path .
  42. (see
  43. .BR "CONFIGURATION FILE" )
  44. .PP
  45. .RE
  46. .B \-K, \-\-config\-block
  47. .I config\-block\-name
  48. .RS 8
  49. Use configuration block with name
  50. .IR config\-block\-name .
  51. (see
  52. .BR "CONFIGURATION FILE" )
  53. .PP
  54. .RE
  55. .B \-z, \-\-pid\-file
  56. .I path\-to\-pidfile
  57. .RS 8
  58. Writes pid to file by path
  59. .IR path\-to\-pidfile .
  60. .PP
  61. .RE
  62. .B \-u, \-\-uid
  63. .I uid
  64. .RS 8
  65. Drop user privileges to uid
  66. .I uid
  67. with
  68. .BR setuid (2)
  69. .PP
  70. .RE
  71. .B \-g, \-\-gid
  72. .I gid
  73. .RS 8
  74. Drop group privileges to gid
  75. .I gid
  76. with
  77. .BR setgid (2)
  78. .PP
  79. .RE
  80. .B \-p, \-\-pthread
  81. .RS 8
  82. Use
  83. .BR pthreads (7)
  84. to parallelize syncing processes.
  85. If you're running
  86. .B clsync
  87. with option
  88. .B \-\-pthread
  89. in conjunction with
  90. .B rsync
  91. with option
  92. .BR \-\-backup ,
  93. you may catch a bug due to nonatomicity of rsync's file replace operation.
  94. (see
  95. .BR DIAGNOSTICS )
  96. .RE
  97. .B \-Y, \-\-syslog
  98. .RS 8
  99. Use syslog instead of stderr for logging
  100. .RE
  101. .PP
  102. .B \-c, \-\-cluster\-iface
  103. .I interface\-ip
  104. .RS 8
  105. .B Not implemented, yet.
  106. .B DANGEROUS OPTION. This functionality wasn't tested well. You can lost your data.
  107. Enables inter-node notifing subsystem to prevent sync looping between nodes.
  108. This's very useful features that provides ability of birectional sync of the
  109. same directory between two or more nodes.
  110. .I interface-ip
  111. is an IP-address already assigned to the interface that will be used for
  112. multicast notifing.
  113. Not enabled by default.
  114. To find out the IP-address on interface "eth0", you can use for example next
  115. command:
  116. ip a s eth0 | awk '{if($1=="inet") {gsub("/.*", "", $2); print $2}}'
  117. .RE
  118. .PP
  119. .B \-m, \-\-cluster\-ip
  120. .I multicast\-ip
  121. .RS 8
  122. .B Not implemented yet.
  123. Sets IP-address for multicast group.
  124. This option can be used only in conjunction with
  125. .BR \-\-cluster\-interface .
  126. Use IP-addresses from 224.0.0.0/4 for this option.
  127. Default value is "227.108.115.121". [(128+"c")."l"."s"."y"]
  128. .RE
  129. .PP
  130. .B \-P, \-\-cluster\-port
  131. .I multicast\-port
  132. .RS 8
  133. .B Not implemented yet.
  134. Sets UDP-port number for multicast messages.
  135. This option can be used only in conjunction with
  136. .BR \-\-cluster\-interface .
  137. .I multicast\-port
  138. should be greater than 0 and less than 65535.
  139. Default value is "40079". [("n" << 8) + "c"]
  140. .RE
  141. .PP
  142. .B \-W, \-\-cluster\-timeout
  143. .I cluster\-timeout
  144. .RS 8
  145. .B Not implemented yet.
  146. Sets timeout (in milliseconds) of waiting answer from another nodes of the
  147. cluster. If there's no answer from some node, it will be excluded.
  148. Default value is "1000". [1 second]
  149. .RE
  150. .PP
  151. .B \-n, \-\-cluster\-node\-name
  152. .I cluster\-node\-name
  153. .RS 8
  154. .B Not implemented yet.
  155. Sets the name of current node in the cluster. It will be used in action
  156. scripts of another nodes (see
  157. .BR "SYNC HANDLER" ).
  158. Default value is $(uname \-n).
  159. .RE
  160. .PP
  161. .B \-o, \-\-cluster\-hash\-dl\-min
  162. .I hash\-dirlevel\-min
  163. .RS 8
  164. Sets minimal directory level for ctime hashing (see
  165. .BR CLUSTERING ).
  166. Default value is "1".
  167. .RE
  168. .PP
  169. .B \-O, \-\-cluster\-hash\-dl\-max
  170. .I hash\-dirlevel\-max
  171. .RS 8
  172. .B Not implemented yet.
  173. Sets maximal directory level for ctime hashing (see
  174. .BR CLUSTERING ).
  175. Default value is "16".
  176. .RE
  177. .PP
  178. .B \-O, \-\-cluster\-scan\-dl\-max
  179. .I scan\-dirlevel\-max
  180. .RS 8
  181. .B Not implemented yet.
  182. Sets maximal directory level for ctime scanning (see
  183. .BR CLUSTERING ).
  184. Default value is "32".
  185. .RE
  186. .PP
  187. .B \-k, \-\-timeout\-sync
  188. .I sync-timeout
  189. .RS 8
  190. Sets timeout for syncing processes.
  191. .B clsync
  192. will die if syncing process alive more than
  193. .I sync-timeout
  194. seconds.
  195. Set "0" to disable the timeout.
  196. Default value is "86400" ["24 hours"].
  197. .RE
  198. .PP
  199. .B \-w, \-\-delay\-sync
  200. .I additional\-delay
  201. .RS 8
  202. Sets the minimal delay (in seconds) between syncs.
  203. Default value is "30".
  204. .RE
  205. .PP
  206. .B \-t, \-\-delay\-collect
  207. .I ordinary\-delay
  208. .RS 8
  209. Sets the delay (in seconds) to collect events about ordinary files and
  210. directories.
  211. Default value is "30".
  212. .RE
  213. .PP
  214. .B \-T, \-\-delay\-collect\-bigfile
  215. .I bigfiles\-delay
  216. .RS 8
  217. Sets the delay (in seconds) to collect events about "big files" (see
  218. .IR \-\-threshold\-bigfile ).
  219. Default value is "1800".
  220. .RE
  221. .PP
  222. .B \-B, \-\-threshold\-bigfile
  223. .I filesize\-threshold
  224. .RS 8
  225. Sets file size threshold (in bytes) that separates ordinary files from
  226. "big files". Events about "big files" are processed in another queue with a
  227. separate collecting delay. This is supposed to be used as a means of unloading
  228. IO resources.
  229. Default value is "134217728" ["128 MiB"].
  230. .RE
  231. .PP
  232. .B \-d, \-\-dir\-lists
  233. .I tmpdir\-path
  234. .RS 8
  235. Sets directory path to output temporary events\-lists files.
  236. If this option is enabled,
  237. .B clsync
  238. will execute
  239. .I sync\-handler
  240. once for each aggregated event list, passing the path to a file containing
  241. this list (actions "synclist" and "rsynclist").
  242. Otherwise,
  243. .B clsync
  244. will execute
  245. .I sync\-handler
  246. for every file in the aggregated event list (action "sync").
  247. Cannot be used in conjunction with
  248. .IR \-\-synchandler\-so\-module
  249. .
  250. See
  251. .BR "SYNC HANDLER" .
  252. Is not set by default.
  253. .RE
  254. .PP
  255. .B \-S, \-\-initialsync\-enable
  256. .RS 8
  257. Use action "initialsync" instead of "synclist" for directories that were just marked (see
  258. .B "SYNC HANDLER"
  259. case
  260. .BR c ).
  261. Is not set by default.
  262. .RE
  263. .PP
  264. .B \-Z, \-\-synclist\-simplify
  265. .RS 8
  266. Removes the first 3 parameters in list files of action "synclist" (see
  267. .B "SYNC HANDLER"
  268. case
  269. .BR b ).
  270. Is not set by default.
  271. .RE
  272. .PP
  273. .B \-A, \-\-auto\-add\-rules\-w
  274. .RS 8
  275. Forces clsync to create a "w\-rule" for every non-"w-rule" (see
  276. .BR RULES ).
  277. Not recommended to use in conjunction with
  278. .I \-\-rsync
  279. option.
  280. Is not set by default.
  281. .RE
  282. .PP
  283. .B \-M, \-\-synchandler\-so\-module
  284. .RS 8
  285. .B clsync
  286. will load
  287. .I sync-handler
  288. as a shared library with
  289. .BR dlopen (3)
  290. and run syncing by calling function "clsyncapi_sync()" from
  291. this shared object file (see
  292. .B "SYNC HANDLER"
  293. case
  294. .BR f ).
  295. Cannot be used in conjunction with
  296. .I \-\-rsync
  297. and/or
  298. .IR \-\-dir\-lists .
  299. Is not set by default.
  300. .RE
  301. .PP
  302. .B \-R, \-\-rsync
  303. .RS 8
  304. Forces
  305. .B clsync
  306. to use "rsynclist" action instead of "initialsync" and "synclist" (see
  307. .B "SYNC HANDLER"
  308. case
  309. .BR d ).
  310. This option can be used only with
  311. .I \-\-dir\-lists
  312. option.
  313. Recommended option.
  314. You can use "\-R2" to run "rsync" directly, bypassing intermediate script
  315. (see
  316. .B "SYNC HANDLER"
  317. case
  318. .BR e ).
  319. Cannot be used in conjunction with
  320. .IR \-\-synchandler\-so\-module .
  321. But you cannot use
  322. .I \-\-cluster\-*
  323. options in
  324. .I \-R2
  325. mode.
  326. Is not set by default.
  327. .RE
  328. .PP
  329. .B \-L, \-\-rsync\-inclimit
  330. .I rsync\-includes\-line\-limit
  331. .RS 8
  332. Sets soft limit for lines count in files by path
  333. .IR rsync\-listpath .
  334. Unfortunately, rsync works very slowly with huge "\-\-include\-from"
  335. files. So,
  336. .B clsync
  337. splits that list with approximately
  338. .I rsync\-includes\-line\-limit
  339. lines per list if it's too big, and executes by one rsync instance per list
  340. part. Use value "0" to disable the limit.
  341. Default value is "20000".
  342. .RE
  343. .PP
  344. .B \-I, \-\-rsync\-prefer\-include
  345. .RS 8
  346. Forces
  347. .B clsync
  348. to prefer a "lot of includes" method instead of a "excludes+includes" for
  349. rsync on recursive syncing.
  350. See
  351. .B case d
  352. of
  353. .BR "SYNC HANDLER" .
  354. This option is not recommended.
  355. Is not set by default.
  356. .RE
  357. .PP
  358. .B \-x, \-\-ignore\-exitcode
  359. .I exitcode
  360. .RS 8
  361. Forces
  362. .B clsync
  363. to do not process exitcode
  364. .I exitcode
  365. of
  366. .I sync\-handler
  367. as an error. You can set multiple ignores by passing this option multiple
  368. times.
  369. Recommended values for rsync case are "23" and "24".
  370. ["\-x 23 \-x 24"]
  371. .RE
  372. .PP
  373. .B \-U, \-\-dont\-unlink\-lists
  374. .RS 8
  375. Do not delete list\-files after
  376. .I sync\-handler
  377. has finished.
  378. This may be used for debugging purposes.
  379. Is not set by default.
  380. .RE
  381. .PP
  382. .B \-F, \-\-full\-initialsync
  383. .RS 8
  384. Ignore filter rules from
  385. .I rules-file
  386. on initial sync.
  387. This may be useful for quick start or e.g. if it's required to sync
  388. "/var/log/" tree but not sync every change from there.
  389. Is not set by default.
  390. .RE
  391. .PP
  392. .B \-v, \-\-verbose
  393. .RS 8
  394. This option is supposed to increase verbosity. But at the moment there's no
  395. "verbose output" in the code, so the option does nothing. :)
  396. .RE
  397. .PP
  398. .B \-D, \-\-debug
  399. .RS 8
  400. Increases debugging output. This may be supplied multiple times for more
  401. debugging information, up to a maximum of three "D" flags (more will do
  402. nothing), for example "\-D \-D \-D" or "\-D3" (equivalent cases)
  403. .RE
  404. .PP
  405. .B \-q, \-\-quiet
  406. .RS 8
  407. Suppresses error messages.
  408. .RE
  409. .PP
  410. .B \-f, \-\-fanotify
  411. .RS 8
  412. .B Don't use this option!
  413. Switches monitor subsystem to "fanotify" [it's described for
  414. future\-compatibility].
  415. .RE
  416. .PP
  417. .B \-i, \-\-inotify
  418. .RS 8
  419. Switches monitor subsystem to "inotify".
  420. Is set by default.
  421. .RE
  422. .PP
  423. .B \-l, \-\-label
  424. .I label
  425. .RS 8
  426. Sets a label for this instance of clsync. The
  427. .I label
  428. will be passed to
  429. .I sync\-handler
  430. every execution.
  431. Default value is "nolabel".
  432. .RE
  433. .PP
  434. .B \-h, \-\-help
  435. .RS 8
  436. Outputs options list and exits with exitcode "0".
  437. .RE
  438. .PP
  439. .B \-V, \-\-version
  440. .RS 8
  441. Outputs clsync version and exits with exitcode "0".
  442. .RE
  443. .SH SYNC HANDLER
  444. .B clsync
  445. executes
  446. .I sync\-handler
  447. that supposed to take care of the actual syncing process. Therefore
  448. .B clsync
  449. is only a convenient way to run a syncing script.
  450. .B clsync
  451. can run
  452. .I sync\-handler
  453. in six ways. Which way will be used depends on specified options (see
  454. .I \-\-dir\-lists
  455. ,
  456. .I \-\-rsync
  457. and
  458. .IR \-\-synchandler\-so\-module ).
  459. case
  460. .B a
  461. .RS
  462. .I sync\-handler
  463. sync
  464. .I label evmask path [nodes]
  465. In this case,
  466. .I sync\-handler
  467. is supposed to non\-recursively sync file or directory by
  468. .IR path .
  469. With
  470. .I evmask
  471. it's passed bitmask of events with the file or directory (see
  472. "/usr/include/linux/inotify.h").
  473. This case will be used, if there is no
  474. .I \-\-dir\-lists
  475. and
  476. .I \-\-synchandler\-so\-module
  477. options are set.
  478. .RE
  479. case
  480. .B b
  481. .RS
  482. .I sync\-handler
  483. synclist
  484. .I label listpath [nodes]
  485. In this case,
  486. .I sync\-handler
  487. is supposed to non\-recursively sync files and directories from list in a file by
  488. path
  489. .IR listpath (see
  490. below). With
  491. .I evmask
  492. it's passed bitmask of events with the file or directory (see
  493. "/usr/include/linux/inotify.h").
  494. This case will be used if option
  495. .I \-\-dir\-lists
  496. is set, but options
  497. .I \-\-rsync
  498. and
  499. .I \-\-synchandler\-so\-module
  500. are not set.
  501. .RE
  502. case
  503. .B c
  504. .RS
  505. .I sync\-handler
  506. initialsync
  507. .I label dirpath [nodes]
  508. In this case,
  509. .I sync\-handler
  510. is supposed to recursively sync data from directory by path
  511. .I dirpath
  512. with manual excluding extra files.
  513. This case will be used for initial sync, if options
  514. .I \-\-dir\-lists
  515. and
  516. .I \-\-initialsync\-enable
  517. are set, but option
  518. .I \-\-synchandler\-so\-module
  519. is not set.
  520. .RE
  521. case
  522. .B d
  523. .RS
  524. .I sync\-handler
  525. rsynclist
  526. .I label rsync\-listpath [nodes] [rsync\-exclude\-listpath]
  527. In this case,
  528. .I sync\-handler
  529. is supposed to run "rsync" application with parameters:
  530. \-aH \-\-delete\-before \-\-include\-from
  531. .I rsync\-listpath
  532. \-\-exclude '*'
  533. if option
  534. .I \-\-rsync\-prefer\-include
  535. is enabled.
  536. And with parameters:
  537. \-aH \-\-delete\-before \-\-exclude\-from
  538. .I rsync\-exclude\-listpath
  539. \-\-include\-from
  540. .I rsync\-listpath
  541. \-\-exclude '*'
  542. if option
  543. .I \-\-rsync\-prefer\-include
  544. is disabled.
  545. This case will be used, if option
  546. .I \-\-rsync
  547. is set once.
  548. Recommended case.
  549. .RE
  550. case
  551. .B e
  552. .RS
  553. .I sync\-handler
  554. \-\-inplace \-aH \-\-delete\-before [\-\-exclude\-from
  555. .I rsync\-exclude\-listpath
  556. ]
  557. \-\-include\-from
  558. .I rsync\-listpath
  559. \-\-exclude '*'
  560. .I watch-dir/ dest-dir/
  561. In this case,
  562. .I sync\-handler
  563. is supposed to be a path to
  564. .B rsync
  565. binary.
  566. Error code "24" from
  567. .I sync\-handler
  568. will be ignored in this case.
  569. This case will be used, if option
  570. .I \-\-rsync
  571. is set twice (or equivalently "\-\-rsync=2"). This case is supposed to be used
  572. only as a proof of concept.
  573. .RE
  574. case
  575. .B f
  576. .RS
  577. In this case there's no direct exec*() calling. In this case
  578. .B clsync
  579. loads
  580. .I sync-handler
  581. as a shared library with
  582. .BR dlopen (3)
  583. and calls function "int clsyncapi_sync(int n, api_eventinfo_t *ei)" from it
  584. for every sync.
  585. .B n
  586. is number of elements of
  587. .BR ei .
  588. .B ei
  589. is an array of structures with information about what and how to sync (see
  590. below).
  591. api_eventinfo_t is a structure:
  592. .RS
  593. struct api_eventinfo {
  594. .br
  595. uint32_t evmask; // event bitmask for file/dir by path
  596. .BR path .
  597. .br
  598. uint32_t flags; // flags of "how to sync" the file/dir
  599. .br
  600. size_t path_len; // strlen(path)
  601. .br
  602. const char *path; // the path to file/dir need to be
  603. synced
  604. .br
  605. };
  606. .br
  607. typedef struct api_eventinfo api_eventinfo_t;
  608. .RE
  609. The event bitmask (evmask) values can be learned from
  610. "/usr/include/linux/inotify.h".
  611. There may be next flags' values (flags):
  612. .RS
  613. enum eventinfo_flags {
  614. .br
  615. EVIF_RECURSIVELY = 0x00000001 // sync the file/dir recursively
  616. .br
  617. };
  618. .RE
  619. .br
  620. Flag "EVIF_RECURSIVELY" may be used if option
  621. .I\-\-initialsync\-enable
  622. is set.
  623. Also may be defined functions "int clsyncapi_init(options_t *, indexes_t *)"
  624. and "int clsyncapi_deinit()" to initialize and deinitialize the syncing
  625. process by this shared object.
  626. See example file "clsync-synchandler-so.c".
  627. This case will be used, if option
  628. .I \-\-synchandler\-so\-module
  629. is set.
  630. Recommended case.
  631. .RE
  632. As can be noticed, in the first four cases clsync's
  633. .I label
  634. (see
  635. .I \-\-label
  636. ) and
  637. .I nodes
  638. are passed (or can be passed).
  639. .I nodes
  640. is comma-separated list of cluster nodes names where to sync to (see
  641. .I \-\-cluster-node-name
  642. )
  643. The listfile by path
  644. .I listpath
  645. contains lines separated by NL (without CR) of next format:
  646. .RS
  647. sync
  648. .I label evmask path
  649. .RS
  650. if option
  651. .I \-\-synclist\-simplify
  652. is not set
  653. .RE
  654. .I path
  655. .RS
  656. if option
  657. .I \-\-synclist\-simplify
  658. is set
  659. .RE
  660. Every lines is supposed to be proceed by external syncer to sync file or
  661. directory by path
  662. .IR path .
  663. With
  664. .I evmask
  665. it's passed bitmask of events with the file or directory (see
  666. "/usr/include/linux/inotify.h").
  667. .RE
  668. .SH RULES
  669. Filter riles can be placed into
  670. .I rules\-file
  671. with one rule per line.
  672. Rule format:
  673. .I [+\-][fdw*]regexp
  674. .I +
  675. \- means include;
  676. .I \-
  677. \- means exclude;
  678. .I f
  679. \- means file;
  680. .I d
  681. \- means directory;
  682. .I w
  683. \- means walking to directory;
  684. .I *
  685. \- means all.
  686. For example: \-*^/[Tt]est
  687. It's not recommended to use
  688. .I w
  689. rules for
  690. .I \-\-rsync
  691. cases.
  692. .BR rsync (1)
  693. allows to set syncing and walking only together in "\-\-include" rules
  694. ("\-\-files\-from" is not appropriate due to problem with syncing files
  695. deletions). So there may be problems with clsync's
  696. .I w
  697. rules in this cases.
  698. More examples:
  699. Syncing pwdb files and sshd_config (non-rsync case):
  700. .RS
  701. +f^/passwd$
  702. .br
  703. +f^/group$
  704. .br
  705. +f^/shadow$
  706. .br
  707. +f^/ssh/sshd_config$
  708. .br
  709. +w^$
  710. .br
  711. +w^/ssh$
  712. .br
  713. -*
  714. .RE
  715. Syncing pwdb files and sshd_config (non-rsync case with option
  716. .IR \-\-auto\-add\-rules\-w ):
  717. .RS
  718. +f^/passwd$
  719. .br
  720. +f^/group$
  721. .br
  722. +f^/shadow$
  723. .br
  724. +f^/ssh/sshd_config$
  725. .br
  726. -*
  727. .RE
  728. Syncing pwdb files and sshd_config (rsync case):
  729. .RS
  730. +f^/passwd$
  731. .br
  732. +f^/group$
  733. .br
  734. +f^/shadow$
  735. .br
  736. +f^/ssh/sshd_config$
  737. .br
  738. +d^$
  739. .br
  740. +d^/ssh$
  741. .br
  742. -*
  743. .RE
  744. Syncing /srv/lxc tree (rsync case):
  745. .RS
  746. -d/sess(ion)?s?$
  747. .br
  748. -f/tmp/
  749. .br
  750. +*
  751. .RE
  752. .SH SIGNALS
  753. 1 \- to reread filter rules
  754. 10 \- runs threads' GC function
  755. 12 \- runs full resync
  756. 16 \- interrupts sleep()/select() and wait() [for debugging and internal uses]
  757. .SH DIAGNOSTICS
  758. Initial rsync process works very slow on clsync start
  759. .RS
  760. Probably there's too huge exclude list is passed to rsync. This can happened
  761. if you're excluding with regex in clsync's rules a lot of thousands files.
  762. They will be passed to rsync's exclude list one by one.
  763. To diagnose it, you can use "\-U" option and look into
  764. .I rsync\-exclude\-listpath
  765. file (see
  766. .B "SYNC HANDLER"
  767. case
  768. .BR d )
  769. To prevent this, it's recommended to write such rules for rsync directly
  770. (not via clsync).
  771. For example, often problem is with PHP's session files. You shouldn't exclude
  772. them in clsync's rules with "\-f/sess_.*", but you should exclude it in rsync
  773. directly (e.g with «\-\-exclude "sess_*"»).
  774. .RE
  775. The following diagnostics may be issued on stderr:
  776. Error: Cannot inotify_add_watch() on [...]
  777. .RS
  778. Not enough inotify watching descriptors is allowed. It can be fixed
  779. by increasing value of "sysctl fs.inotify.max_user_watches"
  780. .RE
  781. Error: Got non-zero exitcode
  782. .I exitcode
  783. [...]
  784. .RS
  785. .I sync\-handler
  786. returned non-zero exitcode. Probably, you should process exitcodes in it or
  787. your syncer process didn't worked well. I case of using rsync, you can find
  788. the exitcodes meanings in
  789. .BR "man 1 rsync" .
  790. If
  791. .I exitcode
  792. equals to 23 and you're using
  793. .B clsync
  794. in conjunction with
  795. .BR rsync ,
  796. this may happend, for example in next cases:
  797. .RS
  798. \- Not enough space on destination.
  799. \- You're running clsync with
  800. .B \-\-pthread
  801. and rsync with
  802. .BR \-\-backup .
  803. See bugreport by URL:
  804. .IR https://bugzilla.samba.org/show_bug.cgi?id=10081 .
  805. .RE
  806. To confirm the problem, you can try to add "return 0" or "exit 0" into
  807. your
  808. .IR sync\-handler .
  809. .RE
  810. .SH CONFIGURATION FILE
  811. .B clsync
  812. supports configuration file.
  813. By default
  814. .B clsync
  815. tries to read next files (in specified order):
  816. .RS
  817. ~/.clsync.conf
  818. .br
  819. /etc/clsync/clsync.conf
  820. .RE
  821. This may be overrided with option
  822. .IR \-\-config\-file .
  823. .B clsync
  824. reads only one configuration file. In other words, if option
  825. .I \-\-config\-file
  826. is not set and file
  827. .B ~/.clsync.conf
  828. is accessable and parsable,
  829. .B clsync
  830. will not try to open
  831. .BR /etc/clsync/clsync.conf .
  832. Command line options have precedence over config file options.
  833. Configuration file is parsed with glib's g_key_file_* API. That means,
  834. that config should consits from groups (blocks) of key-value lines as in the
  835. example:
  836. .RS
  837. [default]
  838. .br
  839. background=1
  840. .br
  841. rsync=1
  842. .br
  843. debug=0
  844. .br
  845. syslog=1
  846. .br
  847. pid-file=/var/run/clsync.pid
  848. .br
  849. .br
  850. [test]
  851. .br
  852. rsync=2
  853. .br
  854. debug=3
  855. .RE
  856. In this example there's 2 blocks are set - "default" and "test".
  857. By default
  858. .B clsync
  859. uses block with name "default". Block name can be set by option
  860. .IR \-\-config\-block .
  861. .SH CLUSTERING
  862. Not implemented yet.
  863. .B Don't try to use cluster functionality.
  864. Not described yet.
  865. .SH EXAMPLES
  866. Working example you can try out in "example/" or
  867. "/usr/share/doc/clsync/example/" directory. Copy this directory somewhere
  868. (e.g. into "/tmp"). And try to run "clsync-start.sh" in there. Any
  869. files/directories modifications in "example/testdir/from" will be synced to
  870. "example/testdir/to" with few seconds delay.
  871. .RE
  872. .SH AUTHOR
  873. Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
  874. .SH "SEE ALSO"
  875. .BR rsync (1),
  876. .BR pthreads (7),
  877. .BR inotify (7)