2
0

faq.rst 62 KB

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