faq.rst 61 KB

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