faq.rst 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  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 (list, load and store objects),
  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 back up from multiple servers into a single repository?
  22. -------------------------------------------------------------
  23. Yes, you can! Even simultaneously.
  24. Can I back up to multiple, swapped backup targets?
  25. --------------------------------------------------
  26. It is possible to swap your backup disks if each backup medium is assigned its
  27. own repository by creating a new one with :ref:`borg_rcreate`.
  28. Can I copy or synchronize my repo to another location?
  29. ------------------------------------------------------
  30. If you want to have redundant backup repositories (preferably at separate
  31. locations), the recommended way to do that is like this:
  32. - ``borg repo-create repo1 --encryption=X``
  33. - ``borg repo-create repo2 --encryption=X --other-repo=repo1``
  34. - maybe do a snapshot to have stable and same input data for both borg create.
  35. - client machine ---borg create---> repo1
  36. - client machine ---borg create---> repo2
  37. This will create distinct (different repo ID), but related repositories.
  38. Related means using the same chunker secret and the same id_key, thus producing
  39. the same chunks / the same chunk ids if the input data is the same.
  40. The 2 independent borg create invocations mean that there is no error propagation
  41. from repo1 to repo2 when done like that.
  42. An alternative way would be to use ``borg transfer`` to copy backup archives
  43. from repo1 to repo2. Likely a bit more efficient and the archives would be identical,
  44. but suffering from potential error propagation.
  45. Warning: using borg with multiple repositories with identical repository ID (like when
  46. creating 1:1 repository copies) is not supported and can lead to all sorts of issues,
  47. like e.g. cache coherency issues, malfunction, data corruption.
  48. "this is either an attack or unsafe" warning
  49. --------------------------------------------
  50. About the warning:
  51. Cache, or information obtained from the security directory is newer than
  52. repository - this is either an attack or unsafe (multiple repos with same ID)
  53. "unsafe": If not following the advice from the previous section, you can easily
  54. run into this by yourself by restoring an older copy of your repository.
  55. "attack": maybe an attacker has replaced your repo by an older copy, trying to
  56. trick you into AES counter reuse, trying to break your repo encryption.
  57. Borg users have also reported that fs issues (like hw issues / I/O errors causing
  58. the fs to become read-only) can cause this warning, see :issue:`7853`.
  59. If you decide to ignore this and accept unsafe operation for this repository,
  60. you could delete the manifest-timestamp and the local cache:
  61. ::
  62. borg config id # shows the REPO_ID
  63. rm ~/.config/borg/security/REPO_ID/manifest-timestamp
  64. borg repo-delete --cache-only
  65. This is an unsafe and unsupported way to use borg, you have been warned.
  66. Which file types, attributes, etc. are *not* preserved?
  67. -------------------------------------------------------
  68. * UNIX domain sockets (because it does not make sense - they are
  69. meaningless without the running process that created them and the process
  70. needs to recreate them in any case). So, don't panic if your backup
  71. misses a UDS!
  72. * The precise on-disk (or rather: not-on-disk) representation of the holes
  73. in a sparse file.
  74. Archive creation has no special support for sparse files, holes are
  75. backed up as (deduplicated and compressed) runs of zero bytes.
  76. Archive extraction has optional support to extract all-zero chunks as
  77. holes in a sparse file.
  78. * Some filesystem specific attributes, like btrfs NOCOW, see :ref:`platforms`.
  79. Are there other known limitations?
  80. ----------------------------------
  81. - borg extract supports restoring only into an empty destination. After extraction,
  82. the destination will have exactly the contents of the extracted archive.
  83. If you extract into a non-empty destination, borg will (for example) not
  84. remove files which are in the destination, but not in the archive.
  85. See :issue:`4598` for a workaround and more details.
  86. .. _interrupted_backup:
  87. If a backup stops mid-way, does the already-backed-up data stay there?
  88. ----------------------------------------------------------------------
  89. Yes, the data transferred into the repo stays there - just avoid running
  90. ``borg compact`` before you completed the backup, because that would remove
  91. chunks that were already transferred to the repo, but not (yet) referenced
  92. by an archive.
  93. If a backup was interrupted, you normally do not need to do anything special,
  94. just invoke ``borg create`` as you always do. You may use the same archive name
  95. as in previous attempt or a different one (e.g. if you always include the
  96. current datetime), it does not matter.
  97. Borg always does full single-pass backups, so it will start again
  98. from the beginning - but it will be much faster, because some of the data was
  99. already stored into the repo, so it does not need to get transmitted and stored
  100. again.
  101. How can I back up huge file(s) over a unstable connection?
  102. ----------------------------------------------------------
  103. Yes. For more details, see :ref:`interrupted_backup`.
  104. How can I restore huge file(s) over an unstable connection?
  105. -----------------------------------------------------------
  106. Try using ``borg mount`` and ``rsync`` (or a similar tool that supports
  107. resuming a partial file copy from what's already copied).
  108. How can I switch append-only mode on and off?
  109. -----------------------------------------------------------------------------------------------------------------------------------
  110. You could do that (via borg config REPO append_only 0/1), but using different
  111. ssh keys and different entries in ``authorized_keys`` is much easier and also
  112. maybe has less potential of things going wrong somehow.
  113. My machine goes to sleep causing `Broken pipe`
  114. ----------------------------------------------
  115. While backing up your data over the network, your machine should not go to sleep.
  116. On macOS you can use `caffeinate` to avoid that.
  117. How can I compare contents of an archive to my local filesystem?
  118. -----------------------------------------------------------------
  119. You can instruct ``export-tar`` to send a tar stream to the stdout, and
  120. then use ``tar`` to perform the comparison:
  121. ::
  122. borg export-tar archive-name - | tar --compare -f - -C /path/to/compare/to
  123. Can Borg add redundancy to the backup data to deal with hardware malfunction?
  124. -----------------------------------------------------------------------------
  125. No, it can't. While that at first sounds like a good idea to defend against
  126. some defect HDD sectors or SSD flash blocks, dealing with this in a
  127. reliable way needs a lot of low-level storage layout information and
  128. control which we do not have (and also can't get, even if we wanted).
  129. So, if you need that, consider RAID or a filesystem that offers redundant
  130. storage or just make backups to different locations / different hardware.
  131. See also :issue:`225`.
  132. Can Borg verify data integrity of a backup archive?
  133. ---------------------------------------------------
  134. Yes, if you want to detect accidental data damage (like bit rot), use the
  135. ``check`` operation. It will notice corruption using CRCs and hashes.
  136. If you want to be able to detect malicious tampering also, use an encrypted
  137. repo. It will then be able to check using CRCs and HMACs.
  138. .. _faq-integrityerror:
  139. I get an IntegrityError or similar - what now?
  140. ----------------------------------------------
  141. A single error does not necessarily indicate bad hardware or a Borg
  142. bug. All hardware exhibits a bit error rate (BER). Hard drives are typically
  143. specified as exhibiting fewer than one error every 12 to 120 TB
  144. (one bit error in 10e14 to 10e15 bits). The specification is often called
  145. *unrecoverable read error rate* (URE rate).
  146. Apart from these very rare errors there are two main causes of errors:
  147. (i) Defective hardware: described below.
  148. (ii) Bugs in software (Borg, operating system, libraries):
  149. Ensure software is up to date.
  150. Check whether the issue is caused by any fixed bugs described in
  151. :ref:`important_notes`.
  152. .. rubric:: Finding defective hardware
  153. .. note::
  154. Hardware diagnostics are operating system dependent and do not
  155. apply universally. The commands shown apply for popular Unix-like
  156. systems. Refer to your operating system's manual.
  157. Checking hard drives
  158. Find the drive containing the repository and use *findmnt*, *mount* or *lsblk*
  159. to learn the device path (typically */dev/...*) of the drive.
  160. Then, smartmontools can retrieve self-diagnostics of the drive in question::
  161. # smartctl -a /dev/sdSomething
  162. The *Offline_Uncorrectable*, *Current_Pending_Sector* and *Reported_Uncorrect*
  163. attributes indicate data corruption. A high *UDMA_CRC_Error_Count* usually
  164. indicates a bad cable.
  165. I/O errors logged by the system (refer to the system journal or
  166. dmesg) can point to issues as well. I/O errors only affecting the
  167. file system easily go unnoticed, since they are not reported to
  168. applications (e.g. Borg), while these errors can still corrupt data.
  169. Drives can corrupt some sectors in one event, while remaining
  170. reliable otherwise. Conversely, drives can fail completely with no
  171. advance warning. If in doubt, copy all data from the drive in
  172. question to another drive -- just in case it fails completely.
  173. If any of these are suspicious, a self-test is recommended::
  174. # smartctl -t long /dev/sdSomething
  175. Running ``fsck`` if not done already might yield further insights.
  176. Checking memory
  177. Intermittent issues, such as ``borg check`` finding errors
  178. inconsistently between runs, are frequently caused by bad memory.
  179. Run memtest86+ (or an equivalent memory tester) to verify that
  180. the memory subsystem is operating correctly.
  181. Checking processors
  182. Processors rarely cause errors. If they do, they are usually overclocked
  183. or otherwise operated outside their specifications. We do not recommend to
  184. operate hardware outside its specifications for productive use.
  185. Tools to verify correct processor operation include Prime95 (mprime), linpack,
  186. and the `Intel Processor Diagnostic Tool
  187. <https://downloadcenter.intel.com/download/19792/Intel-Processor-Diagnostic-Tool>`_
  188. (applies only to Intel processors).
  189. .. rubric:: Repairing a damaged repository
  190. With any defective hardware found and replaced, the damage done to the repository
  191. needs to be ascertained and fixed.
  192. :ref:`borg_check` provides diagnostics and ``--repair`` options for repositories with
  193. issues. We recommend to first run without ``--repair`` to assess the situation.
  194. If the found issues and proposed repairs seem right, re-run "check" with ``--repair`` enabled.
  195. How probable is it to get a hash collision problem?
  196. ---------------------------------------------------
  197. If you noticed, there are some issues (:issue:`170` (**warning: hell**) and :issue:`4884`)
  198. about the probability of a chunk having the same hash as another chunk, making the file
  199. corrupted because it grabbed the wrong chunk. This is called the `Birthday Problem
  200. <https://en.wikipedia.org/wiki/Birthday_problem>`_.
  201. There is a lot of probability in here so, I can give you my interpretation of
  202. such math but it's honestly better that you read it yourself and grab your own
  203. resolution from that.
  204. Assuming that all your chunks have a size of :math:`2^{21}` bytes (approximately 2.1 MB)
  205. and we have a "perfect" hash algorithm, we can think that the probability of collision
  206. would be of :math:`p^2/2^{n+1}` then, using SHA-256 (:math:`n=256`) and for example
  207. we have 1000 million chunks (:math:`p=10^9`) (1000 million chunks would be about 2100TB).
  208. The probability would be around 0.0000000000000000000000000000000000000000000000000000000000043.
  209. A mass-murderer space rock happens about once every 30 million years on average.
  210. This leads to a probability of such an event occurring in the next second to about :math:`10^{-15}`.
  211. That's **45** orders of magnitude more probable than the SHA-256 collision. Briefly stated,
  212. if you find SHA-256 collisions scary then your priorities are wrong. This example was grabbed from
  213. `this SO answer <https://stackoverflow.com/a/4014407/13359375>`_, it's great honestly.
  214. Still, the real question is whether Borg tries not to make this happen?
  215. Well... previously it did not check anything until there was a feature added which saves the size
  216. of the chunks too, so the size of the chunks is compared to the size that you got with the
  217. hash and if the check says there is a mismatch it will raise an exception instead of corrupting
  218. the file. This doesn't save us from everything but reduces the chances of corruption.
  219. There are other ways of trying to escape this but it would affect performance so much that
  220. it wouldn't be worth it and it would contradict Borg's design, so if you don't want this to
  221. happen, simply don't use Borg.
  222. Why is the time elapsed in the archive stats different from wall clock time?
  223. ----------------------------------------------------------------------------
  224. Borg needs to write the time elapsed into the archive metadata before finalizing
  225. the archive and saving the files cache.
  226. This means when Borg is run with e.g. the ``time`` command, the duration shown
  227. in the archive stats may be shorter than the full time the command runs for.
  228. How do I configure different prune policies for different directories?
  229. ----------------------------------------------------------------------
  230. Say you want to prune ``/var/log`` faster than the rest of
  231. ``/``. How do we implement that? The answer is to back up to different
  232. archive *names* and then implement different prune policies for
  233. different prefixes. For example, you could have a script that does::
  234. borg create --exclude var/log main-$(date +%Y-%m-%d) /
  235. borg create logs-$(date +%Y-%m-%d) /var/log
  236. Then you would have two different prune calls with different policies::
  237. borg prune --verbose --list -d 30 -a 'sh:main-*'
  238. borg prune --verbose --list -d 7 -a 'sh:logs-*'
  239. This will keep 7 days of logs and 30 days of everything else.
  240. How do I remove files from an existing backup?
  241. ----------------------------------------------
  242. A file is only removed from a BorgBackup repository if all archives that contain
  243. the file are deleted and the corresponding data chunks are removed from the
  244. repository. There are two ways how to remove files from a repository.
  245. 1. Use :ref:`borg_delete` to remove all archives that contain the files. This
  246. will of course delete everything in the archive, not only some files.
  247. 2. If you really want to remove only some specific files, you can run the
  248. :ref:`borg_recreate` command to rewrite all archives with a different
  249. ``--exclude`` pattern. See the examples in the manpage for more information.
  250. Finally, run :ref:`borg_compact` to delete the data chunks from the repository.
  251. Can I safely change the compression level or algorithm?
  252. --------------------------------------------------------
  253. The compression level and algorithm don't affect deduplication. Chunk ID hashes
  254. are calculated *before* compression. New compression settings
  255. will only be applied to new chunks, not existing chunks. So it's safe
  256. to change them.
  257. Use ``borg repo-compress`` to efficiently recompress a complete repository.
  258. Security
  259. ########
  260. .. _home_config_borg:
  261. How important is the $HOME/.config/borg directory?
  262. --------------------------------------------------
  263. The Borg config directory has content that you should take care of:
  264. ``keys`` subdirectory
  265. All your borg keyfile keys are stored in this directory. Please note that
  266. borg repokey keys are stored inside the repository. You MUST make sure to have an
  267. independent backup of these keyfiles, otherwise you cannot access your backups anymore if you lose
  268. them. You also MUST keep these files secret; everyone who gains access to your repository and has
  269. the corresponding keyfile (and the key passphrase) can extract it.
  270. Make sure that only you have access to the Borg config directory.
  271. .. _home_data_borg:
  272. How important is the $HOME/.local/share/borg directory?
  273. -------------------------------------------------------
  274. The Borg data directory has content that you should take care of:
  275. ``security`` subdirectory
  276. Each directory here represents one Borg repository by its ID and contains the last known status.
  277. If a repository's status is different from this information at the beginning of BorgBackup
  278. operation, Borg outputs warning messages and asks for confirmation, so make sure you do not lose
  279. or manipulate these files. However, apart from those warnings, a loss of these files can be
  280. recovered.
  281. Make sure that only you have access to the Borg data directory.
  282. .. _cache_security:
  283. Do I need to take security precautions regarding the cache?
  284. -----------------------------------------------------------
  285. The cache contains a lot of metadata information about the files in
  286. your repositories and it is not encrypted.
  287. However, the assumption is that the cache is being stored on the very
  288. same system which also contains the original files which are being
  289. backed up. So someone with access to the cache files would also have
  290. access the original files anyway.
  291. The Internals section contains more details about :ref:`cache`. If you ever need to move the cache
  292. to a different location, this can be achieved by using the appropriate :ref:`env_vars`.
  293. How can I specify the encryption passphrase programmatically?
  294. -------------------------------------------------------------
  295. There are several ways to specify a passphrase without human intervention:
  296. Setting ``BORG_PASSPHRASE``
  297. The passphrase can be specified using the ``BORG_PASSPHRASE`` environment variable.
  298. This is often the simplest option, but can be insecure if the script that sets it
  299. is world-readable.
  300. .. _password_env:
  301. .. note:: Be careful how you set the environment; using the ``env``
  302. command, a ``system()`` call or using inline shell scripts
  303. (e.g. ``BORG_PASSPHRASE=hunter2 borg ...``)
  304. might expose the credentials in the process list directly
  305. and they will be readable to all users on a system. Using
  306. ``export`` in a shell script file should be safe, however, as
  307. the environment of a process is `accessible only to that
  308. user
  309. <https://security.stackexchange.com/questions/14000/environment-variable-accessibility-in-linux/14009#14009>`_.
  310. Using ``BORG_PASSCOMMAND`` with a file of proper permissions
  311. Another option is to create a file with a password in it in your home
  312. directory and use permissions to keep anyone else from reading it. For
  313. example, first create a key::
  314. (umask 0077; head -c 32 /dev/urandom | base64 -w 0 > ~/.borg-passphrase)
  315. Then in an automated script one can put::
  316. export BORG_PASSCOMMAND="cat $HOME/.borg-passphrase"
  317. and Borg will automatically use that passphrase.
  318. Using keyfile-based encryption with a blank passphrase
  319. It is possible to encrypt your repository in ``keyfile`` mode instead of the default
  320. ``repokey`` mode and use a blank passphrase for the key file (simply press Enter twice
  321. when ``borg repo-create`` asks for the password). See :ref:`encrypted_repos`
  322. for more details.
  323. Using ``BORG_PASSCOMMAND`` with macOS Keychain
  324. macOS has a native manager for secrets (such as passphrases) which is safer
  325. than just using a file as it is encrypted at rest and unlocked manually
  326. (fortunately, the login keyring automatically unlocks when you log in). With
  327. the built-in ``security`` command, you can access it from the command line,
  328. making it useful for ``BORG_PASSCOMMAND``.
  329. First generate a passphrase and use ``security`` to save it to your login
  330. (default) keychain::
  331. security add-generic-password -D secret -U -a $USER -s borg-passphrase -w $(head -c 32 /dev/urandom | base64 -w 0)
  332. In your backup script retrieve it in the ``BORG_PASSCOMMAND``::
  333. export BORG_PASSCOMMAND="security find-generic-password -a $USER -s borg-passphrase -w"
  334. Using ``BORG_PASSCOMMAND`` with GNOME Keyring
  335. GNOME also has a keyring daemon that can be used to store a Borg passphrase.
  336. First ensure ``libsecret-tools``, ``gnome-keyring`` and ``libpam-gnome-keyring``
  337. are installed. If ``libpam-gnome-keyring`` wasn't already installed, ensure it
  338. runs on login::
  339. sudo sh -c "echo session optional pam_gnome_keyring.so auto_start >> /etc/pam.d/login"
  340. sudo sh -c "echo password optional pam_gnome_keyring.so >> /etc/pam.d/passwd"
  341. # you may need to relogin afterwards to activate the login keyring
  342. Then add a secret to the login keyring::
  343. head -c 32 /dev/urandom | base64 -w 0 | secret-tool store borg-repository repo-name --label="Borg Passphrase"
  344. If a dialog box pops up prompting you to pick a password for a new keychain, use your
  345. login password. If there is a checkbox for automatically unlocking on login, check it
  346. to allow backups without any user intervention whatsoever.
  347. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  348. export BORG_PASSCOMMAND="secret-tool lookup borg-repository repo-name"
  349. .. note:: For this to unlock the keychain automatically it must be run
  350. in the ``dbus`` session of an unlocked terminal; for example, running a backup
  351. script as a ``cron`` job might not work unless you also ``export DISPLAY=:0``
  352. so ``secret-tool`` can pick up your open session. `It gets even more complicated`__
  353. when you are running the tool as a different user (e.g. running a backup as root
  354. with the password stored in the user keyring).
  355. __ https://github.com/borgbackup/borg/pull/2837#discussion_r127641330
  356. Using ``BORG_PASSCOMMAND`` with KWallet
  357. KDE also has a keychain feature in the form of KWallet. The command-line tool
  358. ``kwalletcli`` can be used to store and retrieve secrets. Ensure ``kwalletcli``
  359. is installed, generate a passphrase, and store it in your "wallet"::
  360. head -c 32 /dev/urandom | base64 -w 0 | kwalletcli -Pe borg-passphrase -f Passwords
  361. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  362. export BORG_PASSCOMMAND="kwalletcli -e borg-passphrase -f Passwords"
  363. When backing up to remote encrypted repos, is encryption done locally?
  364. ----------------------------------------------------------------------
  365. Yes, file and directory metadata and data is locally encrypted, before
  366. leaving the local machine. We do not mean the transport layer encryption
  367. by that, but the data/metadata itself. Transport layer encryption (e.g.
  368. when ssh is used as a transport) applies additionally.
  369. When backing up to remote servers, do I have to trust the remote server?
  370. ------------------------------------------------------------------------
  371. Yes and No.
  372. No, as far as data confidentiality is concerned - if you use encryption,
  373. all your files/dirs data and metadata are stored in their encrypted form
  374. into the repository.
  375. Yes, as an attacker with access to the remote server could delete (or
  376. otherwise make unavailable) all your backups.
  377. How can I protect against a hacked backup client?
  378. -------------------------------------------------
  379. Assume you back up your backup client machine C to the backup server S and
  380. C gets hacked. In a simple push setup, the attacker could then use borg on
  381. C to delete all backups residing on S.
  382. These are your options to protect against that:
  383. - Do not allow to delete data permanently from the repo, see :ref:`append_only_mode`.
  384. - Use a pull-mode setup using ``ssh -R``, see :ref:`pull_backup` for more information.
  385. - Mount C's filesystem on another machine and then create a backup of it.
  386. - Do not give C filesystem-level access to S.
  387. See :ref:`hosting_repositories` for a detailed protection guide.
  388. How can I protect against a hacked backup server?
  389. -------------------------------------------------
  390. Just in case you got the impression that pull-mode backups are way more safe
  391. than push-mode, you also need to consider the case that your backup server S
  392. gets hacked. In case S has access to a lot of clients C, that might bring you
  393. into even bigger trouble than a hacked backup client in the previous FAQ entry.
  394. These are your options to protect against that:
  395. - Use the standard push-mode setup (see also previous FAQ entry).
  396. - Mount (the repo part of) S's filesystem on C.
  397. - Do not give S file-system level access to C.
  398. - Have your backup server at a well protected place (maybe not reachable from
  399. the internet), configure it safely, apply security updates, monitor it, ...
  400. How can I protect against theft, sabotage, lightning, fire, ...?
  401. ----------------------------------------------------------------
  402. In general: if your only backup medium is nearby the backupped machine and
  403. always connected, you can easily get into trouble: they likely share the same
  404. fate if something goes really wrong.
  405. Thus:
  406. - have multiple backup media
  407. - have media disconnected from network, power, computer
  408. - have media at another place
  409. - have a relatively recent backup on your media
  410. How do I report a security issue with Borg?
  411. -------------------------------------------
  412. Send a private email to the :ref:`security contact <security-contact>`
  413. if you think you have discovered a security issue.
  414. Please disclose security issues responsibly.
  415. Common issues
  416. #############
  417. /path/to/repo is not a valid repository. Check repo config.
  418. -----------------------------------------------------------
  419. There can be many causes of this error. E.g. you have incorrectly specified the repository path.
  420. You will also get this error if you try to access a repository with a key that uses the argon2 key algorithm using an old version of borg.
  421. We recommend upgrading to the latest stable version and trying again. We are sorry. We should have thought about forward
  422. compatibility and implemented a more helpful error message.
  423. Why does Borg extract hang after some time?
  424. -------------------------------------------
  425. When I do a ``borg extract``, after a while all activity stops, no cpu usage,
  426. no downloads.
  427. This may happen when the SSH connection is stuck on server side. You can
  428. configure SSH on client side to prevent this by sending keep-alive requests,
  429. for example in ~/.ssh/config:
  430. ::
  431. Host borg.example.com
  432. # Client kills connection after 3*30 seconds without server response:
  433. ServerAliveInterval 30
  434. ServerAliveCountMax 3
  435. You can also do the opposite and configure SSH on server side in
  436. /etc/ssh/sshd_config, to make the server send keep-alive requests to the client:
  437. ::
  438. # Server kills connection after 3*30 seconds without client response:
  439. ClientAliveInterval 30
  440. ClientAliveCountMax 3
  441. How can I deal with my very unstable SSH connection?
  442. ----------------------------------------------------
  443. If you have issues with lost connections during long-running borg commands, you
  444. could try to work around:
  445. - Make partial extracts like ``borg extract PATTERN`` to do multiple
  446. smaller extraction runs that complete before your connection has issues.
  447. - Try using ``borg mount MOUNTPOINT`` and ``rsync -avH`` from
  448. ``MOUNTPOINT`` to your desired extraction directory. If the connection breaks
  449. down, just repeat that over and over again until rsync does not find anything
  450. to do any more. Due to the way borg mount works, this might be less efficient
  451. than borg extract for bigger volumes of data.
  452. Why do I get "connection closed by remote" after a while?
  453. ---------------------------------------------------------
  454. When doing a backup to a remote server (using a ssh: repo URL), it sometimes
  455. stops after a while (some minutes, hours, ... - not immediately) with
  456. "connection closed by remote" error message. Why?
  457. That's a good question and we are trying to find a good answer in :issue:`636`.
  458. Why am I seeing idle borg serve processes on the repo server?
  459. -------------------------------------------------------------
  460. Maybe the ssh connection between client and server broke down and that was not
  461. yet noticed on the server. Try these settings:
  462. ::
  463. # /etc/ssh/sshd_config on borg repo server - kill connection to client
  464. # after ClientAliveCountMax * ClientAliveInterval seconds with no response
  465. ClientAliveInterval 20
  466. ClientAliveCountMax 3
  467. If you have multiple borg create ... ; borg create ... commands in a already
  468. serialized way in a single script, you need to give them ``--lock-wait N`` (with N
  469. being a bit more than the time the server needs to terminate broken down
  470. connections and release the lock).
  471. Can I back up my root partition (/) with Borg?
  472. ----------------------------------------------
  473. Backing up your entire root partition works just fine, but remember to
  474. exclude directories that make no sense to back up, such as /dev, /proc,
  475. /sys, /tmp and /run, and to use ``--one-file-system`` if you only want to
  476. back up the root partition (and not any mounted devices e.g.).
  477. If it crashes with a UnicodeError, what can I do?
  478. -------------------------------------------------
  479. Check if your encoding is set correctly. For most POSIX-like systems, try::
  480. export LANG=en_US.UTF-8 # or similar, important is correct charset
  481. If that does not help:
  482. - check for typos, check if you really used ``export``.
  483. - check if you have set ``LC_ALL`` - if so, try not setting it.
  484. - check if you generated the respective locale via ``locale-gen``.
  485. I can't extract non-ascii filenames by giving them on the commandline!?
  486. -----------------------------------------------------------------------
  487. This might be due to different ways to represent some characters in unicode
  488. or due to other non-ascii encoding issues.
  489. If you run into that, try this:
  490. - avoid the non-ascii characters on the commandline by e.g. extracting
  491. the parent directory (or even everything)
  492. - mount the repo using FUSE and use some file manager
  493. .. _expected_performance:
  494. What's the expected backup performance?
  495. ---------------------------------------
  496. Compared to simply copying files (e.g. with ``rsync``), Borg has more work to do.
  497. This can make creation of the first archive slower, but saves time
  498. and disk space on subsequent runs. Here what Borg does when you run ``borg create``:
  499. - Borg chunks the file (using the relatively expensive buzhash algorithm)
  500. - It then computes the "id" of the chunk (hmac-sha256 (slow, except
  501. if your CPU has sha256 acceleration) or blake2b (fast, in software))
  502. - Then it checks whether this chunk is already in the repo (local hashtable lookup,
  503. fast). If so, the processing of the chunk is completed here. Otherwise it needs to
  504. process the chunk:
  505. - Compresses (the default lz4 is super fast)
  506. - Encrypts and authenticates (AES-OCB, usually fast if your CPU has AES acceleration as usual
  507. since about 10y, or chacha20-poly1305, fast pure-software crypto)
  508. - Transmits to repo. If the repo is remote, this usually involves an SSH connection
  509. (does its own encryption / authentication).
  510. - Stores the chunk into a key/value store (the key is the chunk id, the value
  511. is the data). While doing that, it computes XXH64 of the data (repo low-level
  512. checksum, used by borg check --repository).
  513. Subsequent backups are usually very fast if most files are unchanged and only
  514. a few are new or modified. The high performance on unchanged files primarily depends
  515. only on a few factors (like FS recursion + metadata reading performance and the
  516. files cache working as expected) and much less on other factors.
  517. E.g., for this setup:
  518. - server grade machine (4C/8T 2013 Xeon, 64GB RAM, 2x good 7200RPM disks)
  519. - local zfs filesystem (mirrored) containing the backup source data
  520. - repository is remote (does not matter much for unchanged files)
  521. - backup job runs while machine is otherwise idle
  522. The observed performance is that Borg can process about
  523. **1 million unchanged files (and a few small changed ones) in 4 minutes!**
  524. If you are seeing much less than that in similar circumstances, read the next
  525. few FAQ entries below.
  526. .. _slow_backup:
  527. Why is my backup so slow?
  528. --------------------------
  529. If you feel your Borg backup is too slow somehow, here is what you can do:
  530. - Make sure Borg has enough RAM (depends on how big your repo is / how many
  531. files you have)
  532. - Use one of the blake2 modes for --encryption except if you positively know
  533. your CPU (and openssl) accelerates sha256 (then stay with hmac-sha256).
  534. - Don't use any expensive compression. The default is lz4 and super fast.
  535. Uncompressed is often slower than lz4.
  536. - Just wait. You can also interrupt it and start it again as often as you like,
  537. it will converge against a valid "completed" state. It is starting
  538. from the beginning each time, but it is still faster then as it does not store
  539. data into the repo which it already has there.
  540. - If you don’t need additional file attributes, you can disable them with ``--noflags``,
  541. ``--noacls``, ``--noxattrs``. This can lead to noticeable performance improvements
  542. when your backup consists of many small files.
  543. To see what files have changed and take more time processing, you can also add
  544. ``--list --filter=AME --stats`` to your ``borg create`` call to produce more log output,
  545. including a file list (with file status characters) and also some statistics at
  546. the end of the backup.
  547. Then you do the backup and look at the log output:
  548. - stats: Do you really have little changes or are there more changes than you thought?
  549. In the stats you can see the overall volume of changed data, which needed to be
  550. added to the repo. If that is a lot, that can be the reason why it is slow.
  551. - ``A`` status ("added") in the file list:
  552. If you see that often, you have a lot of new files (files that Borg did not find
  553. in the files cache). If you think there is something wrong with that (the file was there
  554. already in the previous backup), please read the FAQ entries below.
  555. - ``M`` status ("modified") in the file list:
  556. If you see that often, Borg thinks that a lot of your files might be modified
  557. (Borg found them in the files cache, but the metadata read from the filesystem did
  558. not match the metadata stored in the files cache).
  559. In such a case, Borg will need to process the files' contents completely, which is
  560. much slower than processing unmodified files (Borg does not read their contents!).
  561. The metadata values used in this comparison are determined by the ``--files-cache`` option
  562. and could be e.g. size, ctime and inode number (see the ``borg create`` docs for more
  563. details and potential issues).
  564. You can use the ``stat`` command on files to look at fs metadata manually to debug if
  565. there is any unexpected change triggering the ``M`` status.
  566. Also, the ``--debug-topic=files_cache`` option of ``borg create`` provides a lot of debug
  567. output helping to analyse why the files cache does not give its expected high performance.
  568. When borg runs inside a virtual machine, there are some more things to look at:
  569. Some hypervisors (e.g. kvm on proxmox) give some broadly compatible CPU type to the
  570. VM (usually to ease migration between VM hosts of potentially different hardware CPUs).
  571. It is broadly compatible because they leave away modern CPU features that could be
  572. not present in older or other CPUs, e.g. hardware acceleration for AES crypto, for
  573. sha2 hashes, for (P)CLMUL(QDQ) computations useful for crc32.
  574. So, basically you pay for compatibility with bad performance. If you prefer better
  575. performance, you should try to expose the host CPU's misc. hw acceleration features
  576. to the VM which runs borg.
  577. On Linux, check ``/proc/cpuinfo`` for the CPU flags inside the VM.
  578. For kvm check the docs about "Host model" and "Host passthrough".
  579. See also the next few FAQ entries for more details.
  580. .. _a_status_oddity:
  581. I am seeing 'A' (added) status for an unchanged file!?
  582. ------------------------------------------------------
  583. The files cache is used to determine whether Borg already
  584. "knows" / has backed up a file and if so, to skip the file from
  585. chunking. It intentionally *excludes* files that have a timestamp
  586. which is the same as the newest timestamp in the created archive.
  587. So, if you see an 'A' status for unchanged file(s), they are likely the files
  588. with the most recent timestamp in that archive.
  589. This is expected: it is to avoid data loss with files that are backed up from
  590. a snapshot and that are immediately changed after the snapshot (but within
  591. timestamp granularity time, so the timestamp would not change). Without the code that
  592. removes these files from the files cache, the change that happened right after
  593. the snapshot would not be contained in the next backup as Borg would
  594. think the file is unchanged.
  595. This does not affect deduplication, the file will be chunked, but as the chunks
  596. will often be the same and already stored in the repo (except in the above
  597. mentioned rare condition), it will just re-use them as usual and not store new
  598. data chunks.
  599. If you want to avoid unnecessary chunking, just create or touch a small or
  600. empty file in your backup source file set (so that one has the latest timestamp,
  601. not your 50GB VM disk image) and, if you do snapshots, do the snapshot after
  602. that.
  603. Since only the files cache is used in the display of files status,
  604. those files are reported as being added when, really, chunks are
  605. already used.
  606. By default, ctime (change time) is used for the timestamps to have a rather
  607. safe change detection (see also the --files-cache option).
  608. Furthermore, pathnames recorded in files cache are always absolute, even if you
  609. specify source directories with relative pathname. If relative pathnames are
  610. stable, but absolute are not (for example if you mount a filesystem without
  611. stable mount points for each backup or if you are running the backup from a
  612. filesystem snapshot whose name is not stable), borg will assume that files are
  613. different and will report them as 'added', even though no new chunks will be
  614. actually recorded for them. To avoid this, you could bind mount your source
  615. directory in a directory with the stable path.
  616. .. _always_chunking:
  617. It always chunks all my files, even unchanged ones!
  618. ---------------------------------------------------
  619. Borg maintains a files cache where it remembers the timestamp, size and
  620. inode of files. When Borg does a new backup and starts processing a
  621. file, it first looks whether the file has changed (compared to the values
  622. stored in the files cache). If the values are the same, the file is assumed
  623. unchanged and thus its contents won't get chunked (again).
  624. Borg can't keep an infinite history of files of course, thus entries
  625. in the files cache have a "maximum time to live" which is set via the
  626. environment variable BORG_FILES_CACHE_TTL (and defaults to 20).
  627. Every time you do a backup (on the same machine, using the same user), the
  628. cache entries' ttl values of files that were not "seen" are incremented by 1
  629. and if they reach BORG_FILES_CACHE_TTL, the entry is removed from the cache.
  630. So, for example, if you do daily backups of 26 different data sets A, B,
  631. C, ..., Z on one machine (using the default TTL), the files from A will be
  632. already forgotten when you repeat the same backups on the next day and it
  633. will be slow because it would chunk all the files each time. If you set
  634. BORG_FILES_CACHE_TTL to at least 26 (or maybe even a small multiple of that),
  635. it would be much faster.
  636. Besides using a higher BORG_FILES_CACHE_TTL (which also increases memory usage),
  637. there is also BORG_FILES_CACHE_SUFFIX which can be used to have separate (smaller)
  638. files caches for each backup set instead of the default one (big) unified files cache.
  639. Another possible reason is that files don't always have the same path, for
  640. example if you mount a filesystem without stable mount points for each backup
  641. or if you are running the backup from a filesystem snapshot whose name is not
  642. stable. If the directory where you mount a filesystem is different every time,
  643. Borg assumes they are different files. This is true even if you back up these
  644. files with relative pathnames - borg uses full pathnames in files cache regardless.
  645. It is possible for some filesystems, such as ``mergerfs`` or network filesystems,
  646. to return inconsistent inode numbers across runs, causing borg to consider them changed.
  647. A workaround is to set the option ``--files-cache=ctime,size`` to exclude the inode
  648. number comparison from the files cache check so that files with different inode
  649. numbers won't be treated as modified.
  650. Is there a way to limit bandwidth with Borg?
  651. --------------------------------------------
  652. To limit upload (i.e. :ref:`borg_create`) bandwidth, use the
  653. ``--remote-ratelimit`` option.
  654. There is no built-in way to limit *download*
  655. (i.e. :ref:`borg_extract`) bandwidth, but limiting download bandwidth
  656. can be accomplished with pipeviewer_:
  657. Create a wrapper script: /usr/local/bin/pv-wrapper
  658. ::
  659. #!/bin/sh
  660. ## -q, --quiet do not output any transfer information at all
  661. ## -L, --rate-limit RATE limit transfer to RATE bytes per second
  662. RATE=307200
  663. pv -q -L $RATE | "$@"
  664. Add BORG_RSH environment variable to use pipeviewer wrapper script with ssh.
  665. ::
  666. export BORG_RSH='/usr/local/bin/pv-wrapper ssh'
  667. Now Borg will be bandwidth limited. The nice thing about ``pv`` is that you can
  668. change rate-limit on the fly:
  669. ::
  670. pv -R $(pidof pv) -L 102400
  671. .. _pipeviewer: http://www.ivarch.com/programs/pv.shtml
  672. How can I avoid unwanted base directories getting stored into archives?
  673. -----------------------------------------------------------------------
  674. Possible use cases:
  675. - Another file system is mounted and you want to back it up with original paths.
  676. - You have created a BTRFS snapshot in a ``/.snapshots`` directory for backup.
  677. To achieve this, run ``borg create`` within the mountpoint/snapshot directory:
  678. ::
  679. # Example: Some file system mounted in /mnt/rootfs.
  680. cd /mnt/rootfs
  681. borg create rootfs_backup .
  682. Another way (without changing the directory) is to use the slashdot hack:
  683. ::
  684. borg create rootfs_backup /mnt/rootfs/./
  685. I am having troubles with some network/FUSE/special filesystem, why?
  686. --------------------------------------------------------------------
  687. Borg is doing nothing special in the filesystem, it only uses very
  688. common and compatible operations (even the locking is just "rename").
  689. So, if you are encountering issues like slowness, corruption or malfunction
  690. when using a specific filesystem, please try if you can reproduce the issues
  691. with a local (non-network) and proven filesystem (like ext4 on Linux).
  692. If you can't reproduce the issue then, you maybe have found an issue within
  693. the filesystem code you used (not with Borg). For this case, it is
  694. recommended that you talk to the developers / support of the network fs and
  695. maybe open an issue in their issue tracker. Do not file an issue in the
  696. Borg issue tracker.
  697. If you can reproduce the issue with the proven filesystem, please file an
  698. issue in the Borg issue tracker about that.
  699. Why does running 'borg check --repair' warn about data loss?
  700. ------------------------------------------------------------
  701. Repair usually works for recovering data in a corrupted archive. However,
  702. it's impossible to predict all modes of corruption. In some very rare
  703. instances, such as malfunctioning storage hardware, additional repo
  704. corruption may occur. If you can't afford to lose the repo, it's strongly
  705. recommended that you perform repair on a copy of the repo.
  706. In other words, the warning is there to emphasize that Borg:
  707. - Will perform automated routines that modify your backup repository
  708. - Might not actually fix the problem you are experiencing
  709. - Might, in very rare cases, further corrupt your repository
  710. In the case of malfunctioning hardware, such as a drive or USB hub
  711. corrupting data when read or written, it's best to diagnose and fix the
  712. cause of the initial corruption before attempting to repair the repo. If
  713. the corruption is caused by a one time event such as a power outage,
  714. running `borg check --repair` will fix most problems.
  715. Why isn't there more progress / ETA information displayed?
  716. ----------------------------------------------------------
  717. Some borg runs take quite a bit, so it would be nice to see a progress display,
  718. maybe even including a ETA (expected time of "arrival" [here rather "completion"]).
  719. For some functionality, this can be done: if the total amount of work is more or
  720. less known, we can display progress. So check if there is a ``--progress`` option.
  721. But sometimes, the total amount is unknown (e.g. for ``borg create`` we just do
  722. a single pass over the filesystem, so we do not know the total file count or data
  723. volume before reaching the end). Adding another pass just to determine that would
  724. take additional time and could be incorrect, if the filesystem is changing.
  725. Even if the fs does not change and we knew count and size of all files, we still
  726. could not compute the ``borg create`` ETA as we do not know the amount of changed
  727. chunks, how the bandwidth of source and destination or system performance might
  728. fluctuate.
  729. You see, trying to display ETA would be futile. The borg developers prefer to
  730. rather not implement progress / ETA display than doing futile attempts.
  731. See also: https://xkcd.com/612/
  732. Why am I getting 'Operation not permitted' errors when backing up on sshfs?
  733. ---------------------------------------------------------------------------
  734. By default, ``sshfs`` is not entirely POSIX-compliant when renaming files due to
  735. a technicality in the SFTP protocol. Fortunately, it also provides a workaround_
  736. to make it behave correctly::
  737. sshfs -o workaround=rename user@host:dir /mnt/dir
  738. .. _workaround: https://unix.stackexchange.com/a/123236
  739. How do I rename a repository?
  740. -----------------------------
  741. There is nothing special that needs to be done, you can simply rename the
  742. directory that corresponds to the repository. However, the next time borg
  743. interacts with the repository (i.e, via ``borg list``), depending on the value
  744. of ``BORG_RELOCATED_REPO_ACCESS_IS_OK``, borg may warn you that the repository
  745. has been moved. You will be given a prompt to confirm you are OK with this.
  746. If ``BORG_RELOCATED_REPO_ACCESS_IS_OK`` is unset, borg will interactively ask for
  747. each repository whether it's OK.
  748. It may be useful to set ``BORG_RELOCATED_REPO_ACCESS_IS_OK=yes`` to avoid the
  749. prompts when renaming multiple repositories or in a non-interactive context
  750. such as a script. See :doc:`deployment` for an example.
  751. My backup disk is full, what can I do?
  752. --------------------------------------
  753. Borg cannot work if you really have zero free space on the backup disk, so the
  754. first thing you must do is deleting some files to regain free disk space. See
  755. :ref:`about_free_space` for further details.
  756. Some Borg commands that do not change the repository might work under disk-full
  757. conditions, but generally this should be avoided. If your backup disk is already
  758. full when Borg starts a write command like `borg create`, it will abort
  759. immediately and the repository will stay as-is.
  760. Miscellaneous
  761. #############
  762. macOS: borg mounts not shown in Finder's side bar
  763. -------------------------------------------------
  764. https://github.com/osxfuse/osxfuse/wiki/Mount-options#local
  765. Read the above first and use this on your own risk::
  766. borg mount -olocal REPO MOUNTPOINT
  767. Requirements for the borg single-file binary, esp. (g)libc?
  768. -----------------------------------------------------------
  769. We try to build the binary on old, but still supported systems - to keep the
  770. minimum requirement for the (g)libc low. The (g)libc can't be bundled into
  771. the binary as it needs to fit your kernel and OS, but Python and all other
  772. required libraries will be bundled into the binary.
  773. If your system fulfills the minimum (g)libc requirement (see the README that
  774. is released with the binary), there should be no problem. If you are slightly
  775. below the required version, maybe just try. Due to the dynamic loading (or not
  776. loading) of some shared libraries, it might still work depending on what
  777. libraries are actually loaded and used.
  778. In the borg git repository, there is scripts/glibc_check.py that can determine
  779. (based on the symbols' versions they want to link to) whether a set of given
  780. (Linux) binaries works with a given glibc version.