faq.rst 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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 repository on an external hard drive and a repository on a server?
  9. ---------------------------------------------------------------------------------------------------
  10. If Borg is running in client/server mode, the client uses SSH as a transport to
  11. talk to a remote agent, which is another Borg process (Borg is also installed on
  12. the server) started automatically by the client. The Borg server performs
  13. storage-related, low-level repository 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 filesystem, e.g.
  18. SSHFS, the Borg client can only perform filesystem 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_repo-create`.
  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. - Optionally, create a snapshot to have stable and identical input data for both borg create runs.
  35. - client machine ---borg create---> repo1
  36. - client machine ---borg create---> repo2
  37. This will create distinct (different repository 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 two independent borg create invocations mean there is no error propagation
  41. from repo1 to repo2 when done like that.
  42. An alternative is to use ``borg transfer`` to copy backup archives
  43. from repo1 to repo2. This is likely a bit more efficient and the archives would be identical,
  44. but it may suffer from potential error propagation.
  45. Warning: Using Borg with multiple repositories that have identical repository IDs (such as
  46. creating 1:1 repository copies) is not supported and can lead to various issues,
  47. for example cache coherency issues, malfunction, or 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 the
  52. repository — this is either an attack or unsafe (multiple repositories with the 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": An attacker may have replaced your repo with an older copy, trying to
  56. trigger AES counter reuse and break your repo encryption.
  57. Borg users have also reported that file system issues (e.g., hardware issues or I/O errors causing
  58. the file system 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. My machine goes to sleep causing `Broken pipe`
  109. ----------------------------------------------
  110. While backing up your data over the network, your machine should not go to sleep.
  111. On Linux you can use `systemd-inhibit` to avoid that. On macOS you can use `caffeinate`.
  112. ``systemd-inhibit borg create ...``
  113. ``caffeinate -i borg create ...``
  114. How can I compare contents of an archive to my local filesystem?
  115. -----------------------------------------------------------------
  116. You can instruct ``export-tar`` to send a tar stream to the stdout, and
  117. then use ``tar`` to perform the comparison:
  118. ::
  119. borg export-tar archive-name - | tar --compare -f - -C /path/to/compare/to
  120. Can Borg add redundancy to the backup data to deal with hardware malfunction?
  121. -----------------------------------------------------------------------------
  122. No, it can't. While that at first sounds like a good idea to defend against
  123. some defect HDD sectors or SSD flash blocks, dealing with this in a
  124. reliable way needs a lot of low-level storage layout information and
  125. control which we do not have (and also can't get, even if we wanted).
  126. So, if you need that, consider RAID or a filesystem that offers redundant
  127. storage or just make backups to different locations / different hardware.
  128. See also :issue:`225`.
  129. Can Borg verify data integrity of a backup archive?
  130. ---------------------------------------------------
  131. Yes, if you want to detect accidental data damage (like bit rot), use the
  132. ``check`` operation. It will notice corruption using CRCs and hashes.
  133. If you want to be able to detect malicious tampering also, use an encrypted
  134. repo. It will then be able to check using CRCs and HMACs.
  135. .. _faq-integrityerror:
  136. I get an IntegrityError or similar - what now?
  137. ----------------------------------------------
  138. A single error does not necessarily indicate bad hardware or a Borg
  139. bug. All hardware exhibits a bit error rate (BER). Hard drives are typically
  140. specified as exhibiting fewer than one error every 12 to 120 TB
  141. (one bit error in 10e14 to 10e15 bits). The specification is often called
  142. *unrecoverable read error rate* (URE rate).
  143. Apart from these very rare errors there are two main causes of errors:
  144. (i) Defective hardware: described below.
  145. (ii) Bugs in software (Borg, operating system, libraries):
  146. Ensure software is up to date.
  147. Check whether the issue is caused by any fixed bugs described in
  148. :ref:`important_notes`.
  149. .. rubric:: Finding defective hardware
  150. .. note::
  151. Hardware diagnostics are operating system dependent and do not
  152. apply universally. The commands shown apply for popular Unix-like
  153. systems. Refer to your operating system's manual.
  154. Checking hard drives
  155. Find the drive containing the repository and use *findmnt*, *mount* or *lsblk*
  156. to learn the device path (typically */dev/...*) of the drive.
  157. Then, smartmontools can retrieve self-diagnostics of the drive in question::
  158. # smartctl -a /dev/sdSomething
  159. The *Offline_Uncorrectable*, *Current_Pending_Sector* and *Reported_Uncorrect*
  160. attributes indicate data corruption. A high *UDMA_CRC_Error_Count* usually
  161. indicates a bad cable.
  162. I/O errors logged by the system (refer to the system journal or
  163. dmesg) can point to issues as well. I/O errors only affecting the
  164. file system easily go unnoticed, since they are not reported to
  165. applications (e.g. Borg), while these errors can still corrupt data.
  166. Drives can corrupt some sectors in one event, while remaining
  167. reliable otherwise. Conversely, drives can fail completely with no
  168. advance warning. If in doubt, copy all data from the drive in
  169. question to another drive -- just in case it fails completely.
  170. If any of these are suspicious, a self-test is recommended::
  171. # smartctl -t long /dev/sdSomething
  172. Running ``fsck`` if not done already might yield further insights.
  173. Checking memory
  174. Intermittent issues, such as ``borg check`` finding errors
  175. inconsistently between runs, are frequently caused by bad memory.
  176. Run memtest86+ (or an equivalent memory tester) to verify that
  177. the memory subsystem is operating correctly.
  178. Checking processors
  179. Processors rarely cause errors. If they do, they are usually overclocked
  180. or otherwise operated outside their specifications. We do not recommend to
  181. operate hardware outside its specifications for productive use.
  182. Tools to verify correct processor operation include Prime95 (mprime), linpack,
  183. and the `Intel Processor Diagnostic Tool
  184. <https://downloadcenter.intel.com/download/19792/Intel-Processor-Diagnostic-Tool>`_
  185. (applies only to Intel processors).
  186. .. rubric:: Repairing a damaged repository
  187. With any defective hardware found and replaced, the damage done to the repository
  188. needs to be ascertained and fixed.
  189. :ref:`borg_check` provides diagnostics and ``--repair`` options for repositories with
  190. issues. We recommend to first run without ``--repair`` to assess the situation.
  191. If the found issues and proposed repairs seem right, re-run "check" with ``--repair`` enabled.
  192. How probable is it to get a hash collision problem?
  193. ---------------------------------------------------
  194. If you noticed, there are some issues (:issue:`170` (**warning: hell**) and :issue:`4884`)
  195. about the probability of a chunk having the same hash as another chunk, making the file
  196. corrupted because it grabbed the wrong chunk. This is called the `Birthday Problem
  197. <https://en.wikipedia.org/wiki/Birthday_problem>`_.
  198. There is a lot of probability in here so, I can give you my interpretation of
  199. such math but it's honestly better that you read it yourself and grab your own
  200. resolution from that.
  201. Assuming that all your chunks have a size of :math:`2^{21}` bytes (approximately 2.1 MB)
  202. and we have a "perfect" hash algorithm, we can think that the probability of collision
  203. would be of :math:`p^2/2^{n+1}` then, using SHA-256 (:math:`n=256`) and for example
  204. we have 1000 million chunks (:math:`p=10^9`) (1000 million chunks would be about 2100TB).
  205. The probability would be around 0.0000000000000000000000000000000000000000000000000000000000043.
  206. A mass-murderer space rock happens about once every 30 million years on average.
  207. This leads to a probability of such an event occurring in the next second to about :math:`10^{-15}`.
  208. That's **45** orders of magnitude more probable than the SHA-256 collision. Briefly stated,
  209. if you find SHA-256 collisions scary then your priorities are wrong. This example was grabbed from
  210. `this SO answer <https://stackoverflow.com/a/4014407/13359375>`_, it's great honestly.
  211. Still, the real question is whether Borg tries not to make this happen?
  212. Well... previously it did not check anything until there was a feature added which saves the size
  213. of the chunks too, so the size of the chunks is compared to the size that you got with the
  214. hash and if the check says there is a mismatch it will raise an exception instead of corrupting
  215. the file. This doesn't save us from everything but reduces the chances of corruption.
  216. There are other ways of trying to escape this but it would affect performance so much that
  217. it wouldn't be worth it and it would contradict Borg's design, so if you don't want this to
  218. happen, simply don't use Borg.
  219. Why is the time elapsed in the archive stats different from wall clock time?
  220. ----------------------------------------------------------------------------
  221. Borg needs to write the time elapsed into the archive metadata before finalizing
  222. the archive and saving the files cache.
  223. This means when Borg is run with e.g. the ``time`` command, the duration shown
  224. in the archive stats may be shorter than the full time the command runs for.
  225. How do I configure different prune policies for different directories?
  226. ----------------------------------------------------------------------
  227. Say you want to prune ``/var/log`` faster than the rest of
  228. ``/``. How do we implement that? The answer is to back up to different
  229. archive *series* and then implement different prune policies for the
  230. different series. For example, you could have a script that does::
  231. borg create --exclude var/log main /
  232. borg create logs /var/log
  233. Then you would have two different prune calls with different policies::
  234. borg prune --verbose --list -d 30 main
  235. borg prune --verbose --list -d 7 logs
  236. This will keep 7 days of logs and 30 days of everything else.
  237. How do I remove files from an existing backup?
  238. ----------------------------------------------
  239. A file is only removed from a BorgBackup repository if all archives that contain
  240. the file are deleted and the corresponding data chunks are removed from the
  241. repository. There are two ways how to remove files from a repository.
  242. 1. Use :ref:`borg_delete` to remove all archives that contain the files. This
  243. will of course delete everything in the archive, not only some files.
  244. 2. If you really want to remove only some specific files, you can run the
  245. :ref:`borg_recreate` command to rewrite all archives with a different
  246. ``--exclude`` pattern. See the examples in the manpage for more information.
  247. Finally, run :ref:`borg_compact` to delete the data chunks from the repository.
  248. Can I safely change the compression level or algorithm?
  249. --------------------------------------------------------
  250. The compression level and algorithm don't affect deduplication. Chunk ID hashes
  251. are calculated *before* compression. New compression settings
  252. will only be applied to new chunks, not existing chunks. So it's safe
  253. to change them.
  254. Use ``borg repo-compress`` to efficiently recompress a complete repository.
  255. Why is backing up an unmodified FAT filesystem slow on Linux?
  256. -------------------------------------------------------------
  257. By default, the files cache used by BorgBackup considers the inode of files.
  258. When an inode number changes compared to the last backup, it hashes the file
  259. again. The ``vfat`` kernel driver does not produce stable inode numbers by
  260. default. One way to achieve stable inode numbering is mounting the filesystem
  261. using ``nfs=nostale_ro``. Doing so implies mounting the filesystem read-only.
  262. Another option is to not consider inode numbers in the files cache by passing
  263. ``--files-cache=ctime,size``.
  264. Why are backups slow on a Linux server that is a member of a Windows domain?
  265. ----------------------------------------------------------------------------
  266. If a Linux server is a member of a Windows domain, username to userid resolution might be
  267. performed via ``winbind`` without caching, which can slow down backups significantly.
  268. You can use e.g. ``nscd`` to add caching and improve the speed.
  269. Security
  270. ########
  271. .. _home_config_borg:
  272. How important is the $HOME/.config/borg directory?
  273. --------------------------------------------------
  274. The Borg config directory has content that you should take care of:
  275. ``keys`` subdirectory
  276. All your borg keyfile keys are stored in this directory. Please note that
  277. borg repokey keys are stored inside the repository. You MUST make sure to have an
  278. independent backup of these keyfiles, otherwise you cannot access your backups anymore if you lose
  279. them. You also MUST keep these files secret; everyone who gains access to your repository and has
  280. the corresponding keyfile (and the key passphrase) can extract it.
  281. Make sure that only you have access to the Borg config directory.
  282. Note about creating multiple keyfile repositories at the same path
  283. ------------------------------------------------------------------
  284. If you create a new keyfile-encrypted repository at the same filesystem
  285. path multiple times (for example, when a previous repository at that path
  286. was moved away or unmounted), Borg will not overwrite or reuse the existing
  287. key file in your keys directory. Instead, it creates a new key file by
  288. appending a numeric suffix to the base name (e.g., .2, .3, ...).
  289. This means you may see multiple key files like:
  290. - ~/.config/borg/keys/home_user_backup
  291. - ~/.config/borg/keys/home_user_backup.2
  292. - ~/.config/borg/keys/home_user_backup.3
  293. Each of these corresponds to a distinct repository created at the same
  294. path at different times. This behavior avoids accidental key reuse or
  295. overwrite.
  296. .. _home_data_borg:
  297. How important is the $HOME/.local/share/borg directory?
  298. -------------------------------------------------------
  299. The Borg data directory has content that you should take care of:
  300. ``security`` subdirectory
  301. Each directory here represents one Borg repository by its ID and contains the last known status.
  302. If a repository's status is different from this information at the beginning of BorgBackup
  303. operation, Borg outputs warning messages and asks for confirmation, so make sure you do not lose
  304. or manipulate these files. However, apart from those warnings, a loss of these files can be
  305. recovered.
  306. Make sure that only you have access to the Borg data directory.
  307. .. _cache_security:
  308. Do I need to take security precautions regarding the cache?
  309. -----------------------------------------------------------
  310. The cache contains a lot of metadata information about the files in
  311. your repositories and it is not encrypted.
  312. However, the assumption is that the cache is being stored on the very
  313. same system which also contains the original files which are being
  314. backed up. So someone with access to the cache files would also have
  315. access the original files anyway.
  316. The Internals section contains more details about :ref:`cache`. If you ever need to move the cache
  317. to a different location, this can be achieved by using the appropriate :ref:`env_vars`.
  318. How can I specify the encryption passphrase programmatically?
  319. -------------------------------------------------------------
  320. There are several ways to specify a passphrase without human intervention:
  321. Setting ``BORG_PASSPHRASE``
  322. The passphrase can be specified using the ``BORG_PASSPHRASE`` environment variable.
  323. This is often the simplest option, but can be insecure if the script that sets it
  324. is world-readable.
  325. .. _password_env:
  326. .. note:: Be careful how you set the environment; using the ``env``
  327. command, a ``system()`` call or using inline shell scripts
  328. (e.g. ``BORG_PASSPHRASE=hunter2 borg ...``)
  329. might expose the credentials in the process list directly
  330. and they will be readable to all users on a system. Using
  331. ``export`` in a shell script file should be safe, however, as
  332. the environment of a process is `accessible only to that
  333. user
  334. <https://security.stackexchange.com/questions/14000/environment-variable-accessibility-in-linux/14009#14009>`_.
  335. Using ``BORG_PASSCOMMAND`` with a file of proper permissions
  336. Another option is to create a file with a password in it in your home
  337. directory and use permissions to keep anyone else from reading it. For
  338. example, first create a key::
  339. (umask 0077; head -c 32 /dev/urandom | base64 -w 0 > ~/.borg-passphrase)
  340. Then in an automated script one can put::
  341. export BORG_PASSCOMMAND="cat $HOME/.borg-passphrase"
  342. and Borg will automatically use that passphrase.
  343. Using keyfile-based encryption with a blank passphrase
  344. It is possible to encrypt your repository in ``keyfile`` mode instead of the default
  345. ``repokey`` mode and use a blank passphrase for the key file (simply press Enter twice
  346. when ``borg repo-create`` asks for the password). See :ref:`encrypted_repos`
  347. for more details.
  348. Using ``BORG_PASSCOMMAND`` with macOS Keychain
  349. macOS has a native manager for secrets (such as passphrases) which is safer
  350. than just using a file as it is encrypted at rest and unlocked manually
  351. (fortunately, the login keyring automatically unlocks when you log in). With
  352. the built-in ``security`` command, you can access it from the command line,
  353. making it useful for ``BORG_PASSCOMMAND``.
  354. First generate a passphrase and use ``security`` to save it to your login
  355. (default) keychain::
  356. security add-generic-password -D secret -U -a $USER -s borg-passphrase -w $(head -c 32 /dev/urandom | base64 -w 0)
  357. In your backup script retrieve it in the ``BORG_PASSCOMMAND``::
  358. export BORG_PASSCOMMAND="security find-generic-password -a $USER -s borg-passphrase -w"
  359. Using ``BORG_PASSCOMMAND`` with GNOME Keyring
  360. GNOME also has a keyring daemon that can be used to store a Borg passphrase.
  361. First ensure ``libsecret-tools``, ``gnome-keyring`` and ``libpam-gnome-keyring``
  362. are installed. If ``libpam-gnome-keyring`` wasn't already installed, ensure it
  363. runs on login::
  364. sudo sh -c "echo session optional pam_gnome_keyring.so auto_start >> /etc/pam.d/login"
  365. sudo sh -c "echo password optional pam_gnome_keyring.so >> /etc/pam.d/passwd"
  366. # you may need to relogin afterwards to activate the login keyring
  367. Then add a secret to the login keyring::
  368. head -c 32 /dev/urandom | base64 -w 0 | secret-tool store borg-repository repo-name --label="Borg Passphrase"
  369. If a dialog box pops up prompting you to pick a password for a new keychain, use your
  370. login password. If there is a checkbox for automatically unlocking on login, check it
  371. to allow backups without any user intervention whatsoever.
  372. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  373. export BORG_PASSCOMMAND="secret-tool lookup borg-repository repo-name"
  374. .. note:: For this to unlock the keychain automatically it must be run
  375. in the ``dbus`` session of an unlocked terminal; for example, running a backup
  376. script as a ``cron`` job might not work unless you also ``export DISPLAY=:0``
  377. so ``secret-tool`` can pick up your open session. `It gets even more complicated`__
  378. when you are running the tool as a different user (e.g. running a backup as root
  379. with the password stored in the user keyring).
  380. __ https://github.com/borgbackup/borg/pull/2837#discussion_r127641330
  381. Using ``BORG_PASSCOMMAND`` with KWallet
  382. KDE also has a keychain feature in the form of KWallet. The command-line tool
  383. ``kwalletcli`` can be used to store and retrieve secrets. Ensure ``kwalletcli``
  384. is installed, generate a passphrase, and store it in your "wallet"::
  385. head -c 32 /dev/urandom | base64 -w 0 | kwalletcli -Pe borg-passphrase -f Passwords
  386. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  387. export BORG_PASSCOMMAND="kwalletcli -e borg-passphrase -f Passwords"
  388. When backing up to remote encrypted repos, is encryption done locally?
  389. ----------------------------------------------------------------------
  390. Yes, file and directory metadata and data is locally encrypted, before
  391. leaving the local machine. We do not mean the transport layer encryption
  392. by that, but the data/metadata itself. Transport layer encryption (e.g.
  393. when ssh is used as a transport) applies additionally.
  394. When backing up to remote servers, do I have to trust the remote server?
  395. ------------------------------------------------------------------------
  396. Yes and No.
  397. No, as far as data confidentiality is concerned - if you use encryption,
  398. all your files/dirs data and metadata are stored in their encrypted form
  399. into the repository.
  400. Yes, as an attacker with access to the remote server could delete (or
  401. otherwise make unavailable) all your backups.
  402. How can I protect against a hacked backup client?
  403. -------------------------------------------------
  404. Assume you back up your backup client machine C to the backup server S and
  405. C gets hacked. In a simple push setup, the attacker could then use borg on
  406. C to delete all backups residing on S.
  407. These are your options to protect against that:
  408. - Use a pull-mode setup using ``ssh -R``, see :ref:`pull_backup` for more information.
  409. - Mount C's filesystem on another machine and then create a backup of it.
  410. - Do not give C filesystem-level access to S.
  411. See :ref:`hosting_repositories` for a detailed protection guide.
  412. How can I protect against a hacked backup server?
  413. -------------------------------------------------
  414. Just in case you got the impression that pull-mode backups are way more safe
  415. than push-mode, you also need to consider the case that your backup server S
  416. gets hacked. In case S has access to a lot of clients C, that might bring you
  417. into even bigger trouble than a hacked backup client in the previous FAQ entry.
  418. These are your options to protect against that:
  419. - Use the standard push-mode setup (see also previous FAQ entry).
  420. - Mount (the repo part of) S's filesystem on C.
  421. - Do not give S file-system level access to C.
  422. - Have your backup server at a well protected place (maybe not reachable from
  423. the internet), configure it safely, apply security updates, monitor it, ...
  424. How can I protect against theft, sabotage, lightning, fire, ...?
  425. ----------------------------------------------------------------
  426. In general: if your only backup medium is nearby the backupped machine and
  427. always connected, you can easily get into trouble: they likely share the same
  428. fate if something goes really wrong.
  429. Thus:
  430. - have multiple backup media
  431. - have media disconnected from network, power, computer
  432. - have media at another place
  433. - have a relatively recent backup on your media
  434. How do I report a security issue with Borg?
  435. -------------------------------------------
  436. Send a private email to the :ref:`security contact <security-contact>`
  437. if you think you have discovered a security issue.
  438. Please disclose security issues responsibly.
  439. Common issues
  440. #############
  441. /path/to/repo is not a valid repository. Check repo config.
  442. -----------------------------------------------------------
  443. There can be many causes of this error. E.g. you have incorrectly specified the repository path.
  444. 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.
  445. We recommend upgrading to the latest stable version and trying again. We are sorry. We should have thought about forward
  446. compatibility and implemented a more helpful error message.
  447. Why am I seeing idle borg serve processes on the repo server?
  448. -------------------------------------------------------------
  449. Please see the next question.
  450. Why does Borg disconnect or hang when backing up to a remote server?
  451. --------------------------------------------------------------------
  452. Communication with the remote server (using an ssh: repo URL) happens via an SSH
  453. connection. This can lead to some issues that would not occur during a local backup:
  454. - Since Borg does not send data all the time, the connection may get closed, leading
  455. to errors like "connection closed by remote".
  456. - On the other hand, network issues may lead to a dysfunctional connection
  457. that is only detected after some time by the server, leading to stale ``borg serve``
  458. processes and locked repositories.
  459. To fix such problems, please apply these :ref:`SSH settings <ssh_configuration>` so that
  460. keep-alive requests are sent regularly.
  461. How can I deal with my very unstable SSH connection?
  462. ----------------------------------------------------
  463. If you have issues with lost connections during long-running borg commands, you
  464. could try to work around:
  465. - Make partial extracts like ``borg extract PATTERN`` to do multiple
  466. smaller extraction runs that complete before your connection has issues.
  467. - Try using ``borg mount MOUNTPOINT`` and ``rsync -avH`` from
  468. ``MOUNTPOINT`` to your desired extraction directory. If the connection breaks
  469. down, just repeat that over and over again until rsync does not find anything
  470. to do any more. Due to the way borg mount works, this might be less efficient
  471. than borg extract for bigger volumes of data.
  472. Can I back up my root partition (/) with Borg?
  473. ----------------------------------------------
  474. Backing up your entire root partition works just fine, but remember to
  475. exclude directories that make no sense to back up, such as /dev, /proc,
  476. /sys, /tmp and /run, and to use ``--one-file-system`` if you only want to
  477. back up the root partition (and not any mounted devices e.g.).
  478. If it crashes with a UnicodeError, what can I do?
  479. -------------------------------------------------
  480. Check if your encoding is set correctly. For most POSIX-like systems, try::
  481. export LANG=en_US.UTF-8 # or similar, important is correct charset
  482. If that does not help:
  483. - check for typos, check if you really used ``export``.
  484. - check if you have set ``LC_ALL`` - if so, try not setting it.
  485. - check if you generated the respective locale via ``locale-gen``.
  486. I can't extract non-ascii filenames by giving them on the commandline!?
  487. -----------------------------------------------------------------------
  488. This might be due to different ways to represent some characters in unicode
  489. or due to other non-ascii encoding issues.
  490. If you run into that, try this:
  491. - avoid the non-ascii characters on the commandline by e.g. extracting
  492. the parent directory (or even everything)
  493. - mount the repo using FUSE and use some file manager
  494. .. _expected_performance:
  495. What's the expected backup performance?
  496. ---------------------------------------
  497. Compared to simply copying files (e.g. with ``rsync``), Borg has more work to do.
  498. This can make creation of the first archive slower, but saves time
  499. and disk space on subsequent runs. Here what Borg does when you run ``borg create``:
  500. - Borg chunks the file (using the relatively expensive buzhash algorithm)
  501. - It then computes the "id" of the chunk (hmac-sha256 (slow, except
  502. if your CPU has sha256 acceleration) or blake2b (fast, in software))
  503. - Then it checks whether this chunk is already in the repo (local hashtable lookup,
  504. fast). If so, the processing of the chunk is completed here. Otherwise it needs to
  505. process the chunk:
  506. - Compresses (the default lz4 is super fast)
  507. - Encrypts and authenticates (AES-OCB, usually fast if your CPU has AES acceleration as usual
  508. since about 10y, or chacha20-poly1305, fast pure-software crypto)
  509. - Transmits to repo. If the repo is remote, this usually involves an SSH connection
  510. (does its own encryption / authentication).
  511. - Stores the chunk into a key/value store (the key is the chunk id, the value
  512. is the data). While doing that, it computes XXH64 of the data (repo low-level
  513. checksum, used by borg check --repository).
  514. Subsequent backups are usually very fast if most files are unchanged and only
  515. a few are new or modified. The high performance on unchanged files primarily depends
  516. only on a few factors (like FS recursion + metadata reading performance and the
  517. files cache working as expected) and much less on other factors.
  518. E.g., for this setup:
  519. - server grade machine (4C/8T 2013 Xeon, 64GB RAM, 2x good 7200RPM disks)
  520. - local zfs filesystem (mirrored) containing the backup source data
  521. - repository is remote (does not matter much for unchanged files)
  522. - backup job runs while machine is otherwise idle
  523. The observed performance is that Borg can process about
  524. **1 million unchanged files (and a few small changed ones) in 4 minutes!**
  525. If you are seeing much less than that in similar circumstances, read the next
  526. few FAQ entries below.
  527. .. _slow_backup:
  528. Why is my backup so slow?
  529. --------------------------
  530. If you feel your Borg backup is too slow somehow, here is what you can do:
  531. - Make sure Borg has enough RAM (depends on how big your repo is / how many
  532. files you have)
  533. - Use one of the blake2 modes for --encryption except if you positively know
  534. your CPU (and openssl) accelerates sha256 (then stay with hmac-sha256).
  535. - Don't use any expensive compression. The default is lz4 and super fast.
  536. Uncompressed is often slower than lz4.
  537. - Just wait. You can also interrupt it and start it again as often as you like,
  538. it will converge against a valid "completed" state. It is starting
  539. from the beginning each time, but it is still faster then as it does not store
  540. data into the repo which it already has there.
  541. - If you don’t need additional file attributes, you can disable them with ``--noflags``,
  542. ``--noacls``, ``--noxattrs``. This can lead to noticeable performance improvements
  543. when your backup consists of many small files.
  544. To see what files have changed and take more time processing, you can also add
  545. ``--list --filter=AME --stats`` to your ``borg create`` call to produce more log output,
  546. including a file list (with file status characters) and also some statistics at
  547. the end of the backup.
  548. Then you do the backup and look at the log output:
  549. - stats: Do you really have little changes or are there more changes than you thought?
  550. In the stats you can see the overall volume of changed data, which needed to be
  551. added to the repo. If that is a lot, that can be the reason why it is slow.
  552. - ``A`` status ("added") in the file list:
  553. If you see that often, you have a lot of new files (files that Borg did not find
  554. in the files cache). If you think there is something wrong with that (the file was there
  555. already in the previous backup), please read the FAQ entries below.
  556. - ``M`` status ("modified") in the file list:
  557. If you see that often, Borg thinks that a lot of your files might be modified
  558. (Borg found them in the files cache, but the metadata read from the filesystem did
  559. not match the metadata stored in the files cache).
  560. In such a case, Borg will need to process the files' contents completely, which is
  561. much slower than processing unmodified files (Borg does not read their contents!).
  562. The metadata values used in this comparison are determined by the ``--files-cache`` option
  563. and could be e.g. size, ctime and inode number (see the ``borg create`` docs for more
  564. details and potential issues).
  565. You can use the ``stat`` command on files to look at fs metadata manually to debug if
  566. there is any unexpected change triggering the ``M`` status.
  567. Also, the ``--debug-topic=files_cache`` option of ``borg create`` provides a lot of debug
  568. output helping to analyse why the files cache does not give its expected high performance.
  569. When borg runs inside a virtual machine, there are some more things to look at:
  570. Some hypervisors (e.g. kvm on proxmox) give some broadly compatible CPU type to the
  571. VM (usually to ease migration between VM hosts of potentially different hardware CPUs).
  572. It is broadly compatible because they leave away modern CPU features that could be
  573. not present in older or other CPUs, e.g. hardware acceleration for AES crypto, for
  574. sha2 hashes, for (P)CLMUL(QDQ) computations useful for crc32.
  575. So, basically you pay for compatibility with bad performance. If you prefer better
  576. performance, you should try to expose the host CPU's misc. hw acceleration features
  577. to the VM which runs borg.
  578. On Linux, check ``/proc/cpuinfo`` for the CPU flags inside the VM.
  579. For kvm check the docs about "Host model" and "Host passthrough".
  580. See also the next few FAQ entries for more details.
  581. .. _a_status_oddity:
  582. I am seeing 'A' (added) status for an unchanged file!?
  583. ------------------------------------------------------
  584. The files cache is used to determine whether Borg already
  585. "knows" / has backed up a file and if so, to skip the file from
  586. chunking. It intentionally *excludes* files that have a timestamp
  587. which is the same as the newest timestamp in the created archive.
  588. So, if you see an 'A' status for unchanged file(s), they are likely the files
  589. with the most recent timestamp in that archive.
  590. This is expected: it is to avoid data loss with files that are backed up from
  591. a snapshot and that are immediately changed after the snapshot (but within
  592. timestamp granularity time, so the timestamp would not change). Without the code that
  593. removes these files from the files cache, the change that happened right after
  594. the snapshot would not be contained in the next backup as Borg would
  595. think the file is unchanged.
  596. This does not affect deduplication, the file will be chunked, but as the chunks
  597. will often be the same and already stored in the repo (except in the above
  598. mentioned rare condition), it will just re-use them as usual and not store new
  599. data chunks.
  600. If you want to avoid unnecessary chunking, just create or touch a small or
  601. empty file in your backup source file set (so that one has the latest timestamp,
  602. not your 50GB VM disk image) and, if you do snapshots, do the snapshot after
  603. that.
  604. Since only the files cache is used in the display of files status,
  605. those files are reported as being added when, really, chunks are
  606. already used.
  607. By default, ctime (change time) is used for the timestamps to have a rather
  608. safe change detection (see also the --files-cache option).
  609. Furthermore, pathnames used as key into the files cache are **as archived**,
  610. so make sure these are always the same (see ``borg list``).
  611. .. _always_chunking:
  612. It always chunks all my files, even unchanged ones!
  613. ---------------------------------------------------
  614. Borg maintains a files cache where it remembers the timestamps, size and
  615. inode of files. When Borg does a new backup and starts processing a
  616. file, it first looks whether the file has changed (compared to the values
  617. stored in the files cache). If the values are the same, the file is assumed
  618. unchanged and thus its contents won't get chunked (again).
  619. The files cache is stored separately (using a different filename suffix) per
  620. archive series, thus using always the same name for the archive is strongly
  621. recommended. The "rebuild files cache from previous archive in repo" feature
  622. also depends on that.
  623. Alternatively, there is also BORG_FILES_CACHE_SUFFIX which can be used to
  624. manually set a custom suffix (if you can't just use the same archive name).
  625. Another possible reason is that files don't always have the same path -
  626. borg uses the paths as seen in the archive when using ``borg list``.
  627. It is possible for some filesystems, such as ``mergerfs`` or network filesystems,
  628. to return inconsistent inode numbers across runs, causing borg to consider them changed.
  629. A workaround is to set the option ``--files-cache=ctime,size`` to exclude the inode
  630. number comparison from the files cache check so that files with different inode
  631. numbers won't be treated as modified.
  632. Using a pure-python msgpack! This will result in lower performance.
  633. -------------------------------------------------------------------
  634. borg uses `msgpack` to serialize/deserialize data.
  635. `msgpack` has 2 implementations:
  636. - a fast one (C code compiled into a platform specific binary), and
  637. - a slow pure-python one.
  638. The slow one is used if it can't successfully import the fast one.
  639. If you use the pyinstaller-made borg "fat binary" which we offer on github
  640. releases, it could be that you downloaded a binary that does not match the
  641. (g)libc on your system.
  642. Binaries made for an older glibc than the one you have on your system usually
  643. just work, but the opposite is not necessarily the case and can lead to misc.
  644. issues - like failing to load the fast msgpack code or not working at all.
  645. So: try a binary made for an older glibc.
  646. If you see this without using a "fat binary" from us, it usually means that
  647. msgpack is not built / installed correctly. It could be also that the platform
  648. is not fully supported (so the python code works, but there is no fast binary
  649. code).
  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.