borg-init.1 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. '\" t
  2. .\" Man page generated from reStructuredText.
  3. .
  4. .
  5. .nr rst2man-indent-level 0
  6. .
  7. .de1 rstReportMargin
  8. \\$1 \\n[an-margin]
  9. level \\n[rst2man-indent-level]
  10. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  11. -
  12. \\n[rst2man-indent0]
  13. \\n[rst2man-indent1]
  14. \\n[rst2man-indent2]
  15. ..
  16. .de1 INDENT
  17. .\" .rstReportMargin pre:
  18. . RS \\$1
  19. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  20. . nr rst2man-indent-level +1
  21. .\" .rstReportMargin post:
  22. ..
  23. .de UNINDENT
  24. . RE
  25. .\" indent \\n[an-margin]
  26. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  27. .nr rst2man-indent-level -1
  28. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  30. ..
  31. .TH "BORG-INIT" "1" "2025-10-31" "" "borg backup tool"
  32. .SH NAME
  33. borg-init \- Initialize an empty repository
  34. .SH SYNOPSIS
  35. .sp
  36. borg [common options] init [options] [REPOSITORY]
  37. .SH DESCRIPTION
  38. .sp
  39. This command initializes an empty repository. A repository is a
  40. filesystem directory containing the deduplicated data from zero or more
  41. archives.
  42. .SS Encryption mode TL;DR
  43. .sp
  44. The encryption mode can only be configured when creating a new
  45. repository. You can neither configure encryption on a per\-archive
  46. basis, nor change the encryption mode of an existing repository. You
  47. should thus take possible future use into account when deciding on an
  48. encryption mode.
  49. .sp
  50. As a general rule of thumb, use \fBrepokey\fP with a strong passphrase:
  51. .INDENT 0.0
  52. .INDENT 3.5
  53. borg init \-\-encryption repokey /path/to/repo
  54. .UNINDENT
  55. .UNINDENT
  56. .sp
  57. However, there are many reasons to choose differently. See the section
  58. below for details. In any case, Borg will:
  59. .INDENT 0.0
  60. .IP 1. 3
  61. Ask you to enter a unique and strong passphrase.
  62. .IP 2. 3
  63. Create a random Borg key (which actually consists of three random
  64. secrets, see \fIkey_files\fP for details).
  65. .IP 3. 3
  66. Encrypt the Borg key with your passphrase.
  67. .IP 4. 3
  68. Store the encrypted Borg key inside the repository directory (with
  69. \fBrepokey\fP and \fBrepokey\-blake2\fP modes; with \fBkeyfile\fP and
  70. \fBkeyfile\-blake2\fP modes the Borg key is stored in your home
  71. directory instead, see below). Since we usually have to assume that
  72. an attacker could gain access to the repository (that\(aqs why we
  73. encrypt the data in the first place), choosing a strong and unique
  74. passphrase is absolutely crucial.
  75. .IP 5. 3
  76. Encrypt and sign your backups with the Borg key to prevent anyone
  77. from reading or forging them unless they have the Borg key \fIand\fP
  78. know the passphrase.
  79. .IP 6. 3
  80. Use the Borg key to decrypt and thus access the data stored in your
  81. repository, e.g. when extracting files. The contents can also be
  82. verified to detect accidental corruption or malicious tampering.
  83. .UNINDENT
  84. .sp
  85. As you can see, you always need \fIboth\fP the Borg key and passphrase to
  86. access your data. Thus it\(aqs crucial to keep a backup of your key
  87. \fIoutside\fP both the repository and the system you create backups of.
  88. You can easily run into a \(dqleaving your keys inside your car\(dq situation
  89. otherwise. See \fIborg_key_export\fP to create a backup of your key
  90. (e.g., by printing it on paper).
  91. .sp
  92. Encryption is done locally \- i.e., if you back up to a remote machine,
  93. the remote machine neither sees your passphrase, nor your unencrypted
  94. Borg key, nor your unencrypted files. Chunking and ID generation are
  95. based on your key to improve privacy.
  96. .sp
  97. \fBAbout hardware acceleration:\fP
  98. .sp
  99. Borg encrypts data with AES, which is pretty fast thanks to hardware
  100. acceleration on basically all modern Intel, AMD, and ARM CPUs since
  101. around the early 2010s (very cheap models since the mid\-2010s).
  102. .sp
  103. As the hashing algorithm, Borg can use either SHA256 or BLAKE2b. ARM
  104. CPUs support hardware\-accelerated SHA256 hashing since ARMv7 with NEON
  105. (around 2011), or ARMv8 (around 2013). AMD CPUs support it since Zen 1
  106. (around 2017), i.e. all AMD Ryzen CPUs. Intel CPUs support it since Ice
  107. Lake on mobile (10th gen, around 2021), and Rocket Lake on desktop
  108. (11th gen, around 2021). Very cheap models have received support a few
  109. years later. If your CPU doesn\(aqt support hardware\-accelerated SHA256
  110. hashing, you might want to give BLAKE2b hashing a try \- it\(aqs likely
  111. faster then. So, instead of \fBrepokey\fP mode, use \fBrepokey\-blake2\fP
  112. (or any of the other \fB\-blake2\fP modes for that matter).
  113. .sp
  114. Hardware acceleration is always used automatically when available.
  115. .SS Picking a passphrase
  116. .sp
  117. Make sure you use a good passphrase. Not too short, not too simple. The
  118. real encryption / decryption key is encrypted with / locked by your
  119. passphrase. If an attacker gets your borg key, they can\(aqt unlock and use
  120. it without knowing the passphrase.
  121. .sp
  122. Be careful with special or non\-ASCII characters in your passphrase:
  123. .INDENT 0.0
  124. .IP \(bu 2
  125. Borg processes the passphrase as Unicode (and encodes it as UTF\-8), so
  126. it does not have problems dealing with even the strangest characters.
  127. .IP \(bu 2
  128. BUT: that does not necessarily apply to your OS / VM / keyboard
  129. configuration.
  130. .UNINDENT
  131. .sp
  132. So it is better to use a long passphrase made from simple ASCII
  133. characters than one that includes non\-ASCII characters or characters
  134. that are hard or impossible to enter on a different keyboard layout.
  135. .sp
  136. You can change your passphrase for existing repositories at any time; it
  137. won\(aqt affect the encryption/decryption key or other secrets. See
  138. \fIborg_key_change\-passphrase\fP\&.
  139. .SS More about encryption modes
  140. .sp
  141. Choosing the right encryption mode isn\(aqt always easy and many factors
  142. can change which mode is best for you. However, note that you can\(aqt
  143. really do anything \fIwrong\fP if you choose \fBrepokey\fP with a strong
  144. passphrase. So, if you\(aqre not sure, choose \fBrepokey\fP (or
  145. \fBrepokey\-blake2\fP, depending on your hardware, see above).
  146. .sp
  147. Borg supports the following encryption modes:
  148. .\" nanorst: inline-fill
  149. .
  150. .TS
  151. box center;
  152. l|l|l|l.
  153. T{
  154. Hash/MAC
  155. T} T{
  156. Not Encrypted
  157. T} T{
  158. Encrypted (AEAD w/ AES)
  159. T}
  160. _
  161. T{
  162. Not Authenticated
  163. T} T{
  164. Authenticated
  165. T}
  166. _
  167. T{
  168. SHA\-256
  169. T} T{
  170. \fBnone\fP
  171. T} T{
  172. \fBauthenticated\fP
  173. T} T{
  174. \fBrepokey\fP
  175. \fBkeyfile\fP
  176. T}
  177. _
  178. T{
  179. BLAKE2b
  180. T} T{
  181. n/a
  182. T} T{
  183. \fBauthenticated\-blake2\fP
  184. T} T{
  185. \fBrepokey\-blake2\fP
  186. \fBkeyfile\-blake2\fP
  187. T}
  188. .TE
  189. .\" nanorst: inline-replace
  190. .
  191. .sp
  192. Borg 1.0 and older support \fBnone\fP, \fBrepokey\fP, and \fBkeyfile\fP
  193. modes only. If you need such old clients to be able to access your
  194. repo, you can\(aqt use any of the other modes.
  195. .sp
  196. \fBAbout modes without encryption:\fP
  197. .sp
  198. Avoid using \fBnone\fP mode. If you think about using \fBnone\fP mode,
  199. please reconsider and be absolutely sure. Using any mode other than
  200. \fBnone\fP allows Borg to detect accidental corruption or malicious
  201. tampering with the repo. It also prevents denial\-of\-service attacks
  202. against clients. Instead of \fBnone\fP mode, you likely want to use
  203. \fBauthenticated\fP mode, or \fBrepokey\fP or \fBkeyfile\fP modes with an
  204. empty passphrase instead (see below).
  205. .sp
  206. If you don\(aqt want to encrypt your data, use \fBauthenticated\fP or
  207. \fBauthenticated\-blake2\fP modes. These modes require a passphrase in
  208. normal operation, but in emergency situations you can access the repo
  209. without the passphrase with \fBBORG_WORKAROUNDS=authenticated_no_key\fP
  210. (see \fIenvironment\-variables\fP).
  211. .sp
  212. If you just don\(aqt want to choose a passphrase, use \fBkeyfile\fP or
  213. \fBkeyfile\-blake2\fP modes with an empty passphrase. These modes are
  214. generally safe even without a passphrase, but keeping an offsite
  215. backup of the Borg key is also important then. See below for details.
  216. .sp
  217. If you can assure that an attacker can\(aqt gain access to your repo, e.g.
  218. when independently encrypting your repository disk or filesystem, you
  219. can think about using \fBrepokey\fP or \fBrepokey\-blake2\fP modes with an
  220. empty passphrase. However, keep in mind that if an attacker still
  221. somehow manages to gain access, they have full access to your repo. In
  222. such situations choosing \fBrepokey\fP over \fBauthenticated\fP mode has
  223. the advantage of allowing you to add a passphrase later using
  224. \fIborg_key_change\-passphrase\fP\&.
  225. .sp
  226. \fBAbout modes with encryption:\fP
  227. .sp
  228. With \fBrepokey\fP and \fBrepokey\-blake2\fP modes the key is stored with
  229. the repo and encrypted with your passphrase. If an attacker gains
  230. access to your repo and knows the passphrase, he can access and tamper
  231. with the repo. The repo\(aqs security thus relies on the strength of your
  232. passphrase. Creating an offsite backup of your Borg key (e.g., by
  233. printing it on paper) is recommended, see \fIborg_key_export\fP\&.
  234. .sp
  235. If you\(aqre thinking about storing the passphrase on the disk of the
  236. system you\(aqre backing up, consider using the \fBkeyfile\fP method
  237. instead. It generally provides the same or better security then.
  238. .sp
  239. With \fBkeyfile\fP and \fBkeyfile\-blake2\fP modes the key is stored on your
  240. local machine (in \fB~/.config/borg/keys\fP) instead. An attacker gaining
  241. access to your repo then needs both the Borg key, and your passphrase to
  242. access and tamper with the repo. However, if you lose the key, you lose
  243. access to the repo, too. You \fBmust\fP create an offsite backup of your
  244. Borg key, e.g. by printing it on paper. Storing a copy of the Borg key
  245. on the system you\(aqre creating backups of is \fBNOT\fP sufficient. Use
  246. \fIborg_key_export\fP to create the backup.
  247. .sp
  248. The \fBkeyfile\fP and \fBkeyfile\-blake2\fP modes allow for \(dqpassphrase and
  249. having\-the\-key\(dq security when using a strong passphrase, but can also
  250. be used with an empty passphrase. Storing a (easily readable)
  251. passphrase on the disk of the system you\(aqre backing up with
  252. \fBkeyfile\fP and \fBkeyfile\-blake2\fP modes adds no security over using an
  253. empty passphrase.
  254. .sp
  255. \fBTechnical details:\fP
  256. .sp
  257. \fBrepokey\fP and \fBkeyfile\fP use AES\-CTR\-256 for encryption and
  258. HMAC\-SHA256 for authentication in an encrypt\-then\-MAC (EtM)
  259. construction. The chunk ID hash is HMAC\-SHA256 (with a separate key).
  260. These modes are compatible with all Borg versions.
  261. .sp
  262. \fBrepokey\-blake2\fP and \fBkeyfile\-blake2\fP are also authenticated
  263. encryption modes, but use BLAKE2b\-256 instead of HMAC\-SHA256 for
  264. authentication. The chunk ID hash is a keyed BLAKE2b\-256 hash. These
  265. modes are only compatible with Borg 1.1 and later.
  266. .sp
  267. \fBauthenticated\fP mode uses no encryption, but authenticates repo
  268. contents through the same HMAC\-SHA256 hash as the \fBrepokey\fP and
  269. \fBkeyfile\fP modes (it uses it as the chunk ID hash). The key is stored
  270. like \fBrepokey\fP within the repo. This mode is only compatible with
  271. Borg 1.1 and later.
  272. .sp
  273. \fBauthenticated\-blake2\fP is like \fBauthenticated\fP, but uses the keyed
  274. BLAKE2b\-256 hash from the other BLAKE2b modes. This mode is only
  275. compatible with Borg 1.1 and later.
  276. .sp
  277. \fBnone\fP mode uses no encryption and no authentication. It uses SHA256
  278. as chunk ID hash. This mode is not recommended. You should instead
  279. consider using an authenticated or authenticated/encrypted mode. This
  280. mode has possible denial\-of\-service issues when running \fBborg create\fP
  281. on contents controlled by an attacker. See above for alternatives.
  282. This mode is compatible with all Borg versions.
  283. .SH OPTIONS
  284. .sp
  285. See \fIborg\-common(1)\fP for common options of Borg commands.
  286. .SS arguments
  287. .INDENT 0.0
  288. .TP
  289. .B REPOSITORY
  290. repository to create
  291. .UNINDENT
  292. .SS options
  293. .INDENT 0.0
  294. .TP
  295. .BI \-e \ MODE\fR,\fB \ \-\-encryption \ MODE
  296. select encryption key mode \fB(required)\fP
  297. .TP
  298. .B \-\-append\-only
  299. create an append\-only mode repository. Note that this only affects the low level structure of the repository, and running \fIdelete\fP or \fIprune\fP will still be allowed. See \fIappend_only_mode\fP in Additional Notes for more details.
  300. .TP
  301. .BI \-\-storage\-quota \ QUOTA
  302. Set storage quota of the new repository (e.g. 5G, 1.5T). Default: no quota.
  303. .TP
  304. .B \-\-make\-parent\-dirs
  305. create the parent directories of the repository directory, if they are missing.
  306. .UNINDENT
  307. .SH EXAMPLES
  308. .INDENT 0.0
  309. .INDENT 3.5
  310. .sp
  311. .EX
  312. # Local repository, repokey encryption, BLAKE2b (often faster, since Borg 1.1)
  313. $ borg init \-\-encryption=repokey\-blake2 /path/to/repo
  314. # Local repository (no encryption)
  315. $ borg init \-\-encryption=none /path/to/repo
  316. # Remote repository (accesses a remote borg via ssh)
  317. # repokey: stores the (encrypted) key into <REPO_DIR>/config
  318. $ borg init \-\-encryption=repokey\-blake2 user@hostname:backup
  319. # Remote repository (accesses a remote borg via ssh)
  320. # keyfile: stores the (encrypted) key into ~/.config/borg/keys/
  321. $ borg init \-\-encryption=keyfile user@hostname:backup
  322. .EE
  323. .UNINDENT
  324. .UNINDENT
  325. .SH SEE ALSO
  326. .sp
  327. \fIborg\-common(1)\fP, \fIborg\-create(1)\fP, \fIborg\-delete(1)\fP, \fIborg\-check(1)\fP, \fIborg\-list(1)\fP, \fIborg\-key\-import(1)\fP, \fIborg\-key\-export(1)\fP, \fIborg\-key\-change\-passphrase(1)\fP
  328. .SH AUTHOR
  329. The Borg Collective
  330. .\" Generated by docutils manpage writer.
  331. .