syncthing-versioning.7 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "TODO" "7" "August 22, 2016" "v0.14" "Syncthing"
  4. .SH NAME
  5. Todo \- Keep automatic backups of deleted files by other nodes
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  33. .INDENT 0.0
  34. .INDENT 3.5
  35. .sp
  36. External versioning needs example for Windows.
  37. .UNINDENT
  38. .UNINDENT
  39. .SH DESCRIPTION
  40. .sp
  41. Syncthing supports archiving the old version of a file when it is deleted or
  42. replaced with a newer version from the cluster. This is called "file
  43. versioning" and uses one of the available \fIversioning strategies\fP described
  44. below. File versioning is configured per folder and defaults to "no file
  45. versioning", i.e. no old copies of files are kept.
  46. .SH TRASH CAN FILE VERSIONING
  47. .sp
  48. This versioning strategy emulates the common "trash can" approach. When a file
  49. is deleted or replaced due to a change on a remote device, it is a moved to
  50. the trash can in the \fB\&.stversions\fP folder. If a file with the same name was
  51. already in the trash can it is replaced.
  52. .sp
  53. A configuration option is available to clean the trash can from files older
  54. than a specified number of days. If this is set to a positive number of days,
  55. files will be removed when they have been in the trash can that long. Setting
  56. this to zero prevents any files from being removed from the trash can
  57. automatically.
  58. .SH SIMPLE FILE VERSIONING
  59. .sp
  60. With "Simple File Versioning" files are moved to the \fB\&.stversions\fP folder
  61. (inside your shared folder) when replaced or deleted on a remote device. This
  62. option also takes a value in an input titled "Keep Versions" which tells
  63. Syncthing how many old versions of the file it should keep. For example, if
  64. you set this value to 5, if a file is replaced 5 times on a remote device, you
  65. will see 5 time\-stamped versions on that file in the ".stversions" folder on
  66. the other devices sharing the same folder.
  67. .SH STAGGERED FILE VERSIONING
  68. .sp
  69. With "Staggered File Versioning" files are also moved to a different folder
  70. when replaced or deleted on a remote device (just like "Simple File
  71. Versioning"), however, versions are automatically deleted if they are older
  72. than the maximum age or exceed the number of files allowed in an interval.
  73. .sp
  74. With this versioning method it\(aqs possible to specify where the versions are
  75. stored, with the default being the \fB\&.stversions\fP folder inside the normal
  76. folder path. If you set a custom version path, please ensure that it\(aqs on the
  77. same partition or filesystem as the regular folder path, as moving files there
  78. may otherwise fail. You can use an absolute path (this is recommended) or a
  79. relative path. Relative paths are interpreted relative to Syncthing\(aqs current
  80. or startup directory.
  81. .sp
  82. The following intervals are used and they each have a maximum number of files
  83. that will be kept for each.
  84. .INDENT 0.0
  85. .TP
  86. .B 1 Hour
  87. For the first hour, the most recent version is kept every 30 seconds.
  88. .TP
  89. .B 1 Day
  90. For the first day, the most recent version is kept every hour.
  91. .TP
  92. .B 30 Days
  93. For the first 30 days, the most recent version is kept every day.
  94. .TP
  95. .B Until Maximum Age
  96. The maximum time to keep a version in days. For example, to keep replaced or
  97. deleted files in the ".stversions" folder for an entire year, use 365. If
  98. only or 10 days, use 10. \fBNote: Set to 0 to keep versions forever.\fP
  99. .UNINDENT
  100. .SH EXTERNAL FILE VERSIONING
  101. .sp
  102. This versioning method delegates the decision on what to do to an external
  103. command (program or script). The only configuration option is the name of the
  104. command. This should be an absolute path name. Just prior to a file being
  105. replaced, the command will be run with two parameters: the path to the folder,
  106. and the path to the file within the folder.
  107. .SS Example for Unixes
  108. .sp
  109. Lets say I want to keep the latest version of each file as they are replaced
  110. or removed; essentially I want a "trash can"\-like behavior. For this, I create
  111. the following script and store it as \fB/Users/jb/bin/onlylatest.sh\fP (i.e. the
  112. \fBbin\fP directory in my home directory):
  113. .INDENT 0.0
  114. .INDENT 3.5
  115. .sp
  116. .nf
  117. .ft C
  118. #!/bin/sh
  119. set \-eu
  120. # Where I want my versions stored
  121. versionspath=~/.trashcan
  122. # The parameters we get from Syncthing
  123. folderpath="$1"
  124. filepath="$2"
  125. # First ensure the dir where we need to store the file exists
  126. outpath=\(gadirname "$versionspath/$filepath"\(ga
  127. mkdir \-p "$outpath"
  128. # Then move the file there
  129. mv \-f "$folderpath/$filepath" "$versionspath/$filepath"
  130. .ft P
  131. .fi
  132. .UNINDENT
  133. .UNINDENT
  134. .sp
  135. I must ensure that the script has execute permissions (\fBchmod 755
  136. onlylatest.sh\fP), then configure Syncthing with the above path as the command
  137. name.
  138. .sp
  139. Lets assume I have a folder "default" in ~/Sync, and that within that folder
  140. there is a file \fBdocs/letter.txt\fP that is being replaced or deleted. The
  141. script will be called as if I ran this from the command line:
  142. .INDENT 0.0
  143. .INDENT 3.5
  144. .sp
  145. .nf
  146. .ft C
  147. $ /Users/jb/bin/onlylatest.sh /Users/jb/Sync docs/letter.txt
  148. .ft P
  149. .fi
  150. .UNINDENT
  151. .UNINDENT
  152. .sp
  153. The script will then move the file in question to
  154. \fB~/.trashcan/docs/letter.txt\fP, replacing any previous version of that letter
  155. that may already have been there.
  156. .SS Example for Windows
  157. .sp
  158. On Windows we can use a batch script to perform the same "trash can"\-like
  159. behavior as mentioned above. I created the following script and saved it as
  160. \fBC:\eUsers\emfrnd\eScripts\eonlylatest.bat\fP\&.
  161. .INDENT 0.0
  162. .INDENT 3.5
  163. .sp
  164. .nf
  165. .ft C
  166. @echo off
  167. :: We need command extensions for mkdir to create intermediate folders in one go
  168. setlocal EnableExtensions
  169. :: Where I want my versions stored
  170. set VERSIONS_PATH=%USERPROFILE%\e.trashcan
  171. :: The parameters we get from Syncthing, \(aq~\(aq removes quotes if any
  172. set FOLDER_PATH=%~1
  173. set FILE_PATH=%~2
  174. :: First ensure the dir where we need to store the file exists
  175. for %%F in ("%VERSIONS_PATH%\e%FILE_PATH%") do set OUTPUT_PATH=%%~dpF
  176. if not exist "%OUTPUT_PATH%" mkdir "%OUTPUT_PATH%" || exit /B
  177. :: Finally move the file, overwrite existing file if any
  178. move /Y "%FOLDER_PATH%\e%FILE_PATH%" "%VERSIONS_PATH%\e%FILE_PATH%"
  179. .ft P
  180. .fi
  181. .UNINDENT
  182. .UNINDENT
  183. .sp
  184. Finally, I set \fBC:\eUsers\emfrnd\eScripts\eonlylatest.bat\fP as command name in
  185. Syncthing.
  186. .SH AUTHOR
  187. The Syncthing Authors
  188. .SH COPYRIGHT
  189. 2015, The Syncthing Authors
  190. .\" Generated by docutils manpage writer.
  191. .