faq.rst 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350
  1. .. include:: global.rst.inc
  2. .. highlight:: none
  3. .. _faq:
  4. Frequently asked questions
  5. ==========================
  6. Usage & Limitations
  7. ###################
  8. What is the difference between a repo on an external hard drive vs. repo on a server?
  9. -------------------------------------------------------------------------------------
  10. If Borg is running in client/server mode, the client uses SSH as a transport to
  11. talk to the remote agent, which is another Borg process (Borg is installed on
  12. the server, too) started automatically by the client. The Borg server is doing
  13. storage-related low-level repo operations (get, put, commit, check, compact),
  14. while the Borg client does the high-level stuff: deduplication, encryption,
  15. compression, dealing with archives, backups, restores, etc., which reduces the
  16. amount of data that goes over the network.
  17. When Borg is writing to a repo on a locally mounted remote file system, e.g.
  18. SSHFS, the Borg client only can do file system operations and has no agent
  19. running on the remote side, so *every* operation needs to go over the network,
  20. which is slower.
  21. Can I backup from multiple servers into a single repository?
  22. ------------------------------------------------------------
  23. Yes, this is *possible* from the technical standpoint, but it is
  24. *not recommended* from the security perspective. BorgBackup is
  25. built upon a defined :ref:`attack_model` that cannot provide its
  26. guarantees for multiple clients using the same repository. See
  27. :ref:`borg_security_critique` for a detailed explanation.
  28. Also, in order for the deduplication used by Borg to work, it
  29. needs to keep a local cache containing checksums of all file
  30. chunks already stored in the repository. This cache is stored in
  31. ``~/.cache/borg/``. If Borg detects that a repository has been
  32. modified since the local cache was updated it will need to rebuild
  33. the cache. This rebuild can be quite time consuming.
  34. So, yes it's possible. But it will be most efficient if a single
  35. repository is only modified from one place. Also keep in mind that
  36. Borg will keep an exclusive lock on the repository while creating
  37. or deleting archives, which may make *simultaneous* backups fail.
  38. Can I copy or synchronize my repo to another location?
  39. ------------------------------------------------------
  40. If you want to have redundant backup repositories (preferably at separate
  41. locations), the recommended way to do that is like this:
  42. - ``borg init repo1``
  43. - ``borg init repo2``
  44. - client machine ---borg create---> repo1
  45. - client machine ---borg create---> repo2
  46. This will create distinct repositories (separate repo ID, separate
  47. keys) and nothing bad happening in repo1 will influence repo2.
  48. Some people decide against above recommendation and create identical
  49. copies of a repo (using some copy / sync / clone tool).
  50. While this might be better than having no redundancy at all, you have
  51. to be very careful about how you do that and what you may / must not
  52. do with the result (if you decide against our recommendation).
  53. What you would get with this is:
  54. - client machine ---borg create---> repo
  55. - repo ---copy/sync---> copy-of-repo
  56. There is no special borg command to do the copying, you could just
  57. use any reliable tool that creates an identical copy (cp, rsync, rclone
  58. might be options).
  59. But think about whether that is really what you want. If something goes
  60. wrong in repo, you will have the same issue in copy-of-repo.
  61. Make sure you do the copy/sync while no backup is running, see
  62. :ref:`borg_with-lock` about how to do that.
  63. Also, you must not run borg against multiple instances of the same repo
  64. (like repo and copy-of-repo) as that would create severe issues:
  65. - Data loss: they have the same repository ID, so the borg client will
  66. think they are identical and e.g. use the same local cache for them
  67. (which is an issue if they happen to be not the same).
  68. See :issue:`4272` for an example.
  69. - Encryption security issues if you would update repo and copy-of-repo
  70. independently, due to AES counter reuse.
  71. See also: :ref:`faq_corrupt_repo`
  72. "this is either an attack or unsafe" warning
  73. --------------------------------------------
  74. About the warning:
  75. Cache, or information obtained from the security directory is newer than
  76. repository - this is either an attack or unsafe (multiple repos with same ID)
  77. "unsafe": If not following the advice from the previous section, you can easily
  78. run into this by yourself by restoring an older copy of your repository.
  79. "attack": maybe an attacker has replaced your repo by an older copy, trying to
  80. trick you into AES counter reuse, trying to break your repo encryption.
  81. If you'ld decide to ignore this and accept unsafe operation for this repository,
  82. you could delete the manifest-timestamp and the local cache:
  83. ::
  84. borg config repo id # shows the REPO_ID
  85. rm ~/.config/borg/security/REPO_ID/manifest-timestamp
  86. borg delete --cache-only REPO
  87. This is an unsafe and unsupported way to use borg, you have been warned.
  88. Which file types, attributes, etc. are *not* preserved?
  89. -------------------------------------------------------
  90. * UNIX domain sockets (because it does not make sense - they are
  91. meaningless without the running process that created them and the process
  92. needs to recreate them in any case). So, don't panic if your backup
  93. misses a UDS!
  94. * The precise on-disk (or rather: not-on-disk) representation of the holes
  95. in a sparse file.
  96. Archive creation has no special support for sparse files, holes are
  97. backed up as (deduplicated and compressed) runs of zero bytes.
  98. Archive extraction has optional support to extract all-zero chunks as
  99. holes in a sparse file.
  100. * Some filesystem specific attributes, like btrfs NOCOW, see :ref:`platforms`.
  101. * For hardlinked symlinks, the hardlinking can not be archived (and thus,
  102. the hardlinking will not be done at extraction time). The symlinks will
  103. be archived and extracted as non-hardlinked symlinks, see :issue:`2379`.
  104. Are there other known limitations?
  105. ----------------------------------
  106. - A single archive can only reference a limited volume of file/dir metadata,
  107. usually corresponding to tens or hundreds of millions of files/dirs.
  108. When trying to go beyond that limit, you will get a fatal IntegrityError
  109. exception telling that the (archive) object is too big.
  110. An easy workaround is to create multiple archives with fewer items each.
  111. See also the :ref:`archive_limitation` and :issue:`1452`.
  112. :ref:`borg_info` shows how large (relative to the maximum size) existing
  113. archives are.
  114. - borg extract only supports restoring into an empty destination. After that,
  115. the destination will exactly have the contents of the extracted archive.
  116. If you extract into a non-empty destination, borg will (for example) not
  117. remove files which are in the destination, but not in the archive.
  118. See :issue:`4598` for a workaround and more details.
  119. .. _checkpoints_parts:
  120. If a backup stops mid-way, does the already-backed-up data stay there?
  121. ----------------------------------------------------------------------
  122. Yes, Borg supports resuming backups.
  123. During a backup a special checkpoint archive named ``<archive-name>.checkpoint``
  124. is saved every checkpoint interval (the default value for this is 30
  125. minutes) containing all the data backed-up until that point.
  126. This checkpoint archive is a valid archive,
  127. but it is only a partial backup (not all files that you wanted to backup are
  128. contained in it). Having it in the repo until a successful, full backup is
  129. completed is useful because it references all the transmitted chunks up
  130. to the checkpoint. This means that in case of an interruption, you only need to
  131. retransfer the data since the last checkpoint.
  132. If a backup was interrupted, you normally do not need to do anything special,
  133. just invoke ``borg create`` as you always do. If the repository is still locked,
  134. you may need to run ``borg break-lock`` before the next backup. You may use the
  135. same archive name as in previous attempt or a different one (e.g. if you always
  136. include the current datetime), it does not matter.
  137. Borg always does full single-pass backups, so it will start again
  138. from the beginning - but it will be much faster, because some of the data was
  139. already stored into the repo (and is still referenced by the checkpoint
  140. archive), so it does not need to get transmitted and stored again.
  141. Once your backup has finished successfully, you can delete all
  142. ``<archive-name>.checkpoint`` archives. If you run ``borg prune``, it will
  143. also care for deleting unneeded checkpoints.
  144. Note: the checkpointing mechanism creates hidden, partial files in an archive,
  145. so that checkpoints even work while a big file is being processed.
  146. They are named ``<filename>.borg_part_<N>`` and all operations usually ignore
  147. these files, but you can make them considered by giving the option
  148. ``--consider-part-files``. You usually only need that option if you are
  149. really desperate (e.g. if you have no completed backup of that file and you'ld
  150. rather get a partial file extracted than nothing). You do **not** want to give
  151. that option under any normal circumstances.
  152. Note that checkpoints inside files are created only since version 1.1, make
  153. sure you have an up-to-date version of borgbackup if you want to continue
  154. instead of retransferring a huge file. In some cases, there is only an outdated
  155. version shipped with your distribution (e.g. Debian). See :ref:`installation`.
  156. How can I backup huge file(s) over a unstable connection?
  157. ---------------------------------------------------------
  158. This is not a problem anymore.
  159. For more details, see :ref:`checkpoints_parts`.
  160. How can I switch append-only mode on and off?
  161. -----------------------------------------------------------------------------------------------------------------------------------
  162. You could do that (via borg config REPO append_only 0/1), but using different
  163. ssh keys and different entries in ``authorized_keys`` is much easier and also
  164. maybe has less potential of things going wrong somehow.
  165. My machine goes to sleep causing `Broken pipe`
  166. ----------------------------------------------
  167. When backing up your data over the network, your machine should not go to sleep.
  168. On macOS you can use `caffeinate` to avoid that.
  169. How can I restore huge file(s) over an unstable connection?
  170. -----------------------------------------------------------
  171. If you cannot manage to extract the whole big file in one go, you can extract
  172. all the part files and manually concatenate them together.
  173. For more details, see :ref:`checkpoints_parts`.
  174. How can I compare contents of an archive to my local filesystem?
  175. -----------------------------------------------------------------
  176. You can instruct ``export-tar`` to send a tar stream to the stdout, and
  177. then use ``tar`` to perform the comparison:
  178. ::
  179. borg export-tar /path/to/repo::archive-name - | tar --compare -f - -C /path/to/compare/to
  180. .. _faq_corrupt_repo:
  181. My repository is corrupt, how can I restore from an older copy of it?
  182. ---------------------------------------------------------------------
  183. If your repositories are encrypted and have the same ID, the recommended method
  184. is to delete the corrupted repository, but keep its security info, and then copy
  185. the working repository to the same location:
  186. ::
  187. borg delete --keep-security-info /path/to/repo
  188. rsync -aH /path/to/repo-working/ /path/to/repo # Note the trailing slash.
  189. A plain delete command would remove the security info in
  190. ``~/.config/borg/security``, including the nonce value. In BorgBackup
  191. :ref:`security_encryption` is AES-CTR, where the nonce is a counter. When the
  192. working repo was used later for creating new archives, Borg would re-use nonce
  193. values due to starting from a lower counter value given by the older copy of the
  194. repository. To prevent this, the ``keep-security-info`` option is applied so
  195. that the client-side nonce counter is kept.
  196. Can Borg add redundancy to the backup data to deal with hardware malfunction?
  197. -----------------------------------------------------------------------------
  198. No, it can't. While that at first sounds like a good idea to defend against
  199. some defect HDD sectors or SSD flash blocks, dealing with this in a
  200. reliable way needs a lot of low-level storage layout information and
  201. control which we do not have (and also can't get, even if we wanted).
  202. So, if you need that, consider RAID or a filesystem that offers redundant
  203. storage or just make backups to different locations / different hardware.
  204. See also :issue:`225`.
  205. Can Borg verify data integrity of a backup archive?
  206. ---------------------------------------------------
  207. Yes, if you want to detect accidental data damage (like bit rot), use the
  208. ``check`` operation. It will notice corruption using CRCs and hashes.
  209. If you want to be able to detect malicious tampering also, use an encrypted
  210. repo. It will then be able to check using CRCs and HMACs.
  211. Can I use Borg on SMR hard drives?
  212. ----------------------------------
  213. SMR (shingled magnetic recording) hard drives are very different from
  214. regular hard drives. Applications have to behave in certain ways or
  215. performance will be heavily degraded.
  216. Borg 1.1 ships with default settings suitable for SMR drives,
  217. and has been successfully tested on *Seagate Archive v2* drives
  218. using the ext4 file system.
  219. Some Linux kernel versions between 3.19 and 4.5 had various bugs
  220. handling device-managed SMR drives, leading to IO errors, unresponsive
  221. drives and unreliable operation in general.
  222. For more details, refer to :issue:`2252`.
  223. .. _faq-integrityerror:
  224. I get an IntegrityError or similar - what now?
  225. ----------------------------------------------
  226. A single error does not necessarily indicate bad hardware or a Borg
  227. bug. All hardware exhibits a bit error rate (BER). Hard drives are typically
  228. specified as exhibiting fewer than one error every 12 to 120 TB
  229. (one bit error in 10e14 to 10e15 bits). The specification is often called
  230. *unrecoverable read error rate* (URE rate).
  231. Apart from these very rare errors there are two main causes of errors:
  232. (i) Defective hardware: described below.
  233. (ii) Bugs in software (Borg, operating system, libraries):
  234. Ensure software is up to date.
  235. Check whether the issue is caused by any fixed bugs described in
  236. :ref:`important_notes`.
  237. .. rubric:: Finding defective hardware
  238. .. note::
  239. Hardware diagnostics are operating system dependent and do not
  240. apply universally. The commands shown apply for popular Unix-like
  241. systems. Refer to your operating system's manual.
  242. Checking hard drives
  243. Find the drive containing the repository and use *findmnt*, *mount* or *lsblk*
  244. to learn the device path (typically */dev/...*) of the drive.
  245. Then, smartmontools can retrieve self-diagnostics of the drive in question::
  246. # smartctl -a /dev/sdSomething
  247. The *Offline_Uncorrectable*, *Current_Pending_Sector* and *Reported_Uncorrect*
  248. attributes indicate data corruption. A high *UDMA_CRC_Error_Count* usually
  249. indicates a bad cable.
  250. I/O errors logged by the system (refer to the system journal or
  251. dmesg) can point to issues as well. I/O errors only affecting the
  252. file system easily go unnoticed, since they are not reported to
  253. applications (e.g. Borg), while these errors can still corrupt data.
  254. Drives can corrupt some sectors in one event, while remaining
  255. reliable otherwise. Conversely, drives can fail completely with no
  256. advance warning. If in doubt, copy all data from the drive in
  257. question to another drive -- just in case it fails completely.
  258. If any of these are suspicious, a self-test is recommended::
  259. # smartctl -t long /dev/sdSomething
  260. Running ``fsck`` if not done already might yield further insights.
  261. Checking memory
  262. Intermittent issues, such as ``borg check`` finding errors
  263. inconsistently between runs, are frequently caused by bad memory.
  264. Run memtest86+ (or an equivalent memory tester) to verify that
  265. the memory subsystem is operating correctly.
  266. Checking processors
  267. Processors rarely cause errors. If they do, they are usually overclocked
  268. or otherwise operated outside their specifications. We do not recommend to
  269. operate hardware outside its specifications for productive use.
  270. Tools to verify correct processor operation include Prime95 (mprime), linpack,
  271. and the `Intel Processor Diagnostic Tool
  272. <https://downloadcenter.intel.com/download/19792/Intel-Processor-Diagnostic-Tool>`_
  273. (applies only to Intel processors).
  274. .. rubric:: Repairing a damaged repository
  275. With any defective hardware found and replaced, the damage done to the repository
  276. needs to be ascertained and fixed.
  277. :ref:`borg_check` provides diagnostics and ``--repair`` options for repositories with
  278. issues. We recommend to first run without ``--repair`` to assess the situation.
  279. If the found issues and proposed repairs seem right, re-run "check" with ``--repair`` enabled.
  280. How probable is it to get a hash collision problem?
  281. ---------------------------------------------------
  282. If you noticed, there are some issues (:issue:`170` (**warning: hell**) and :issue:`4884`)
  283. about the probability of a chunk having the same hash as another chunk, making the file
  284. corrupted because it grabbed the wrong chunk. This is called the `Birthday Problem
  285. <https://en.wikipedia.org/wiki/Birthday_problem>`_.
  286. There is a lot of probability in here so, I can give you my interpretation of
  287. such math but it's honestly better that you read it yourself and grab your own
  288. resolution from that.
  289. Assuming that all your chunks have a size of :math:`2^{21}` bytes (approximately 2.1 MB)
  290. and we have a "perfect" hash algorithm, we can think that the probability of collision
  291. would be of :math:`p^2/2^{n+1}` then, using SHA-256 (:math:`n=256`) and for example
  292. we have 1000 million chunks (:math:`p=10^9`) (1000 million chunks would be about 2100TB).
  293. The probability would be around to 0.0000000000000000000000000000000000000000000000000000000000043.
  294. A mass-murderer space rock happens about once every 30 million years on average.
  295. This leads to a probability of such an event occurring in the next second to about :math:`10^{-15}`.
  296. That's **45** orders of magnitude more probable than the SHA-256 collision. Briefly stated,
  297. if you find SHA-256 collisions scary then your priorities are wrong. This example was grabbed from
  298. `this SO answer <https://stackoverflow.com/a/4014407/13359375>`_, it's great honestly.
  299. Still, the real question is if Borg tries to not make this happen?
  300. Well... it used to not check anything but there was a feature added which saves the size
  301. of the chunks too, so the size of the chunks is compared to the size that you got with the
  302. hash and if the check says there is a mismatch it will raise an exception instead of corrupting
  303. the file. This doesn't save us from everything but reduces the chances of corruption.
  304. There are other ways of trying to escape this but it would affect performance so much that
  305. it wouldn't be worth it and it would contradict Borg's design, so if you don't want this to
  306. happen, simply don't use Borg.
  307. Why is the time elapsed in the archive stats different from wall clock time?
  308. ----------------------------------------------------------------------------
  309. Borg needs to write the time elapsed into the archive metadata before finalizing
  310. the archive, compacting the segments, and committing the repo & cache. This means
  311. when Borg is run with e.g. the ``time`` command, the duration shown in the archive
  312. stats may be shorter than the full time the command runs for.
  313. How do I configure different prune policies for different directories?
  314. ----------------------------------------------------------------------
  315. Say you want to prune ``/var/log`` faster than the rest of
  316. ``/``. How do we implement that? The answer is to backup to different
  317. archive *names* and then implement different prune policies for
  318. different prefixes. For example, you could have a script that does::
  319. borg create --exclude /var/log $REPOSITORY:main-$(date +%Y-%m-%d) /
  320. borg create $REPOSITORY:logs-$(date +%Y-%m-%d) /var/log
  321. Then you would have two different prune calls with different policies::
  322. borg prune --verbose --list -d 30 --prefix main- "$REPOSITORY"
  323. borg prune --verbose --list -d 7 --prefix logs- "$REPOSITORY"
  324. This will keep 7 days of logs and 30 days of everything else. Borg 1.1
  325. also supports the ``--glob-archives`` parameter.
  326. How do I remove files from an existing backup?
  327. ----------------------------------------------
  328. A file is only removed from a BorgBackup repository if all archives that contain
  329. the file are deleted and the corresponding data chunks are removed from the
  330. repository There are two ways how to remove files from a repository.
  331. 1. Use :ref:`borg_delete` to remove all archives that contain the files. This
  332. will of course delete everything in the archive, not only some files.
  333. 2. If you really want to remove only some specific files, you can run the
  334. :ref:`borg_recreate` command to rewrite all archives with a different
  335. ``--exclude`` pattern. See the examples in the manpage for more information.
  336. Finally, run :ref:`borg_compact` with the ``--threshold 0`` option to delete the
  337. data chunks from the repository.
  338. Can I safely change the compression level or algorithm?
  339. --------------------------------------------------------
  340. The compression level and algorithm don't affect deduplication. Chunk ID hashes
  341. are calculated *before* compression. New compression settings
  342. will only be applied to new chunks, not existing chunks. So it's safe
  343. to change them.
  344. Security
  345. ########
  346. .. _borg_security_critique:
  347. Isn't BorgBackup's AES-CTR crypto broken?
  348. -----------------------------------------
  349. If a nonce (counter) value is reused, AES-CTR mode crypto is broken.
  350. To exploit the AES counter management issue, an attacker would need to have
  351. access to the borg repository.
  352. By tampering with the repo, the attacker could bring the repo into a state so
  353. that it reports a lower "highest used counter value" than the one that actually
  354. was used. The client would usually notice that, because it rather trusts the
  355. clientside stored "highest used counter value" than trusting the server.
  356. But there are situations, where this is simply not possible:
  357. - If clients A and B used the repo, the client A can only know its own highest
  358. CTR value, but not the one produced by B. That is only known to (B and) the
  359. server (the repo) and thus the client A needs to trust the server about the
  360. value produced by B in that situation. You can't do much about this except
  361. not having multiple clients per repo.
  362. - Even if there is only one client, if client-side information is completely
  363. lost (e.g. due to disk defect), the client also needs to trust the value from
  364. server side. You can avoid this by not continuing to write to the repository
  365. after you have lost clientside borg information.
  366. .. _home_config_borg:
  367. How important is the $HOME/.config/borg directory?
  368. --------------------------------------------------
  369. The Borg config directory has content that you should take care of:
  370. ``security`` subdirectory
  371. Each directory here represents one Borg repository by its ID and contains the last known status.
  372. If a repository's status is different from this information at the beginning of BorgBackup
  373. operation, Borg outputs warning messages and asks for confirmation, so make sure you do not lose
  374. or manipulate these files. However, apart from those warnings, a loss of these files can be
  375. recovered.
  376. ``keys`` subdirectory
  377. All your borg keyfile keys are stored in this directory. Please note that
  378. borg repokey keys are stored inside the repository. You MUST make sure to have an
  379. independent backup of these keyfiles, otherwise you cannot access your backups anymore if you lose
  380. them. You also MUST keep these files secret; everyone who gains access to your repository and has
  381. the corresponding keyfile (and the key passphrase) can extract it.
  382. Make sure that only you have access to the Borg config directory.
  383. .. _cache_security:
  384. Do I need to take security precautions regarding the cache?
  385. -----------------------------------------------------------
  386. The cache contains a lot of metadata information about the files in
  387. your repositories and it is not encrypted.
  388. However, the assumption is that the cache is being stored on the very
  389. same system which also contains the original files which are being
  390. backed up. So someone with access to the cache files would also have
  391. access the original files anyway.
  392. The Internals section contains more details about :ref:`cache`. If you ever need to move the cache
  393. to a different location, this can be achieved by using the appropriate :ref:`env_vars`.
  394. How can I specify the encryption passphrase programmatically?
  395. -------------------------------------------------------------
  396. There are several ways to specify a passphrase without human intervention:
  397. Setting ``BORG_PASSPHRASE``
  398. The passphrase can be specified using the ``BORG_PASSPHRASE`` environment variable.
  399. This is often the simplest option, but can be insecure if the script that sets it
  400. is world-readable.
  401. .. _password_env:
  402. .. note:: Be careful how you set the environment; using the ``env``
  403. command, a ``system()`` call or using inline shell scripts
  404. (e.g. ``BORG_PASSPHRASE=hunter2 borg ...``)
  405. might expose the credentials in the process list directly
  406. and they will be readable to all users on a system. Using
  407. ``export`` in a shell script file should be safe, however, as
  408. the environment of a process is `accessible only to that
  409. user
  410. <https://security.stackexchange.com/questions/14000/environment-variable-accessibility-in-linux/14009#14009>`_.
  411. Using ``BORG_PASSCOMMAND`` with a properly permissioned file
  412. Another option is to create a file with a password in it in your home
  413. directory and use permissions to keep anyone else from reading it. For
  414. example, first create a key::
  415. head -c 32 /dev/urandom | base64 -w 0 > ~/.borg-passphrase
  416. chmod 400 ~/.borg-passphrase
  417. Then in an automated script one can put::
  418. export BORG_PASSCOMMAND="cat $HOME/.borg-passphrase"
  419. and Borg will automatically use that passphrase.
  420. Using keyfile-based encryption with a blank passphrase
  421. It is possible to encrypt your repository in ``keyfile`` mode instead of the default
  422. ``repokey`` mode and use a blank passphrase for the key file (simply press Enter twice
  423. when ``borg init`` asks for the password). See :ref:`encrypted_repos`
  424. for more details.
  425. Using ``BORG_PASSCOMMAND`` with macOS Keychain
  426. macOS has a native manager for secrets (such as passphrases) which is safer
  427. than just using a file as it is encrypted at rest and unlocked manually
  428. (fortunately, the login keyring automatically unlocks when you login). With
  429. the built-in ``security`` command, you can access it from the command line,
  430. making it useful for ``BORG_PASSCOMMAND``.
  431. First generate a passphrase and use ``security`` to save it to your login
  432. (default) keychain::
  433. security add-generic-password -D secret -U -a $USER -s borg-passphrase -w $(head -c 32 /dev/urandom | base64 -w 0)
  434. In your backup script retrieve it in the ``BORG_PASSCOMMAND``::
  435. export BORG_PASSCOMMAND="security find-generic-password -a $USER -s borg-passphrase -w"
  436. Using ``BORG_PASSCOMMAND`` with GNOME Keyring
  437. GNOME also has a keyring daemon that can be used to store a Borg passphrase.
  438. First ensure ``libsecret-tools``, ``gnome-keyring`` and ``libpam-gnome-keyring``
  439. are installed. If ``libpam-gnome-keyring`` wasn't already installed, ensure it
  440. runs on login::
  441. sudo sh -c "echo session optional pam_gnome_keyring.so auto_start >> /etc/pam.d/login"
  442. sudo sh -c "echo password optional pam_gnome_keyring.so >> /etc/pam.d/passwd"
  443. # you may need to relogin afterwards to activate the login keyring
  444. Then add a secret to the login keyring::
  445. head -c 32 /dev/urandom | base64 -w 0 | secret-tool store borg-repository repo-name --label="Borg Passphrase"
  446. If a dialog box pops up prompting you to pick a password for a new keychain, use your
  447. login password. If there is a checkbox for automatically unlocking on login, check it
  448. to allow backups without any user intervention whatsoever.
  449. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  450. export BORG_PASSCOMMAND="secret-tool lookup borg-repository repo-name"
  451. .. note:: For this to automatically unlock the keychain it must be run
  452. in the ``dbus`` session of an unlocked terminal; for example, running a backup
  453. script as a ``cron`` job might not work unless you also ``export DISPLAY=:0``
  454. so ``secret-tool`` can pick up your open session. `It gets even more complicated`__
  455. when you are running the tool as a different user (e.g. running a backup as root
  456. with the password stored in the user keyring).
  457. __ https://github.com/borgbackup/borg/pull/2837#discussion_r127641330
  458. Using ``BORG_PASSCOMMAND`` with KWallet
  459. KDE also has a keychain feature in the form of KWallet. The command-line tool
  460. ``kwalletcli`` can be used to store and retrieve secrets. Ensure ``kwalletcli``
  461. is installed, generate a passphrase, and store it in your "wallet"::
  462. head -c 32 /dev/urandom | base64 -w 0 | kwalletcli -Pe borg-passphrase -f Passwords
  463. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  464. export BORG_PASSCOMMAND="kwalletcli -e borg-passphrase -f Passwords"
  465. When backing up to remote encrypted repos, is encryption done locally?
  466. ----------------------------------------------------------------------
  467. Yes, file and directory metadata and data is locally encrypted, before
  468. leaving the local machine. We do not mean the transport layer encryption
  469. by that, but the data/metadata itself. Transport layer encryption (e.g.
  470. when ssh is used as a transport) applies additionally.
  471. When backing up to remote servers, do I have to trust the remote server?
  472. ------------------------------------------------------------------------
  473. Yes and No.
  474. No, as far as data confidentiality is concerned - if you use encryption,
  475. all your files/dirs data and metadata are stored in their encrypted form
  476. into the repository.
  477. Yes, as an attacker with access to the remote server could delete (or
  478. otherwise make unavailable) all your backups.
  479. How can I protect against a hacked backup client?
  480. -------------------------------------------------
  481. Assume you backup your backup client machine C to the backup server S and
  482. C gets hacked. In a simple push setup, the attacker could then use borg on
  483. C to delete all backups residing on S.
  484. These are your options to protect against that:
  485. - Do not allow to permanently delete data from the repo, see :ref:`append_only_mode`.
  486. - Use a pull-mode setup using ``ssh -R``, see :ref:`pull_backup` for more information.
  487. - Mount C's filesystem on another machine and then create a backup of it.
  488. - Do not give C filesystem-level access to S.
  489. See :ref:`hosting_repositories` for a detailed protection guide.
  490. How can I protect against a hacked backup server?
  491. -------------------------------------------------
  492. Just in case you got the impression that pull-mode backups are way more safe
  493. than push-mode, you also need to consider the case that your backup server S
  494. gets hacked. In case S has access to a lot of clients C, that might bring you
  495. into even bigger trouble than a hacked backup client in the previous FAQ entry.
  496. These are your options to protect against that:
  497. - Use the standard push-mode setup (see also previous FAQ entry).
  498. - Mount (the repo part of) S's filesystem on C.
  499. - Do not give S file-system level access to C.
  500. - Have your backup server at a well protected place (maybe not reachable from
  501. the internet), configure it safely, apply security updates, monitor it, ...
  502. How can I protect against theft, sabotage, lightning, fire, ...?
  503. ----------------------------------------------------------------
  504. In general: if your only backup medium is nearby the backupped machine and
  505. always connected, you can easily get into trouble: they likely share the same
  506. fate if something goes really wrong.
  507. Thus:
  508. - have multiple backup media
  509. - have media disconnected from network, power, computer
  510. - have media at another place
  511. - have a relatively recent backup on your media
  512. How do I report a security issue with Borg?
  513. -------------------------------------------
  514. Send a private email to the :ref:`security contact <security-contact>`
  515. if you think you have discovered a security issue.
  516. Please disclose security issues responsibly.
  517. How important are the nonce files?
  518. ------------------------------------
  519. Borg uses :ref:`AES-CTR encryption <borg_security_critique>`. An
  520. essential part of AES-CTR is a sequential counter that must **never**
  521. repeat. If the same value of the counter is used twice in the same repository,
  522. an attacker can decrypt the data. The counter is stored in the home directory
  523. of each user ($HOME/.config/borg/security/$REPO_ID/nonce) as well as
  524. in the repository (/path/to/repo/nonce). When creating a new archive borg uses
  525. the highest of the two values. The value of the counter in the repository may be
  526. higher than your local value if another user has created an archive more recently
  527. than you did.
  528. Since the nonce is not necessary to read the data that is already encrypted,
  529. ``borg info``, ``borg list``, ``borg extract`` and ``borg mount`` should work
  530. just fine without it.
  531. If the the nonce file stored in the repo is lost, but you still have your local copy,
  532. borg will recreate the repository nonce file the next time you run ``borg create``.
  533. This should be safe for repositories that are only used from one user account
  534. on one machine.
  535. For repositories that are used by multiple users and/or from multiple machines
  536. it is safest to avoid running *any* commands that modify the repository after
  537. the nonce is deleted or if you suspect it may have been tampered with. See :ref:`attack_model`.
  538. Common issues
  539. #############
  540. Why does Borg extract hang after some time?
  541. -------------------------------------------
  542. When I do a ``borg extract``, after a while all activity stops, no cpu usage,
  543. no downloads.
  544. This may happen when the SSH connection is stuck on server side. You can
  545. configure SSH on client side to prevent this by sending keep-alive requests,
  546. for example in ~/.ssh/config:
  547. ::
  548. Host borg.example.com
  549. # Client kills connection after 3*30 seconds without server response:
  550. ServerAliveInterval 30
  551. ServerAliveCountMax 3
  552. You can also do the opposite and configure SSH on server side in
  553. /etc/ssh/sshd_config, to make the server send keep-alive requests to the client:
  554. ::
  555. # Server kills connection after 3*30 seconds without client response:
  556. ClientAliveInterval 30
  557. ClientAliveCountMax 3
  558. How can I deal with my very unstable SSH connection?
  559. ----------------------------------------------------
  560. If you have issues with lost connections during long-running borg commands, you
  561. could try to work around:
  562. - Make partial extracts like ``borg extract REPO PATTERN`` to do multiple
  563. smaller extraction runs that complete before your connection has issues.
  564. - Try using ``borg mount REPO MOUNTPOINT`` and ``rsync -avH`` from
  565. ``MOUNTPOINT`` to your desired extraction directory. If the connection breaks
  566. down, just repeat that over and over again until rsync does not find anything
  567. to do any more. Due to the way borg mount works, this might be less efficient
  568. than borg extract for bigger volumes of data.
  569. Why do I get "connection closed by remote" after a while?
  570. ---------------------------------------------------------
  571. When doing a backup to a remote server (using a ssh: repo URL), it sometimes
  572. stops after a while (some minutes, hours, ... - not immediately) with
  573. "connection closed by remote" error message. Why?
  574. That's a good question and we are trying to find a good answer in :issue:`636`.
  575. Why am I seeing idle borg serve processes on the repo server?
  576. -------------------------------------------------------------
  577. Maybe the ssh connection between client and server broke down and that was not
  578. yet noticed on the server. Try these settings:
  579. ::
  580. # /etc/ssh/sshd_config on borg repo server - kill connection to client
  581. # after ClientAliveCountMax * ClientAliveInterval seconds with no response
  582. ClientAliveInterval 20
  583. ClientAliveCountMax 3
  584. If you have multiple borg create ... ; borg create ... commands in a already
  585. serialized way in a single script, you need to give them ``--lock-wait N`` (with N
  586. being a bit more than the time the server needs to terminate broken down
  587. connections and release the lock).
  588. .. _disable_archive_chunks:
  589. The borg cache eats way too much disk space, what can I do?
  590. -----------------------------------------------------------
  591. This may especially happen if borg needs to rebuild the local "chunks" index -
  592. either because it was removed, or because it was not coherent with the
  593. repository state any more (e.g. because another borg instance changed the
  594. repository).
  595. To optimize this rebuild process, borg caches per-archive information in the
  596. ``chunks.archive.d/`` directory. It won't help the first time it happens, but it
  597. will make the subsequent rebuilds faster (because it needs to transfer less data
  598. from the repository). While being faster, the cache needs quite some disk space,
  599. which might be unwanted.
  600. There is a temporary (but maybe long lived) hack to avoid using lots of disk
  601. space for chunks.archive.d (see :issue:`235` for details):
  602. ::
  603. # this assumes you are working with the same user as the backup.
  604. cd ~/.cache/borg/$(borg config /path/to/repo id)
  605. rm -rf chunks.archive.d ; touch chunks.archive.d
  606. This deletes all the cached archive chunk indexes and replaces the directory
  607. that kept them with a file, so borg won't be able to store anything "in" there
  608. in future.
  609. This has some pros and cons, though:
  610. - much less disk space needs for ~/.cache/borg.
  611. - chunk cache resyncs will be slower as it will have to transfer chunk usage
  612. metadata for all archives from the repository (which might be slow if your
  613. repo connection is slow) and it will also have to build the hashtables from
  614. that data.
  615. chunk cache resyncs happen e.g. if your repo was written to by another
  616. machine (if you share same backup repo between multiple machines) or if
  617. your local chunks cache was lost somehow.
  618. The long term plan to improve this is called "borgception", see :issue:`474`.
  619. Can I backup my root partition (/) with Borg?
  620. ---------------------------------------------
  621. Backing up your entire root partition works just fine, but remember to
  622. exclude directories that make no sense to backup, such as /dev, /proc,
  623. /sys, /tmp and /run, and to use ``--one-file-system`` if you only want to
  624. backup the root partition (and not any mounted devices e.g.).
  625. If it crashes with a UnicodeError, what can I do?
  626. -------------------------------------------------
  627. Check if your encoding is set correctly. For most POSIX-like systems, try::
  628. export LANG=en_US.UTF-8 # or similar, important is correct charset
  629. I can't extract non-ascii filenames by giving them on the commandline!?
  630. -----------------------------------------------------------------------
  631. This might be due to different ways to represent some characters in unicode
  632. or due to other non-ascii encoding issues.
  633. If you run into that, try this:
  634. - avoid the non-ascii characters on the commandline by e.g. extracting
  635. the parent directory (or even everything)
  636. - mount the repo using FUSE and use some file manager
  637. .. _expected_performance:
  638. What's the expected backup performance?
  639. ---------------------------------------
  640. Compared to simply copying files (e.g. with ``rsync``), Borg has more work to do.
  641. This can make creation of the first archive slower, but saves time
  642. and disk space on subsequent runs. Here what Borg does when you run ``borg create``:
  643. - Borg chunks the file (using the relatively expensive buzhash algorithm)
  644. - It then computes the "id" of the chunk (hmac-sha256 (often slow, except
  645. if your CPU has sha256 acceleration) or blake2b (fast, in software))
  646. - Then it checks whether this chunk is already in the repo (local hashtable lookup,
  647. fast). If so, the processing of the chunk is completed here. Otherwise it needs to
  648. process the chunk:
  649. - Compresses (the default lz4 is super fast)
  650. - Encrypts (AES, usually fast if your CPU has AES acceleration as usual
  651. since about 10y)
  652. - Authenticates ("signs") using hmac-sha256 or blake2b (see above),
  653. - Transmits to repo. If the repo is remote, this usually involves an SSH connection
  654. (does its own encryption / authentication).
  655. - Stores the chunk into a key/value store (the key is the chunk id, the value
  656. is the data). While doing that, it computes a CRC32 of the data (repo low-level
  657. checksum, used by borg check --repository) and also updates the repo index
  658. (another hashtable).
  659. Subsequent backups are usually very fast if most files are unchanged and only
  660. a few are new or modified. The high performance on unchanged files primarily depends
  661. only on a few factors (like FS recursion + metadata reading performance and the
  662. files cache working as expected) and much less on other factors.
  663. E.g., for this setup:
  664. - server grade machine (4C/8T 2013 Xeon, 64GB RAM, 2x good 7200RPM disks)
  665. - local zfs filesystem (mirrored) containing the backup source data
  666. - repository is remote (does not matter much for unchanged files)
  667. - backup job runs while machine is otherwise idle
  668. The observed performance is that Borg can process about
  669. **1 million unchanged files (and a few small changed ones) in 4 minutes!**
  670. If you are seeing much less than that in similar circumstances, read the next
  671. few FAQ entries below.
  672. .. _slow_backup:
  673. Why is my backup so slow?
  674. --------------------------
  675. If you feel your Borg backup is too slow somehow, here is what you can do:
  676. - Make sure Borg has enough RAM (depends on how big your repo is / how many
  677. files you have)
  678. - Use one of the blake2 modes for --encryption except if you positively know
  679. your CPU (and openssl) accelerates sha256 (then stay with hmac-sha256).
  680. - Don't use any expensive compression. The default is lz4 and super fast.
  681. Uncompressed is often slower than lz4.
  682. - Just wait. You can also interrupt it and start it again as often as you like,
  683. it will converge against a valid "completed" state (see ``--checkpoint-interval``,
  684. maybe use the default, but in any case don't make it too short). It is starting
  685. from the beginning each time, but it is still faster then as it does not store
  686. data into the repo which it already has there from last checkpoint.
  687. - If you don’t need additional file attributes, you can disable them with ``--noflags``,
  688. ``--noacls``, ``--noxattrs``. This can lead to noticable performance improvements
  689. when your backup consists of many small files.
  690. If you feel that Borg "freezes" on a file, it could be in the middle of processing a
  691. large file (like ISOs or VM images). Borg < 1.2 announces file names *after* finishing
  692. with the file. This can lead to displaying the name of a small file, while processing the
  693. next (larger) file. For very big files this can lead to the progress display show some
  694. previous short file for a long time while it processes the big one. With Borg 1.2 this
  695. was changed to announcing the filename before starting to process it.
  696. To see what files have changed and take more time processing, you can also add
  697. ``--list --filter=AME --stats`` to your ``borg create`` call to produce more log output,
  698. including a file list (with file status characters) and also some statistics at
  699. the end of the backup.
  700. Then you do the backup and look at the log output:
  701. - stats: Do you really have little changes or are there more changes than you thought?
  702. In the stats you can see the overall volume of changed data, which needed to be
  703. added to the repo. If that is a lot, that can be the reason why it is slow.
  704. - ``A`` status ("added") in the file list:
  705. If you see that often, you have a lot of new files (files that Borg did not find
  706. in the files cache). If you think there is something wrong with that (the file was there
  707. already in the previous backup), please read the FAQ entries below.
  708. - ``M`` status ("modified") in the file list:
  709. If you see that often, Borg thinks that a lot of your files might be modified
  710. (Borg found them in the files cache, but the metadata read from the filesystem did
  711. not match the metadata stored in the files cache).
  712. In such a case, Borg will need to process the files' contents completely, which is
  713. much slower than processing unmodified files (Borg does not read their contents!).
  714. The metadata values used in this comparison are determined by the ``--files-cache`` option
  715. and could be e.g. size, ctime and inode number (see the ``borg create`` docs for more
  716. details and potential issues).
  717. You can use the ``stat`` command on files to manually look at fs metadata to debug if
  718. there is any unexpected change triggering the ``M`` status.
  719. See also the next few FAQ entries for more details.
  720. .. _a_status_oddity:
  721. I am seeing 'A' (added) status for an unchanged file!?
  722. ------------------------------------------------------
  723. The files cache is used to determine whether Borg already
  724. "knows" / has backed up a file and if so, to skip the file from
  725. chunking. It intentionally *excludes* files that have a timestamp
  726. which is the same as the newest timestamp in the created archive.
  727. So, if you see an 'A' status for unchanged file(s), they are likely the files
  728. with the most recent timestamp in that archive.
  729. This is expected: it is to avoid data loss with files that are backed up from
  730. a snapshot and that are immediately changed after the snapshot (but within
  731. timestamp granularity time, so the timestamp would not change). Without the code that
  732. removes these files from the files cache, the change that happened right after
  733. the snapshot would not be contained in the next backup as Borg would
  734. think the file is unchanged.
  735. This does not affect deduplication, the file will be chunked, but as the chunks
  736. will often be the same and already stored in the repo (except in the above
  737. mentioned rare condition), it will just re-use them as usual and not store new
  738. data chunks.
  739. If you want to avoid unnecessary chunking, just create or touch a small or
  740. empty file in your backup source file set (so that one has the latest timestamp,
  741. not your 50GB VM disk image) and, if you do snapshots, do the snapshot after
  742. that.
  743. Since only the files cache is used in the display of files status,
  744. those files are reported as being added when, really, chunks are
  745. already used.
  746. By default, ctime (change time) is used for the timestamps to have a rather
  747. safe change detection (see also the --files-cache option).
  748. Furthermore, pathnames recorded in files cache are always absolute, even if you
  749. specify source directories with relative pathname. If relative pathnames are
  750. stable, but absolute are not (for example if you mount a filesystem without
  751. stable mount points for each backup or if you are running the backup from a
  752. filesystem snapshot whose name is not stable), borg will assume that files are
  753. different and will report them as 'added', even though no new chunks will be
  754. actually recorded for them. To avoid this, you could bind mount your source
  755. directory in a directory with the stable path.
  756. .. _always_chunking:
  757. It always chunks all my files, even unchanged ones!
  758. ---------------------------------------------------
  759. Borg maintains a files cache where it remembers the timestamp, size and
  760. inode of files. When Borg does a new backup and starts processing a
  761. file, it first looks whether the file has changed (compared to the values
  762. stored in the files cache). If the values are the same, the file is assumed
  763. unchanged and thus its contents won't get chunked (again).
  764. Borg can't keep an infinite history of files of course, thus entries
  765. in the files cache have a "maximum time to live" which is set via the
  766. environment variable BORG_FILES_CACHE_TTL (and defaults to 20).
  767. Every time you do a backup (on the same machine, using the same user), the
  768. cache entries' ttl values of files that were not "seen" are incremented by 1
  769. and if they reach BORG_FILES_CACHE_TTL, the entry is removed from the cache.
  770. So, for example, if you do daily backups of 26 different data sets A, B,
  771. C, ..., Z on one machine (using the default TTL), the files from A will be
  772. already forgotten when you repeat the same backups on the next day and it
  773. will be slow because it would chunk all the files each time. If you set
  774. BORG_FILES_CACHE_TTL to at least 26 (or maybe even a small multiple of that),
  775. it would be much faster.
  776. Another possible reason is that files don't always have the same path, for
  777. example if you mount a filesystem without stable mount points for each backup
  778. or if you are running the backup from a filesystem snapshot whose name is not
  779. stable. If the directory where you mount a filesystem is different every time,
  780. Borg assumes they are different files. This is true even if you backup these
  781. files with relative pathnames - borg uses full pathnames in files cache regardless.
  782. It is possible for some filesystems, such as ``mergerfs`` or network filesystems,
  783. to return inconsistent inode numbers across runs, causing borg to consider them changed.
  784. A workaround is to set the option ``--files-cache=ctime,size`` to exclude the inode
  785. number comparison from the files cache check so that files with different inode
  786. numbers won't be treated as modified.
  787. Is there a way to limit bandwidth with Borg?
  788. --------------------------------------------
  789. To limit upload (i.e. :ref:`borg_create`) bandwidth, use the
  790. ``--remote-ratelimit`` option.
  791. There is no built-in way to limit *download*
  792. (i.e. :ref:`borg_extract`) bandwidth, but limiting download bandwidth
  793. can be accomplished with pipeviewer_:
  794. Create a wrapper script: /usr/local/bin/pv-wrapper
  795. ::
  796. #!/bin/sh
  797. ## -q, --quiet do not output any transfer information at all
  798. ## -L, --rate-limit RATE limit transfer to RATE bytes per second
  799. RATE=307200
  800. pv -q -L $RATE | "$@"
  801. Add BORG_RSH environment variable to use pipeviewer wrapper script with ssh.
  802. ::
  803. export BORG_RSH='/usr/local/bin/pv-wrapper ssh'
  804. Now Borg will be bandwidth limited. The nice thing about ``pv`` is that you can
  805. change rate-limit on the fly:
  806. ::
  807. pv -R $(pidof pv) -L 102400
  808. .. _pipeviewer: http://www.ivarch.com/programs/pv.shtml
  809. How can I avoid unwanted base directories getting stored into archives?
  810. -----------------------------------------------------------------------
  811. Possible use cases:
  812. - Another file system is mounted and you want to backup it with original paths.
  813. - You have created a BTRFS snapshot in a ``/.snapshots`` directory for backup.
  814. To achieve this, run ``borg create`` within the mountpoint/snapshot directory:
  815. ::
  816. # Example: Some file system mounted in /mnt/rootfs.
  817. cd /mnt/rootfs
  818. borg create /path/to/repo::rootfs_backup .
  819. I am having troubles with some network/FUSE/special filesystem, why?
  820. --------------------------------------------------------------------
  821. Borg is doing nothing special in the filesystem, it only uses very
  822. common and compatible operations (even the locking is just "rename").
  823. So, if you are encountering issues like slowness, corruption or malfunction
  824. when using a specific filesystem, please try if you can reproduce the issues
  825. with a local (non-network) and proven filesystem (like ext4 on Linux).
  826. If you can't reproduce the issue then, you maybe have found an issue within
  827. the filesystem code you used (not with Borg). For this case, it is
  828. recommended that you talk to the developers / support of the network fs and
  829. maybe open an issue in their issue tracker. Do not file an issue in the
  830. Borg issue tracker.
  831. If you can reproduce the issue with the proven filesystem, please file an
  832. issue in the Borg issue tracker about that.
  833. Why does running 'borg check --repair' warn about data loss?
  834. ------------------------------------------------------------
  835. Repair usually works for recovering data in a corrupted archive. However,
  836. it's impossible to predict all modes of corruption. In some very rare
  837. instances, such as malfunctioning storage hardware, additional repo
  838. corruption may occur. If you can't afford to lose the repo, it's strongly
  839. recommended that you perform repair on a copy of the repo.
  840. In other words, the warning is there to emphasize that Borg:
  841. - Will perform automated routines that modify your backup repository
  842. - Might not actually fix the problem you are experiencing
  843. - Might, in very rare cases, further corrupt your repository
  844. In the case of malfunctioning hardware, such as a drive or USB hub
  845. corrupting data when read or written, it's best to diagnose and fix the
  846. cause of the initial corruption before attempting to repair the repo. If
  847. the corruption is caused by a one time event such as a power outage,
  848. running `borg check --repair` will fix most problems.
  849. Why isn't there more progress / ETA information displayed?
  850. ----------------------------------------------------------
  851. Some borg runs take quite a bit, so it would be nice to see a progress display,
  852. maybe even including a ETA (expected time of "arrival" [here rather "completion"]).
  853. For some functionality, this can be done: if the total amount of work is more or
  854. less known, we can display progress. So check if there is a ``--progress`` option.
  855. But sometimes, the total amount is unknown (e.g. for ``borg create`` we just do
  856. a single pass over the filesystem, so we do not know the total file count or data
  857. volume before reaching the end). Adding another pass just to determine that would
  858. take additional time and could be incorrect, if the filesystem is changing.
  859. Even if the fs does not change and we knew count and size of all files, we still
  860. could not compute the ``borg create`` ETA as we do not know the amount of changed
  861. chunks, how the bandwidth of source and destination or system performance might
  862. fluctuate.
  863. You see, trying to display ETA would be futile. The borg developers prefer to
  864. rather not implement progress / ETA display than doing futile attempts.
  865. See also: https://xkcd.com/612/
  866. Why am I getting 'Operation not permitted' errors when backing up on sshfs?
  867. ---------------------------------------------------------------------------
  868. By default, ``sshfs`` is not entirely POSIX-compliant when renaming files due to
  869. a technicality in the SFTP protocol. Fortunately, it also provides a workaround_
  870. to make it behave correctly::
  871. sshfs -o workaround=rename user@host:dir /mnt/dir
  872. .. _workaround: https://unix.stackexchange.com/a/123236
  873. Can I disable checking for free disk space?
  874. -------------------------------------------
  875. In some cases, the free disk space of the target volume is reported incorrectly.
  876. This can happen for CIFS- or FUSE shares. If you are sure that your target volume
  877. will always have enough disk space, you can use the following workaround to disable
  878. checking for free disk space::
  879. borg config -- $REPO_LOCATION additional_free_space -2T
  880. How do I rename a repository?
  881. -----------------------------
  882. There is nothing special that needs to be done, you can simply rename the
  883. directory that corresponds to the repository. However, the next time borg
  884. interacts with the repository (i.e, via ``borg list``), depending on the value
  885. of ``BORG_RELOCATED_REPO_ACCESS_IS_OK``, borg may warn you that the repository
  886. has been moved. You will be given a prompt to confirm you are OK with this.
  887. If ``BORG_RELOCATED_REPO_ACCESS_IS_OK`` is unset, borg will interactively ask for
  888. each repository whether it's OK.
  889. It may be useful to set ``BORG_RELOCATED_REPO_ACCESS_IS_OK=yes`` to avoid the
  890. prompts when renaming multiple repositories or in a non-interactive context
  891. such as a script. See :doc:`deployment` for an example.
  892. Miscellaneous
  893. #############
  894. Requirements for the borg single-file binary, esp. (g)libc?
  895. -----------------------------------------------------------
  896. We try to build the binary on old, but still supported systems - to keep the
  897. minimum requirement for the (g)libc low. The (g)libc can't be bundled into
  898. the binary as it needs to fit your kernel and OS, but Python and all other
  899. required libraries will be bundled into the binary.
  900. If your system fulfills the minimum (g)libc requirement (see the README that
  901. is released with the binary), there should be no problem. If you are slightly
  902. below the required version, maybe just try. Due to the dynamic loading (or not
  903. loading) of some shared libraries, it might still work depending on what
  904. libraries are actually loaded and used.
  905. In the borg git repository, there is scripts/glibc_check.py that can determine
  906. (based on the symbols' versions they want to link to) whether a set of given
  907. (Linux) binaries works with a given glibc version.
  908. Why was Borg forked from Attic?
  909. -------------------------------
  910. Borg was created in May 2015 in response to the difficulty of getting new
  911. code or larger changes incorporated into Attic and establishing a bigger
  912. developer community / more open development.
  913. More details can be found in `ticket 217
  914. <https://github.com/jborg/attic/issues/217>`_ that led to the fork.
  915. Borg intends to be:
  916. * simple:
  917. * as simple as possible, but no simpler
  918. * do the right thing by default, but offer options
  919. * open:
  920. * welcome feature requests
  921. * accept pull requests of good quality and coding style
  922. * give feedback on PRs that can't be accepted "as is"
  923. * discuss openly, don't work in the dark
  924. * changing:
  925. * Borg is not compatible with Attic
  926. * do not break compatibility accidentally, without a good reason
  927. or without warning. allow compatibility breaking for other cases.
  928. * if major version number changes, it may have incompatible changes
  929. Migrating from Attic
  930. ####################
  931. What are the differences between Attic and Borg?
  932. ------------------------------------------------
  933. Borg is a fork of `Attic`_ and maintained by "`The Borg collective`_".
  934. .. _Attic: https://github.com/jborg/attic
  935. .. _The Borg collective: https://borgbackup.readthedocs.org/en/latest/authors.html
  936. Here's a (incomplete) list of some major changes:
  937. * lots of attic issues fixed
  938. (see `issue #5 <https://github.com/borgbackup/borg/issues/5>`_),
  939. including critical data corruption bugs and security issues.
  940. * more open, faster paced development
  941. (see `issue #1 <https://github.com/borgbackup/borg/issues/1>`_)
  942. * less chunk management overhead (less memory and disk usage for chunks index)
  943. * faster remote cache resync (useful when backing up multiple machines into same repo)
  944. * compression: no, lz4, zstd, zlib or lzma compression, adjustable compression levels
  945. * repokey replaces problematic passphrase mode (you can't change the passphrase
  946. nor the pbkdf2 iteration count in "passphrase" mode)
  947. * simple sparse file support, great for virtual machine disk files
  948. * can read special files (e.g. block devices) or from stdin, write to stdout
  949. * rename-based locking is more compatible than attic's posix locking
  950. * uses fadvise to not spoil / blow up the fs cache
  951. * better error messages / exception handling
  952. * better logging, screen output, progress indication
  953. * tested on misc. Linux systems, 32 and 64bit, FreeBSD, OpenBSD, NetBSD, macOS
  954. Please read the :ref:`changelog` (or ``docs/changes.rst`` in the source distribution) for more
  955. information.
  956. Borg is not compatible with original Attic (but there is a one-way conversion).
  957. How do I migrate from Attic to Borg?
  958. ------------------------------------
  959. Use :ref:`borg_upgrade`. This is a one-way process that cannot be reversed.
  960. There are some caveats:
  961. - The upgrade can only be performed on local repositories.
  962. It cannot be performed on remote repositories.
  963. - If the repository is in "keyfile" encryption mode, the keyfile must
  964. exist locally or it must be manually moved after performing the upgrade:
  965. 1. Get the repository ID with ``borg config /path/to/repo id``.
  966. 2. Locate the attic key file at ``~/.attic/keys/``. The correct key for the
  967. repository starts with the line ``ATTIC_KEY <repository id>``.
  968. 3. Copy the attic key file to ``~/.config/borg/keys/``
  969. 4. Change the first line from ``ATTIC_KEY ...`` to ``BORG_KEY ...``.
  970. 5. Verify that the repository is now accessible (e.g. ``borg list <repository>``).
  971. - Attic and Borg use different :ref:`"chunker params" <chunker-params>`.
  972. This means that data added by Borg won't deduplicate with the existing data
  973. stored by Attic. The effect is lessened if the files cache is used with Borg.
  974. - Repositories in "passphrase" mode *must* be migrated to "repokey" mode using
  975. "borg key migrate-to-repokey" (only available in borg <= 1.2.x). Borg does not
  976. support the "passphrase" mode in any other way.
  977. Why is my backup bigger than with attic?
  978. ----------------------------------------
  979. Attic was rather unflexible when it comes to compression, it always
  980. compressed using zlib level 6 (no way to switch compression off or
  981. adjust the level or algorithm).
  982. The default in Borg is lz4, which is fast enough to not use significant CPU time
  983. in most cases, but can only achieve modest compression. It still compresses
  984. easily compressed data fairly well.
  985. Borg also offers zstd, zlib and lzma compression, choose wisely.
  986. Which choice is the best option depends on a number of factors, like
  987. bandwidth to the repository, how well the data compresses, available CPU
  988. power and so on.