faq.rst 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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 an 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 stress-ng.
  184. .. rubric:: Repairing a damaged repository
  185. With any defective hardware found and replaced, the damage done to the repository
  186. needs to be ascertained and fixed.
  187. :ref:`borg_check` provides diagnostics and ``--repair`` options for repositories with
  188. issues. We recommend to first run without ``--repair`` to assess the situation.
  189. If the found issues and proposed repairs seem right, re-run "check" with ``--repair`` enabled.
  190. How probable is it to get a hash collision problem?
  191. ---------------------------------------------------
  192. If you noticed, there are some issues (:issue:`170` (**warning: hell**) and :issue:`4884`)
  193. about the probability of a chunk having the same hash as another chunk, making the file
  194. corrupted because it grabbed the wrong chunk. This is called the `Birthday Problem
  195. <https://en.wikipedia.org/wiki/Birthday_problem>`_.
  196. There is a lot of probability in here so, I can give you my interpretation of
  197. such math but it's honestly better that you read it yourself and grab your own
  198. resolution from that.
  199. Assuming that all your chunks have a size of :math:`2^{21}` bytes (approximately 2.1 MB)
  200. and we have a "perfect" hash algorithm, we can think that the probability of collision
  201. would be of :math:`p^2/2^{n+1}` then, using SHA-256 (:math:`n=256`) and for example
  202. we have 1000 million chunks (:math:`p=10^9`) (1000 million chunks would be about 2100TB).
  203. The probability would be around 0.0000000000000000000000000000000000000000000000000000000000043.
  204. A mass-murderer space rock happens about once every 30 million years on average.
  205. This leads to a probability of such an event occurring in the next second to about :math:`10^{-15}`.
  206. That's **45** orders of magnitude more probable than the SHA-256 collision. Briefly stated,
  207. if you find SHA-256 collisions scary then your priorities are wrong. This example was grabbed from
  208. `this SO answer <https://stackoverflow.com/a/4014407/13359375>`_, it's great honestly.
  209. Still, the real question is whether Borg tries not to make this happen?
  210. Well... previously it did not check anything until there was a feature added which saves the size
  211. of the chunks too, so the size of the chunks is compared to the size that you got with the
  212. hash and if the check says there is a mismatch it will raise an exception instead of corrupting
  213. the file. This doesn't save us from everything but reduces the chances of corruption.
  214. There are other ways of trying to escape this but it would affect performance so much that
  215. it wouldn't be worth it and it would contradict Borg's design, so if you don't want this to
  216. happen, simply don't use Borg.
  217. Why is the time elapsed in the archive stats different from wall clock time?
  218. ----------------------------------------------------------------------------
  219. Borg needs to write the time elapsed into the archive metadata before finalizing
  220. the archive and saving the files cache.
  221. This means when Borg is run with e.g. the ``time`` command, the duration shown
  222. in the archive stats may be shorter than the full time the command runs for.
  223. How do I configure different prune policies for different directories?
  224. ----------------------------------------------------------------------
  225. Say you want to prune ``/var/log`` faster than the rest of
  226. ``/``. How do we implement that? The answer is to back up to different
  227. archive *series* and then implement different prune policies for the
  228. different series. For example, you could have a script that does::
  229. borg create --exclude var/log main /
  230. borg create logs /var/log
  231. Then you would have two different prune calls with different policies::
  232. borg prune --verbose --list -d 30 main
  233. borg prune --verbose --list -d 7 logs
  234. This will keep 7 days of logs and 30 days of everything else.
  235. How do I remove files from an existing backup?
  236. ----------------------------------------------
  237. A file is only removed from a BorgBackup repository if all archives that contain
  238. the file are deleted and the corresponding data chunks are removed from the
  239. repository. There are two ways how to remove files from a repository.
  240. 1. Use :ref:`borg_delete` to remove all archives that contain the files. This
  241. will of course delete everything in the archive, not only some files.
  242. 2. If you really want to remove only some specific files, you can run the
  243. :ref:`borg_recreate` command to rewrite all archives with a different
  244. ``--exclude`` pattern. See the examples in the manpage for more information.
  245. Finally, run :ref:`borg_compact` to delete the data chunks from the repository.
  246. Can I safely change the compression level or algorithm?
  247. --------------------------------------------------------
  248. The compression level and algorithm don't affect deduplication. Chunk ID hashes
  249. are calculated *before* compression. New compression settings
  250. will only be applied to new chunks, not existing chunks. So it's safe
  251. to change them.
  252. Use ``borg repo-compress`` to efficiently recompress a complete repository.
  253. Why is backing up an unmodified FAT filesystem slow on Linux?
  254. -------------------------------------------------------------
  255. By default, the files cache used by BorgBackup considers the inode of files.
  256. When an inode number changes compared to the last backup, it hashes the file
  257. again. The ``vfat`` kernel driver does not produce stable inode numbers by
  258. default. One way to achieve stable inode numbering is mounting the filesystem
  259. using ``nfs=nostale_ro``. Doing so implies mounting the filesystem read-only.
  260. Another option is to not consider inode numbers in the files cache by passing
  261. ``--files-cache=ctime,size``.
  262. Why are backups slow on a Linux server that is a member of a Windows domain?
  263. ----------------------------------------------------------------------------
  264. If a Linux server is a member of a Windows domain, username to userid resolution might be
  265. performed via ``winbind`` without caching, which can slow down backups significantly.
  266. You can use e.g. ``nscd`` to add caching and improve the speed.
  267. Security
  268. ########
  269. .. _home_config_borg:
  270. How important is the $HOME/.config/borg directory?
  271. --------------------------------------------------
  272. The Borg config directory has content that you should take care of:
  273. ``keys`` subdirectory
  274. All your borg keyfile keys are stored in this directory. Please note that
  275. borg repokey keys are stored inside the repository. You MUST make sure to have an
  276. independent backup of these keyfiles, otherwise you cannot access your backups anymore if you lose
  277. them. You also MUST keep these files secret; everyone who gains access to your repository and has
  278. the corresponding keyfile (and the key passphrase) can extract it.
  279. Make sure that only you have access to the Borg config directory.
  280. Note about creating multiple keyfile repositories at the same path
  281. ------------------------------------------------------------------
  282. If you create a new keyfile-encrypted repository at the same filesystem
  283. path multiple times (for example, when a previous repository at that path
  284. was moved away or unmounted), Borg will not overwrite or reuse the existing
  285. key file in your keys directory. Instead, it creates a new key file by
  286. appending a numeric suffix to the base name (e.g., .2, .3, ...).
  287. This means you may see multiple key files like:
  288. - ~/.config/borg/keys/home_user_backup
  289. - ~/.config/borg/keys/home_user_backup.2
  290. - ~/.config/borg/keys/home_user_backup.3
  291. Each of these corresponds to a distinct repository created at the same
  292. path at different times. This behavior avoids accidental key reuse or
  293. overwrite.
  294. .. _home_data_borg:
  295. How important is the $HOME/.local/share/borg directory?
  296. -------------------------------------------------------
  297. The Borg data directory has content that you should take care of:
  298. ``security`` subdirectory
  299. Each directory here represents one Borg repository by its ID and contains the last known status.
  300. If a repository's status is different from this information at the beginning of BorgBackup
  301. operation, Borg outputs warning messages and asks for confirmation, so make sure you do not lose
  302. or manipulate these files. However, apart from those warnings, a loss of these files can be
  303. recovered.
  304. Make sure that only you have access to the Borg data directory.
  305. .. _cache_security:
  306. Do I need to take security precautions regarding the cache?
  307. -----------------------------------------------------------
  308. The cache contains a lot of metadata information about the files in
  309. your repositories and it is not encrypted.
  310. However, the assumption is that the cache is being stored on the very
  311. same system which also contains the original files which are being
  312. backed up. So someone with access to the cache files would also have
  313. access the original files anyway.
  314. The Internals section contains more details about :ref:`cache`. If you ever need to move the cache
  315. to a different location, this can be achieved by using the appropriate :ref:`env_vars`.
  316. How can I specify the encryption passphrase programmatically?
  317. -------------------------------------------------------------
  318. There are several ways to specify a passphrase without human intervention:
  319. Setting ``BORG_PASSPHRASE``
  320. The passphrase can be specified using the ``BORG_PASSPHRASE`` environment variable.
  321. This is often the simplest option, but can be insecure if the script that sets it
  322. is world-readable.
  323. .. _password_env:
  324. .. note:: Be careful how you set the environment; using the ``env``
  325. command, a ``system()`` call or using inline shell scripts
  326. (e.g. ``BORG_PASSPHRASE=hunter2 borg ...``)
  327. might expose the credentials in the process list directly
  328. and they will be readable to all users on a system. Using
  329. ``export`` in a shell script file should be safe, however, as
  330. the environment of a process is `accessible only to that
  331. user
  332. <https://security.stackexchange.com/questions/14000/environment-variable-accessibility-in-linux/14009#14009>`_.
  333. Using ``BORG_PASSCOMMAND`` with a file of proper permissions
  334. Another option is to create a file with a password in it in your home
  335. directory and use permissions to keep anyone else from reading it. For
  336. example, first create a key::
  337. (umask 0077; head -c 32 /dev/urandom | base64 -w 0 > ~/.borg-passphrase)
  338. Then in an automated script one can put::
  339. export BORG_PASSCOMMAND="cat $HOME/.borg-passphrase"
  340. and Borg will automatically use that passphrase.
  341. Using keyfile-based encryption with a blank passphrase
  342. It is possible to encrypt your repository in ``keyfile`` mode instead of the default
  343. ``repokey`` mode and use a blank passphrase for the key file (simply press Enter twice
  344. when ``borg repo-create`` asks for the password). See :ref:`encrypted_repos`
  345. for more details.
  346. Using ``BORG_PASSCOMMAND`` with macOS Keychain
  347. macOS has a native manager for secrets (such as passphrases) which is safer
  348. than just using a file as it is encrypted at rest and unlocked manually
  349. (fortunately, the login keyring automatically unlocks when you log in). With
  350. the built-in ``security`` command, you can access it from the command line,
  351. making it useful for ``BORG_PASSCOMMAND``.
  352. First generate a passphrase and use ``security`` to save it to your login
  353. (default) keychain::
  354. security add-generic-password -D secret -U -a $USER -s borg-passphrase -w $(head -c 32 /dev/urandom | base64 -w 0)
  355. In your backup script retrieve it in the ``BORG_PASSCOMMAND``::
  356. export BORG_PASSCOMMAND="security find-generic-password -a $USER -s borg-passphrase -w"
  357. Using ``BORG_PASSCOMMAND`` with GNOME Keyring
  358. GNOME also has a keyring daemon that can be used to store a Borg passphrase.
  359. First ensure ``libsecret-tools``, ``gnome-keyring`` and ``libpam-gnome-keyring``
  360. are installed. If ``libpam-gnome-keyring`` wasn't already installed, ensure it
  361. runs on login::
  362. sudo sh -c "echo session optional pam_gnome_keyring.so auto_start >> /etc/pam.d/login"
  363. sudo sh -c "echo password optional pam_gnome_keyring.so >> /etc/pam.d/passwd"
  364. # you may need to relogin afterwards to activate the login keyring
  365. Then add a secret to the login keyring::
  366. head -c 32 /dev/urandom | base64 -w 0 | secret-tool store borg-repository repo-name --label="Borg Passphrase"
  367. If a dialog box pops up prompting you to pick a password for a new keychain, use your
  368. login password. If there is a checkbox for automatically unlocking on login, check it
  369. to allow backups without any user intervention whatsoever.
  370. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  371. export BORG_PASSCOMMAND="secret-tool lookup borg-repository repo-name"
  372. .. note:: For this to unlock the keychain automatically it must be run
  373. in the ``dbus`` session of an unlocked terminal; for example, running a backup
  374. script as a ``cron`` job might not work unless you also ``export DISPLAY=:0``
  375. so ``secret-tool`` can pick up your open session. `It gets even more complicated`__
  376. when you are running the tool as a different user (e.g. running a backup as root
  377. with the password stored in the user keyring).
  378. __ https://github.com/borgbackup/borg/pull/2837#discussion_r127641330
  379. Using ``BORG_PASSCOMMAND`` with KWallet
  380. KDE also has a keychain feature in the form of KWallet. The command-line tool
  381. ``kwalletcli`` can be used to store and retrieve secrets. Ensure ``kwalletcli``
  382. is installed, generate a passphrase, and store it in your "wallet"::
  383. head -c 32 /dev/urandom | base64 -w 0 | kwalletcli -Pe borg-passphrase -f Passwords
  384. Once the secret is saved, retrieve it in a backup script using ``BORG_PASSCOMMAND``::
  385. export BORG_PASSCOMMAND="kwalletcli -e borg-passphrase -f Passwords"
  386. When backing up to remote encrypted repos, is encryption done locally?
  387. ----------------------------------------------------------------------
  388. Yes, file and directory metadata and data is locally encrypted, before
  389. leaving the local machine. We do not mean the transport layer encryption
  390. by that, but the data/metadata itself. Transport layer encryption (e.g.
  391. when ssh is used as a transport) applies additionally.
  392. When backing up to remote servers, do I have to trust the remote server?
  393. ------------------------------------------------------------------------
  394. Yes and No.
  395. No, as far as data confidentiality is concerned - if you use encryption,
  396. all your files/dirs data and metadata are stored in their encrypted form
  397. into the repository.
  398. Yes, as an attacker with access to the remote server could delete (or
  399. otherwise make unavailable) all your backups on that server.
  400. How can I protect against a hacked backup client?
  401. -------------------------------------------------
  402. Assume you back up your backup client machine C to the backup server S and
  403. C gets hacked. In a simple push setup, the attacker could then use borg on
  404. C to delete all backups residing on S.
  405. These are your options to protect against that:
  406. - Use a pull-mode setup using ``ssh -R``, see :ref:`pull_backup` for more information.
  407. - Mount C's filesystem on another machine and then create a backup of it.
  408. - Do not give C filesystem-level access to S.
  409. See :ref:`hosting_repositories` for a detailed protection guide.
  410. How can I protect against a hacked backup server?
  411. -------------------------------------------------
  412. Just in case you got the impression that pull-mode backups are way more safe
  413. than push-mode, you also need to consider the case that your backup server S
  414. gets hacked. In case S has access to a lot of clients C, that might bring you
  415. into even bigger trouble than a hacked backup client in the previous FAQ entry.
  416. These are your options to protect against that:
  417. - Use the standard push-mode setup (see also previous FAQ entry).
  418. - Mount (the repo part of) S's filesystem on C.
  419. - Do not give S file-system level access to C.
  420. - Have your backup server at a well protected place (maybe not reachable from
  421. the internet), configure it safely, apply security updates, monitor it, ...
  422. How can I protect against theft, sabotage, lightning, fire, ...?
  423. ----------------------------------------------------------------
  424. In general: if your only backup medium is nearby the backupped machine and
  425. always connected, you can easily get into trouble: they likely share the same
  426. fate if something goes really wrong.
  427. Thus:
  428. - have multiple backup media
  429. - have media disconnected from network, power, computer
  430. - have media at another place
  431. - have a relatively recent backup on your media
  432. How do I report a security issue with Borg?
  433. -------------------------------------------
  434. Send a private email to the :ref:`security contact <security-contact>`
  435. if you think you have discovered a security issue.
  436. Please disclose security issues responsibly.
  437. Common issues
  438. #############
  439. /path/to/repo is not a valid repository. Check repo config.
  440. -----------------------------------------------------------
  441. There can be many causes of this error. E.g. you have incorrectly specified the repository path.
  442. 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.
  443. We recommend upgrading to the latest stable version and trying again. We are sorry. We should have thought about forward
  444. compatibility and implemented a more helpful error message.
  445. Why am I seeing idle borg serve processes on the repo server?
  446. -------------------------------------------------------------
  447. Please see the next question.
  448. Why does Borg disconnect or hang when backing up to a remote server?
  449. --------------------------------------------------------------------
  450. Communication with the remote server (using an ssh: repo URL) happens via an SSH
  451. connection. This can lead to some issues that would not occur during a local backup:
  452. - Since Borg does not send data all the time, the connection may get closed, leading
  453. to errors like "connection closed by remote".
  454. - On the other hand, network issues may lead to a dysfunctional connection
  455. that is only detected after some time by the server, leading to stale ``borg serve``
  456. processes and locked repositories.
  457. To fix such problems, please apply these :ref:`SSH settings <ssh_configuration>` so that
  458. keep-alive requests are sent regularly.
  459. How can I deal with my very unstable SSH connection?
  460. ----------------------------------------------------
  461. If you have issues with lost connections during long-running borg commands, you
  462. could try to work around:
  463. - Make partial extracts like ``borg extract PATTERN`` to do multiple
  464. smaller extraction runs that complete before your connection has issues.
  465. - Try using ``borg mount MOUNTPOINT`` and ``rsync -avH`` from
  466. ``MOUNTPOINT`` to your desired extraction directory. If the connection breaks
  467. down, just repeat that over and over again until rsync does not find anything
  468. to do any more. Due to the way borg mount works, this might be less efficient
  469. than borg extract for bigger volumes of data.
  470. Can I back up my root partition (/) with Borg?
  471. ----------------------------------------------
  472. Backing up your entire root partition works just fine, but remember to
  473. exclude directories that make no sense to back up, such as /dev, /proc,
  474. /sys, /tmp and /run, and to use ``--one-file-system`` if you only want to
  475. back up the root partition (and not any mounted devices e.g.).
  476. If it crashes with a UnicodeError, what can I do?
  477. -------------------------------------------------
  478. Check if your encoding is set correctly. For most POSIX-like systems, try::
  479. export LANG=en_US.UTF-8 # or similar, important is correct charset
  480. If that does not help:
  481. - check for typos, check if you really used ``export``.
  482. - check if you have set ``LC_ALL`` - if so, try not setting it.
  483. - check if you generated the respective locale via ``locale-gen``.
  484. I can't extract non-ascii filenames by giving them on the commandline!?
  485. -----------------------------------------------------------------------
  486. This might be due to different ways to represent some characters in unicode
  487. or due to other non-ascii encoding issues.
  488. If you run into that, try this:
  489. - avoid the non-ascii characters on the commandline by e.g. extracting
  490. the parent directory (or even everything)
  491. - mount the repo using FUSE and use some file manager
  492. .. _expected_performance:
  493. What's the expected backup performance?
  494. ---------------------------------------
  495. Compared to simply copying files (e.g. with ``rsync``), Borg has more work to do.
  496. This can make creation of the first archive slower, but saves time
  497. and disk space on subsequent runs. Here what Borg does when you run ``borg create``:
  498. - Borg chunks the file (using the relatively expensive buzhash algorithm)
  499. - It then computes the "id" of the chunk (hmac-sha256 (slow, except
  500. if your CPU has sha256 acceleration) or blake2b (fast, in software))
  501. - Then it checks whether this chunk is already in the repo (local hashtable lookup,
  502. fast). If so, the processing of the chunk is completed here. Otherwise it needs to
  503. process the chunk:
  504. - Compresses (the default lz4 is super fast)
  505. - Encrypts and authenticates (AES-OCB, usually fast if your CPU has AES acceleration as usual
  506. since about 10y, or chacha20-poly1305, fast pure-software crypto)
  507. - Transmits to repo. If the repo is remote, this usually involves an SSH connection
  508. (does its own encryption / authentication).
  509. - Stores the chunk into a key/value store (the key is the chunk id, the value
  510. is the data). While doing that, it computes XXH64 of the data (repo low-level
  511. checksum, used by borg check --repository).
  512. Subsequent backups are usually very fast if most files are unchanged and only
  513. a few are new or modified. The high performance on unchanged files primarily depends
  514. only on a few factors (like FS recursion + metadata reading performance and the
  515. files cache working as expected) and much less on other factors.
  516. E.g., for this setup:
  517. - server grade machine (4C/8T 2013 Xeon, 64GB RAM, 2x good 7200RPM disks)
  518. - local zfs filesystem (mirrored) containing the backup source data
  519. - repository is remote (does not matter much for unchanged files)
  520. - backup job runs while machine is otherwise idle
  521. The observed performance is that Borg can process about
  522. **1 million unchanged files (and a few small changed ones) in 4 minutes!**
  523. If you are seeing much less than that in similar circumstances, read the next
  524. few FAQ entries below.
  525. .. _slow_backup:
  526. Why is my backup so slow?
  527. --------------------------
  528. If you feel your Borg backup is too slow somehow, here is what you can do:
  529. - Make sure Borg has enough RAM (depends on how big your repo is / how many
  530. files you have)
  531. - Use one of the blake2 modes for --encryption except if you positively know
  532. your CPU (and openssl) accelerates sha256 (then stay with hmac-sha256).
  533. - Don't use any expensive compression. The default is lz4 and super fast.
  534. Uncompressed is often slower than lz4.
  535. - Just wait. You can also interrupt it and start it again as often as you like,
  536. it will converge against a valid "completed" state. It is starting
  537. from the beginning each time, but it is still faster then as it does not store
  538. data into the repo which it already has there.
  539. - If you don’t need additional file attributes, you can disable them with ``--noflags``,
  540. ``--noacls``, ``--noxattrs``. This can lead to noticeable performance improvements
  541. when your backup consists of many small files.
  542. To see what files have changed and take more time processing, you can also add
  543. ``--list --filter=AME --stats`` to your ``borg create`` call to produce more log output,
  544. including a file list (with file status characters) and also some statistics at
  545. the end of the backup.
  546. Then you do the backup and look at the log output:
  547. - stats: Do you really have little changes or are there more changes than you thought?
  548. In the stats you can see the overall volume of changed data, which needed to be
  549. added to the repo. If that is a lot, that can be the reason why it is slow.
  550. - ``A`` status ("added") in the file list:
  551. If you see that often, you have a lot of new files (files that Borg did not find
  552. in the files cache). If you think there is something wrong with that (the file was there
  553. already in the previous backup), please read the FAQ entries below.
  554. - ``M`` status ("modified") in the file list:
  555. If you see that often, Borg thinks that a lot of your files might be modified
  556. (Borg found them in the files cache, but the metadata read from the filesystem did
  557. not match the metadata stored in the files cache).
  558. In such a case, Borg will need to process the files' contents completely, which is
  559. much slower than processing unmodified files (Borg does not read their contents!).
  560. The metadata values used in this comparison are determined by the ``--files-cache`` option
  561. and could be e.g. size, ctime and inode number (see the ``borg create`` docs for more
  562. details and potential issues).
  563. You can use the ``stat`` command on files to look at fs metadata manually to debug if
  564. there is any unexpected change triggering the ``M`` status.
  565. Also, the ``--debug-topic=files_cache`` option of ``borg create`` provides a lot of debug
  566. output helping to analyse why the files cache does not give its expected high performance.
  567. When borg runs inside a virtual machine, there are some more things to look at:
  568. Some hypervisors (e.g. kvm on older proxmox) give some broadly compatible CPU type to the
  569. VM (usually to ease migration between VM hosts of potentially different hardware CPUs).
  570. It is broadly compatible because they leave away modern CPU features that could be
  571. not present in older or other CPUs, e.g. hardware acceleration for AES crypto, for
  572. sha2 hashes, for (P)CLMUL(QDQ) computations useful for crc32.
  573. So, basically you pay for compatibility with bad performance. If you prefer better
  574. performance, you should try to use the x86-64-v2-AES VCPU or the "host" VCPU,
  575. exposing misc. hw acceleration features to the VM which runs borg.
  576. On Linux, check ``/proc/cpuinfo`` for the CPU flags inside the VM.
  577. For kvm check the docs about "Host model" and "Host passthrough".
  578. See also the next few FAQ entries for more details.
  579. .. _a_status_oddity:
  580. I am seeing 'A' (added) status for an unchanged file!?
  581. ------------------------------------------------------
  582. The files cache is used to determine whether Borg already
  583. "knows" / has backed up a file and if so, to skip the file from
  584. chunking. It intentionally *excludes* files that have a timestamp
  585. which is the same as the newest timestamp in the created archive.
  586. So, if you see an 'A' status for unchanged file(s), they are likely the files
  587. with the most recent timestamp in that archive.
  588. This is expected: it is to avoid data loss with files that are backed up from
  589. a snapshot and that are immediately changed after the snapshot (but within
  590. timestamp granularity time, so the timestamp would not change). Without the code that
  591. removes these files from the files cache, the change that happened right after
  592. the snapshot would not be contained in the next backup as Borg would
  593. think the file is unchanged.
  594. This does not affect deduplication, the file will be chunked, but as the chunks
  595. will often be the same and already stored in the repo (except in the above
  596. mentioned rare condition), it will just re-use them as usual and not store new
  597. data chunks.
  598. If you want to avoid unnecessary chunking, just create or touch a small or
  599. empty file in your backup source file set (so that one has the latest timestamp,
  600. not your 50GB VM disk image) and, if you do snapshots, do the snapshot after
  601. that.
  602. Since only the files cache is used in the display of files status,
  603. those files are reported as being added when, really, chunks are
  604. already used.
  605. By default, ctime (change time) is used for the timestamps to have a rather
  606. safe change detection (see also the --files-cache option).
  607. Furthermore, pathnames used as key into the files cache are **as archived**,
  608. so make sure these are always the same (see ``borg list``).
  609. .. _always_chunking:
  610. It always chunks all my files, even unchanged ones!
  611. ---------------------------------------------------
  612. Borg maintains a files cache where it remembers the timestamps, size and
  613. inode of files. When Borg does a new backup and starts processing a
  614. file, it first looks whether the file has changed (compared to the values
  615. stored in the files cache). If the values are the same, the file is assumed
  616. unchanged and thus its contents won't get chunked (again).
  617. The files cache is stored separately (using a different filename suffix) per
  618. archive series, thus using always the same name for the archive is strongly
  619. recommended. The "rebuild files cache from previous archive in repo" feature
  620. also depends on that.
  621. Alternatively, there is also BORG_FILES_CACHE_SUFFIX which can be used to
  622. manually set a custom suffix (if you can't just use the same archive name).
  623. Another possible reason is that files don't always have the same path -
  624. borg uses the paths as seen in the archive when using ``borg list``.
  625. It is possible for some filesystems, such as ``mergerfs`` or network filesystems,
  626. to return inconsistent inode numbers across runs, causing borg to consider them changed.
  627. A workaround is to set the option ``--files-cache=ctime,size`` to exclude the inode
  628. number comparison from the files cache check so that files with different inode
  629. numbers won't be treated as modified.
  630. Using a pure-python msgpack! This will result in lower performance.
  631. -------------------------------------------------------------------
  632. borg uses `msgpack` to serialize/deserialize data.
  633. `msgpack` has 2 implementations:
  634. - a fast one (C code compiled into a platform specific binary), and
  635. - a slow pure-python one.
  636. The slow one is used if it can't successfully import the fast one.
  637. If you use the pyinstaller-made borg "fat binary" which we offer on github
  638. releases, it could be that you downloaded a binary that does not match the
  639. (g)libc on your system.
  640. Binaries made for an older glibc than the one you have on your system usually
  641. just work, but the opposite is not necessarily the case and can lead to misc.
  642. issues - like failing to load the fast msgpack code or not working at all.
  643. So: try a binary made for an older glibc.
  644. If you see this without using a "fat binary" from us, it usually means that
  645. msgpack is not built / installed correctly. It could be also that the platform
  646. is not fully supported (so the python code works, but there is no fast binary
  647. code).
  648. Is there a way to limit bandwidth with Borg?
  649. --------------------------------------------
  650. To limit upload (i.e. :ref:`borg_create`) bandwidth, use the
  651. ``--remote-ratelimit`` option.
  652. There is no built-in way to limit *download*
  653. (i.e. :ref:`borg_extract`) bandwidth, but limiting download bandwidth
  654. can be accomplished with pipeviewer_:
  655. Create a wrapper script: /usr/local/bin/pv-wrapper
  656. ::
  657. #!/bin/sh
  658. ## -q, --quiet do not output any transfer information at all
  659. ## -L, --rate-limit RATE limit transfer to RATE bytes per second
  660. RATE=307200
  661. pv -q -L $RATE | "$@"
  662. Add BORG_RSH environment variable to use pipeviewer wrapper script with ssh.
  663. ::
  664. export BORG_RSH='/usr/local/bin/pv-wrapper ssh'
  665. Now Borg will be bandwidth limited. The nice thing about ``pv`` is that you can
  666. change rate-limit on the fly:
  667. ::
  668. pv -R $(pidof pv) -L 102400
  669. .. _pipeviewer: http://www.ivarch.com/programs/pv.shtml
  670. How can I avoid unwanted base directories getting stored into archives?
  671. -----------------------------------------------------------------------
  672. Possible use cases:
  673. - Another file system is mounted and you want to back it up with original paths.
  674. - You have created a BTRFS snapshot in a ``/.snapshots`` directory for backup.
  675. To achieve this, run ``borg create`` within the mountpoint/snapshot directory:
  676. ::
  677. # Example: Some file system mounted in /mnt/rootfs.
  678. cd /mnt/rootfs
  679. borg create rootfs_backup .
  680. Another way (without changing the directory) is to use the slashdot hack:
  681. ::
  682. borg create rootfs_backup /mnt/rootfs/./
  683. I am having troubles with some network/FUSE/special filesystem, why?
  684. --------------------------------------------------------------------
  685. Borg is doing nothing special in the filesystem, it only uses very
  686. common and compatible operations (even the locking is just "rename").
  687. So, if you are encountering issues like slowness, corruption or malfunction
  688. when using a specific filesystem, please try if you can reproduce the issues
  689. with a local (non-network) and proven filesystem (like ext4 on Linux).
  690. If you can't reproduce the issue then, you maybe have found an issue within
  691. the filesystem code you used (not with Borg). For this case, it is
  692. recommended that you talk to the developers / support of the network fs and
  693. maybe open an issue in their issue tracker. Do not file an issue in the
  694. Borg issue tracker.
  695. If you can reproduce the issue with the proven filesystem, please file an
  696. issue in the Borg issue tracker about that.
  697. Why does running 'borg check --repair' warn about data loss?
  698. ------------------------------------------------------------
  699. Repair usually works for recovering data in a corrupted archive. However,
  700. it's impossible to predict all modes of corruption. In some very rare
  701. instances, such as malfunctioning storage hardware, additional repo
  702. corruption may occur. If you can't afford to lose the repo, it's strongly
  703. recommended that you perform repair on a copy of the repo.
  704. In other words, the warning is there to emphasize that Borg:
  705. - Will perform automated routines that modify your backup repository
  706. - Might not actually fix the problem you are experiencing
  707. - Might, in very rare cases, further corrupt your repository
  708. In the case of malfunctioning hardware, such as a drive or USB hub
  709. corrupting data when read or written, it's best to diagnose and fix the
  710. cause of the initial corruption before attempting to repair the repo. If
  711. the corruption is caused by a one time event such as a power outage,
  712. running `borg check --repair` will fix most problems.
  713. Why isn't there more progress / ETA information displayed?
  714. ----------------------------------------------------------
  715. Some borg runs take quite a bit, so it would be nice to see a progress display,
  716. maybe even including a ETA (expected time of "arrival" [here rather "completion"]).
  717. For some functionality, this can be done: if the total amount of work is more or
  718. less known, we can display progress. So check if there is a ``--progress`` option.
  719. But sometimes, the total amount is unknown (e.g. for ``borg create`` we just do
  720. a single pass over the filesystem, so we do not know the total file count or data
  721. volume before reaching the end). Adding another pass just to determine that would
  722. take additional time and could be incorrect, if the filesystem is changing.
  723. Even if the fs does not change and we knew count and size of all files, we still
  724. could not compute the ``borg create`` ETA as we do not know the amount of changed
  725. chunks, how the bandwidth of source and destination or system performance might
  726. fluctuate.
  727. You see, trying to display ETA would be futile. The borg developers prefer to
  728. rather not implement progress / ETA display than doing futile attempts.
  729. See also: https://xkcd.com/612/
  730. Why am I getting 'Operation not permitted' errors when backing up on sshfs?
  731. ---------------------------------------------------------------------------
  732. By default, ``sshfs`` is not entirely POSIX-compliant when renaming files due to
  733. a technicality in the SFTP protocol. Fortunately, it also provides a workaround_
  734. to make it behave correctly::
  735. sshfs -o workaround=rename user@host:dir /mnt/dir
  736. .. _workaround: https://unix.stackexchange.com/a/123236
  737. How do I rename a repository?
  738. -----------------------------
  739. There is nothing special that needs to be done, you can simply rename the
  740. directory that corresponds to the repository. However, the next time borg
  741. interacts with the repository (i.e, via ``borg list``), depending on the value
  742. of ``BORG_RELOCATED_REPO_ACCESS_IS_OK``, borg may warn you that the repository
  743. has been moved. You will be given a prompt to confirm you are OK with this.
  744. If ``BORG_RELOCATED_REPO_ACCESS_IS_OK`` is unset, borg will interactively ask for
  745. each repository whether it's OK.
  746. It may be useful to set ``BORG_RELOCATED_REPO_ACCESS_IS_OK=yes`` to avoid the
  747. prompts when renaming multiple repositories or in a non-interactive context
  748. such as a script. See :doc:`deployment` for an example.
  749. My backup disk is full, what can I do?
  750. --------------------------------------
  751. Borg cannot work if you really have zero free space on the backup disk, so the
  752. first thing you must do is deleting some files to regain free disk space. See
  753. :ref:`about_free_space` for further details.
  754. Some Borg commands that do not change the repository might work under disk-full
  755. conditions, but generally this should be avoided. If your backup disk is already
  756. full when Borg starts a write command like `borg create`, it will abort
  757. immediately and the repository will stay as-is.
  758. Miscellaneous
  759. #############
  760. macOS: borg mounts not shown in Finder's side bar
  761. -------------------------------------------------
  762. https://github.com/macfuse/macfuse/wiki/Mount-options#local
  763. Read the above first and use this on your own risk::
  764. borg mount -olocal REPO MOUNTPOINT
  765. Requirements for the borg single-file binary, esp. (g)libc?
  766. -----------------------------------------------------------
  767. We try to build the binary on old, but still supported systems - to keep the
  768. minimum requirement for the (g)libc low. The (g)libc can't be bundled into
  769. the binary as it needs to fit your kernel and OS, but Python and all other
  770. required libraries will be bundled into the binary.
  771. If your system fulfills the minimum (g)libc requirement (see the README that
  772. is released with the binary), there should be no problem. If you are slightly
  773. below the required version, maybe just try. Due to the dynamic loading (or not
  774. loading) of some shared libraries, it might still work depending on what
  775. libraries are actually loaded and used.
  776. In the borg git repository, there is scripts/glibc_check.py that can determine
  777. (based on the symbols' versions they want to link to) whether a set of given
  778. (Linux) binaries works with a given glibc version.