1BORG(1)                  Borg - Deduplicating Archiver                 BORG(1)
2
3
4

NAME

6       borg  - BorgBackup is a deduplicating backup program with optional com‐
7       pression and authenticated encryption.
8

GENERAL

10       Borg consists of a number of commands. Each command accepts a number of
11       arguments  and  options  and  interprets various environment variables.
12       The following sections will describe each command in detail.
13
14       Commands, options, parameters, paths and such are set  in  fixed-width.
15       Option  values  are  underlined. Borg has few options accepting a fixed
16       set of values (e.g. --encryption of borg_init).  Experimental  features
17       are marked with red stripes on the sides, like this paragraph.
18
19       Experimental  features  are  not  stable,  which means that they may be
20       changed in incompatible ways or even  removed  entirely  without  prior
21       notice in following releases.
22
23   Positional Arguments and Options: Order matters
24       Borg only supports taking options (-s and --progress in the example) to
25       the left or right of all positional arguments (repo::archive  and  path
26       in the example), but not in between them:
27
28          borg create -s --progress repo::archive path  # good and preferred
29          borg create repo::archive path -s --progress  # also works
30          borg create -s repo::archive path --progress  # works, but ugly
31          borg create repo::archive -s --progress path  # BAD
32
33       This    is    due    to    a    problem   in   the   argparse   module:
34       http://bugs.python.org/issue15112
35
36   Repository URLs
37       Local filesystem (or locally mounted network filesystem):
38
39       /path/to/repo - filesystem path to repo directory, absolute path
40
41       path/to/repo - filesystem path to repo directory, relative path
42
43       Also, stuff like ~/path/to/repo or ~other/path/to/repo works  (this  is
44       expanded by your shell).
45
46       Note:  you  may  also prepend a file:// to a filesystem path to get URL
47       style.
48
49       Remote repositories accessed via ssh user@host:
50
51       user@host:/path/to/repo - remote repo, absolute path
52
53       ssh://user@host:port/path/to/repo - same, alternative syntax, port  can
54       be given
55
56       Remote repositories with relative paths can be given using this syntax:
57
58       user@host:path/to/repo - path relative to current directory
59
60       user@host:~/path/to/repo - path relative to user's home directory
61
62       user@host:~other/path/to/repo - path relative to other's home directory
63
64       Note:  giving user@host:/./path/to/repo or user@host:/~/path/to/repo or
65       user@host:/~other/path/to/repo is  also  supported,  but  not  required
66       here.
67
68       Remote repositories with relative paths, alternative syntax with port:
69
70       ssh://user@host:port/./path/to/repo  -  path relative to current direc‐
71       tory
72
73       ssh://user@host:port/~/path/to/repo -  path  relative  to  user's  home
74       directory
75
76       ssh://user@host:port/~other/path/to/repo  -  path  relative  to other's
77       home directory
78
79       If you frequently need the same repo URL, it is a good idea to set  the
80       BORG_REPO environment variable to set a default for the repo URL:
81
82          export BORG_REPO='ssh://user@host:port/path/to/repo'
83
84       Then  just leave away the repo URL if only a repo URL is needed and you
85       want to use the default - it will be read from BORG_REPO then.
86
87       Use :: syntax to give the repo URL when syntax requires giving a  posi‐
88       tional argument for the repo (e.g. borg mount :: /mnt).
89
90   Repository / Archive Locations
91       Many  commands  want  either  a repository (just give the repo URL, see
92       above) or an archive location, which is a repo URL  followed  by  ::ar‐
93       chive_name.
94
95       Archive names must not contain the / (slash) character. For simplicity,
96       maybe also avoid blanks or other characters that have  special  meaning
97       on  the  shell or in a filesystem (borg mount will use the archive name
98       as directory name).
99
100       If you have set BORG_REPO  (see  above)  and  an  archive  location  is
101       needed,  use  ::archive_name  -  the  repo  URL  part is then read from
102       BORG_REPO.
103
104   Logging
105       Borg writes all log output to stderr by default. But please  note  that
106       something  showing  up  on  stderr does not indicate an error condition
107       just because it is on stderr. Please check the log levels of  the  mes‐
108       sages  and  the  return  code of borg for determining error, warning or
109       success conditions.
110
111       If you want to capture the log output to a file, just redirect it:
112
113          borg create repo::archive myfiles 2>> logfile
114
115       Custom logging configurations can be implemented via BORG_LOGGING_CONF.
116
117       The log level of the builtin logging configuration defaults to WARNING.
118       This  is because we want Borg to be mostly silent and only output warn‐
119       ings, errors and critical messages, unless output has been requested by
120       supplying an option that implies output (e.g. --list or --progress).
121
122       Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL
123
124       Use --debug to set DEBUG log level - to get debug, info, warning, error
125       and critical level output.
126
127       Use --info (or -v or --verbose) to set INFO log level -  to  get  info,
128       warning, error and critical level output.
129
130       Use  --warning  (default)  to  set  WARNING log level - to get warning,
131       error and critical level output.
132
133       Use --error to set ERROR log level - to get error  and  critical  level
134       output.
135
136       Use  --critical  to set CRITICAL log level - to get critical level out‐
137       put.
138
139       While you can set misc. log levels, do not expect  that  every  command
140       will give different output on different log levels - it's just a possi‐
141       bility.
142
143       WARNING:
144          Options --critical and --error are provided for completeness,  their
145          usage is not recommended as you might miss important information.
146
147   Return codes
148       Borg can exit with the following return codes (rc):
149
150                     ┌────────────┬────────────────────────────┐
151                     │Return code │ Meaning                    │
152                     ├────────────┼────────────────────────────┤
153                     │0           │ success (logged as INFO)   │
154                     ├────────────┼────────────────────────────┤
155                     │1           │ warning (operation reached │
156                     │            │ its normal end, but  there │
157                     │            │ were   warnings   --   you │
158                     │            │ should  check   the   log, │
159                     │            │ logged as WARNING)         │
160                     ├────────────┼────────────────────────────┤
161                     │2           │ error (like a fatal error, │
162                     │            │ a local or  remote  excep‐ │
163                     │            │ tion,  the  operation  did │
164                     │            │ not reach its normal  end, │
165                     │            │ logged as ERROR)           │
166                     ├────────────┼────────────────────────────┤
167                     │128+N       │ killed  by  signal N (e.g. │
168                     │            │ 137 == kill -9)            │
169                     └────────────┴────────────────────────────┘
170
171       If you use --show-rc, the return code is also logged at  the  indicated
172       level as the last log entry.
173
174   Environment Variables
175       Borg uses some environment variables for automation:
176
177       General:
178
179              BORG_REPO
180                     When  set,  use  the value to give the default repository
181                     location. If a command needs an  archive  parameter,  you
182                     can abbreviate as ::archive. If a command needs a reposi‐
183                     tory parameter, you can either leave it away or  abbrevi‐
184                     ate as ::, if a positional parameter is required.
185
186              BORG_PASSPHRASE
187                     When set, use the value to answer the passphrase question
188                     for encrypted repositories.  It is used when a passphrase
189                     is  needed  to access an encrypted repo as well as when a
190                     new passphrase should be initially set when  initializing
191                     an encrypted repo.  See also BORG_NEW_PASSPHRASE.
192
193              BORG_PASSCOMMAND
194                     When  set, use the standard output of the command (trail‐
195                     ing newlines are stripped) to answer the passphrase ques‐
196                     tion  for  encrypted  repositories.   It  is  used when a
197                     passphrase is needed to access an encrypted repo as  well
198                     as  when  a  new  passphrase should be initially set when
199                     initializing an encrypted repo. Note that the command  is
200                     executed  without  a shell. So variables, like $HOME will
201                     work, but ~ won't.  If BORG_PASSPHRASE is  also  set,  it
202                     takes precedence.  See also BORG_NEW_PASSPHRASE.
203
204              BORG_PASSPHRASE_FD
205                     When   set,   specifies  a  file  descriptor  to  read  a
206                     passphrase from. Programs starting  borg  may  choose  to
207                     open  an  anonymous pipe and use it to pass a passphrase.
208                     This is safer than passing via  BORG_PASSPHRASE,  because
209                     on  some systems (e.g. Linux) environment can be examined
210                     by other processes.  If BORG_PASSPHRASE or  BORG_PASSCOM‐
211                     MAND are also set, they take precedence.
212
213              BORG_NEW_PASSPHRASE
214                     When set, use the value to answer the passphrase question
215                     when a new passphrase is asked  for.   This  variable  is
216                     checked  first.  If  it  is  not set, BORG_PASSPHRASE and
217                     BORG_PASSCOMMAND will also be checked.  Main usecase  for
218                     this is to fully automate borg change-passphrase.
219
220              BORG_DISPLAY_PASSPHRASE
221                     When  set,  use  the  value  to  answer  the "display the
222                     passphrase for verification" question when defining a new
223                     passphrase for encrypted repositories.
224
225              BORG_HOSTNAME_IS_UNIQUE=no
226                     Borg assumes that it can derive a unique hostname / iden‐
227                     tity (see borg debug info).  If this is not the  case  or
228                     you do not want Borg to automatically remove stale locks,
229                     set this to no.
230
231              BORG_HOST_ID
232                     Borg usually computes a host id from the  FQDN  plus  the
233                     results of uuid.getnode() (which usually returns a unique
234                     id based on the MAC address  of  the  network  interface.
235                     Except  if that MAC happens to be all-zero - in that case
236                     it returns a random value, which  is  not  what  we  want
237                     (because  it kills automatic stale lock removal).  So, if
238                     you have a all-zero MAC address or other reasons to  bet‐
239                     ter  externally  control the host id, just set this envi‐
240                     ronment variable to a unique value. If all your FQDNs are
241                     unique,   you   can  just  use  the  FQDN.  If  not,  use
242                     fqdn@uniqueid.
243
244              BORG_LOGGING_CONF
245                     When set, use the given  filename  as  INI-style  logging
246                     configuration.   A  basic  example  conf  can be found at
247                     docs/misc/logging.conf.
248
249              BORG_RSH
250                     When set, use this command instead of ssh.  This  can  be
251                     used  to  specify  ssh options, such as a custom identity
252                     file ssh -i /path/to/private/key. See man ssh  for  other
253                     options. Using the --rsh CMD commandline option overrides
254                     the environment variable.
255
256              BORG_REMOTE_PATH
257                     When set, use the given path as borg  executable  on  the
258                     remote    (defaults   to   "borg"   if   unset).    Using
259                     --remote-path PATH commandline option overrides the envi‐
260                     ronment variable.
261
262              BORG_FILES_CACHE_TTL
263                     When  set to a numeric value, this determines the maximum
264                     "time to live" for the files cache entries (default: 20).
265                     The  files  cache  is used to quickly determine whether a
266                     file is unchanged.  The FAQ explains this  more  detailed
267                     in: always_chunking
268
269              BORG_SHOW_SYSINFO
270                     When  set  to no (default: yes), system information (like
271                     OS, Python version, ...)  in  exceptions  is  not  shown.
272                     Please  only  use  for  good  reasons  as it makes issues
273                     harder to analyze.
274
275              TMPDIR where temporary files are stored (might  need  a  lot  of
276                     temporary  space  for  some operations), see tempfile for
277                     details
278
279       Some automatic answerers (if set, they automatically  answer  confirma‐
280       tion questions):
281
282              BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
283                     For  "Warning:  Attempting to access a previously unknown
284                     unencrypted repository"
285
286              BORG_RELOCATED_REPO_ACCESS_IS_OK=no (or =yes)
287                     For "Warning: The repository at location ...  was  previ‐
288                     ously located at ..."
289
290              BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
291                     For "Warning: 'check --repair' is an experimental feature
292                     that might result in data loss."
293
294              BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
295                     For "You requested to completely  DELETE  the  repository
296                     including all archives it contains:"
297
298              BORG_RECREATE_I_KNOW_WHAT_I_AM_DOING=NO (or =YES)
299                     For "recreate is an experimental feature."
300
301              Note:  answers  are  case  sensitive.  setting an invalid answer
302              value might either give the default answer or ask  you  interac‐
303              tively,  depending  on  whether  retries  are  allowed  (they by
304              default are allowed). So please test your scripts  interactively
305              before making them a non-interactive script.
306
307       Directories and files:
308
309              BORG_BASE_DIR
310                     Default  to  '$HOME', '~$USER', '~' (in that order)'.  If
311                     we refer to ~ below, we in fact mean BORG_BASE_DIR.
312
313              BORG_CONFIG_DIR
314                     Default to '~/.config/borg'. This directory contains  the
315                     whole config directories.
316
317              BORG_CACHE_DIR
318                     Default  to  '~/.cache/borg'. This directory contains the
319                     local cache and might need a lot  of  space  for  dealing
320                     with big repositories.
321
322              BORG_SECURITY_DIR
323                     Default to '~/.config/borg/security'. This directory con‐
324                     tains information borg uses to track its usage of  NONCES
325                     ("numbers used once" - usually in encryption context) and
326                     other security relevant data.
327
328              BORG_KEYS_DIR
329                     Default to '~/.config/borg/keys'. This directory contains
330                     keys for encrypted repositories.
331
332              BORG_KEY_FILE
333                     When set, use the given filename as repository key file.
334
335       Building:
336
337              BORG_OPENSSL_PREFIX
338                     Adds  given  OpenSSL header file directory to the default
339                     locations (setup.py).
340
341              BORG_LIBLZ4_PREFIX
342                     Adds given prefix directory to the default locations.  If
343                     a  'include/lz4.h'  is  found Borg will be linked against
344                     the system liblz4 instead of  a  bundled  implementation.
345                     (setup.py)
346
347              BORG_LIBB2_PREFIX
348                     Adds  given prefix directory to the default locations. If
349                     a 'include/blake2.h' is found Borg will be linked against
350                     the  system  libb2  instead  of a bundled implementation.
351                     (setup.py)
352
353              BORG_LIBZSTD_PREFIX
354                     Adds given prefix directory to the default locations.  If
355                     a  'include/zstd.h'  is found Borg will be linked against
356                     the system libzstd instead of a  bundled  implementation.
357                     (setup.py)
358
359       Please note:
360
361       · be very careful when using the "yes" sayers, the warnings with prompt
362         exist for your / your data's security/safety
363
364       · also be very careful when putting your passphrase into a script, make
365         sure it has appropriate file permissions (e.g. mode 600, root:root).
366
367   File systems
368       We  strongly  recommend  against using Borg (or any other database-like
369       software) on non-journaling file systems like FAT, since it is not pos‐
370       sible  to assume any consistency in case of power failures (or a sudden
371       disconnect of an external drive or similar failures).
372
373       While Borg uses a data store that is resilient against  these  failures
374       when  used  on journaling file systems, it is not possible to guarantee
375       this with some hardware -- independent of the software used.  We  don't
376       know a list of affected hardware.
377
378       If  you are suspicious whether your Borg repository is still consistent
379       and readable after one of the failures mentioned  above  occurred,  run
380       borg check --verify-data to make sure it is consistent.
381
382       Requirements for Borg repository file systems
383
384       · Long file names
385
386       · At least three directory levels with short names
387
388       · Typically, file sizes up to a few hundred MB.  Large repositories may
389         require large files (>2 GB).
390
391       · Up to 1000 files per directory (10000  for  repositories  initialized
392         with Borg 1.0)
393
394       · mkdir(2) should be atomic, since it is used for locking
395
396       · Hardlinks are needed for borg_upgrade --inplace
397
398   Units
399       To  display quantities, Borg takes care of respecting the usual conven‐
400       tions of scale. Disk sizes are displayed in decimal,  using  powers  of
401       ten  (so  kB  means  1000 bytes). For memory usage, binary prefixes are
402       used, and are indicated using the IEC binary prefixes, using powers  of
403       two (so KiB means 1024 bytes).
404
405   Date and Time
406       We format date and time conforming to ISO-8601, that is: YYYY-MM-DD and
407       HH:MM:SS (24h clock).
408
409       For more information about that, see: https://xkcd.com/1179/
410
411       Unless otherwise noted, we display local date and time.  Internally, we
412       store and process date and time as UTC.
413
414   Resource Usage
415       Borg might use a lot of resources depending on the size of the data set
416       it is dealing with.
417
418       If one uses Borg in a client/server way (with a ssh:  repository),  the
419       resource  usage occurs in part on the client and in another part on the
420       server.
421
422       If one uses Borg as a single process (with a filesystem repo), all  the
423       resource  usage  occurs  in  that  one process, so just add up client +
424       server to get the approximate resource usage.
425
426       CPU client:
427
428              · borg create: does chunking, hashing, compression, crypto (high
429                CPU usage)
430
431              · chunks cache sync: quite heavy on CPU, doing lots of hashtable
432                operations.
433
434              · borg extract: crypto, decompression (medium to high CPU usage)
435
436              · borg check: similar to extract, but depends on options given.
437
438              · borg prune / borg delete archive: low to medium CPU usage
439
440              · borg delete repo: done on the server
441
442              It won't go beyond 100% of 1 core as the code is currently  sin‐
443              gle-threaded.   Especially higher zlib and lzma compression lev‐
444              els use significant amounts of CPU cycles. Crypto might be cheap
445              on the CPU (if hardware accelerated) or expensive (if not).
446
447       CPU server:
448              It  usually  doesn't  need  much  CPU,  it  just  deals with the
449              key/value store (repository) and uses the repository  index  for
450              that.
451
452              borg  check:  the repository check computes the checksums of all
453              chunks (medium CPU usage) borg delete repo: low CPU usage
454
455       CPU (only for client/server operation):
456              When using borg in a client/server way with  a  ssh:-type  repo,
457              the  ssh  processes  used for the transport layer will need some
458              CPU on the client and on the server due to the crypto  they  are
459              doing - esp. if you are pumping big amounts of data.
460
461       Memory (RAM) client:
462              The  chunks  index  and the files index are read into memory for
463              performance reasons. Might  need  big  amounts  of  memory  (see
464              below).   Compression,  esp.  lzma  compression with high levels
465              might need substantial amounts of memory.
466
467       Memory (RAM) server:
468              The server process will load the repository index  into  memory.
469              Might  need considerable amounts of memory, but less than on the
470              client (see below).
471
472       Chunks index (client only):
473              Proportional to the amount of data chunks in your repo. Lots  of
474              chunks in your repo imply a big chunks index.  It is possible to
475              tweak the chunker params (see create options).
476
477       Files index (client only):
478              Proportional to the amount of files in your last backups. Can be
479              switched off (see create options), but next backup might be much
480              slower if you do.  The speed benefit of using the files cache is
481              proportional to file size.
482
483       Repository index (server only):
484              Proportional  to the amount of data chunks in your repo. Lots of
485              chunks in your repo imply a big repository index.  It is  possi‐
486              ble  to  tweak the chunker params (see create options) to influ‐
487              ence the amount of chunks being created.
488
489       Temporary files (client):
490              Reading data and metadata from a FUSE  mounted  repository  will
491              consume  up to the size of all deduplicated, small chunks in the
492              repository. Big chunks won't be locally cached.
493
494       Temporary files (server):
495              None.
496
497       Cache files (client only):
498              Contains the chunks index and files index (plus a collection  of
499              single-  archive  chunk indexes which might need huge amounts of
500              disk space, depending on archive count and size - see FAQ  about
501              how to reduce).
502
503       Network (only for client/server operation):
504              If  your  repository is remote, all deduplicated (and optionally
505              compressed/ encrypted) data of course has to go over the connec‐
506              tion  (ssh://  repo  url).  If you use a locally mounted network
507              filesystem, additionally some copy operations used for  transac‐
508              tion support also go over the connection. If you backup multiple
509              sources to one target repository, additional traffic happens for
510              cache resynchronization.
511
512   Support for file metadata
513       Besides regular file and directory structures, Borg can preserve
514
515       · symlinks (stored as symlink, the symlink is not followed)
516
517       · special files:
518
519         · character and block device files (restored via mknod)
520
521         · FIFOs ("named pipes")
522
523         · special  file contents can be backed up in --read-special mode.  By
524           default the metadata to create them with mknod(2),  mkfifo(2)  etc.
525           is stored.
526
527       · hardlinked  regular  files,  devices, FIFOs (considering all items in
528         the same archive)
529
530       · timestamps in nanosecond precision: mtime, atime, ctime
531
532       · other timestamps: birthtime (on platforms supporting it)
533
534       · permissions:
535
536         · IDs of owning user and owning group
537
538         · names of owning user and owning group (if the IDs can be resolved)
539
540         · Unix Mode/Permissions (u/g/o permissions, suid, sgid, sticky)
541
542       On some platforms additional features are supported:
543
544                ┌─────────────────┬──────────┬───────────┬───────────┐
545                │Platform         │ ACLs [5] │ xattr [6] │ Flags [7] │
546                ├─────────────────┼──────────┼───────────┼───────────┤
547                │Linux            │ Yes      │ Yes       │ Yes [1]   │
548                ├─────────────────┼──────────┼───────────┼───────────┤
549                │Mac OS X         │ Yes      │ Yes       │ Yes (all) │
550                ├─────────────────┼──────────┼───────────┼───────────┤
551                │FreeBSD          │ Yes      │ Yes       │ Yes (all) │
552                ├─────────────────┼──────────┼───────────┼───────────┤
553                │OpenBSD          │ n/a      │ n/a       │ Yes (all) │
554                ├─────────────────┼──────────┼───────────┼───────────┤
555                │NetBSD           │ n/a      │ No [2]    │ Yes (all) │
556                ├─────────────────┼──────────┼───────────┼───────────┤
557                │Solaris and  de‐ │ No [3]   │ No [3]    │ n/a       │
558                │rivatives        │          │           │           │
559                ├─────────────────┼──────────┼───────────┼───────────┤
560                │Windows (cygwin) │ No [4]   │ No        │ No        │
561                └─────────────────┴──────────┴───────────┴───────────┘
562
563       Other  Unix-like  operating systems may work as well, but have not been
564       tested at all.
565
566       Note that most of the platform-dependent features also  depend  on  the
567       file  system.   For example, ntfs-3g on Linux isn't able to convey NTFS
568       ACLs.
569
570       [1]  Only "nodump", "immutable", "compressed"  and  "append"  are  sup‐
571            ported.  Feature request #618 for more flags.
572
573       [2]  Feature request #1332
574
575       [3]  Feature request #1337
576
577       [4]  Cygwin  tries to map NTFS ACLs to permissions with varying degress
578            of success.
579
580       [5]  The native access control list mechanism of the OS. This  normally
581            limits  access  to  non-native ACLs. For example, NTFS ACLs aren't
582            completely accessible on Linux with ntfs-3g.
583
584       [6]  extended attributes; key-value pairs attached to  a  file,  mainly
585            used by the OS.  This includes resource forks on Mac OS X.
586
587       [7]  aka BSD flags. The Linux set of flags [1] is portable across plat‐
588            forms.  The BSDs define additional flags.
589
590            In case you are interested in more details (like formulas), please
591            see  internals. For details on the available JSON output, refer to
592            json_output.
593
594   Common options
595       All Borg commands share these options:
596
597       -h, --help
598              show this help message and exit
599
600       --critical
601              work on log level CRITICAL
602
603       --error
604              work on log level ERROR
605
606       --warning
607              work on log level WARNING (default)
608
609       --info, -v, --verbose
610              work on log level INFO
611
612       --debug
613              enable debug output, work on log level DEBUG
614
615       --debug-topic TOPIC
616              enable TOPIC debugging (can be specified  multiple  times).  The
617              logger  path  is borg.debug.<TOPIC> if TOPIC is not fully quali‐
618              fied.
619
620       -p, --progress
621              show progress information
622
623       --log-json
624              Output one JSON object per log line instead of formatted text.
625
626       --lock-wait SECONDS
627              wait at most  SECONDS  for  acquiring  a  repository/cache  lock
628              (default: 1).
629
630       --show-version
631              show/log the borg version
632
633       --show-rc
634              show/log the return code (rc)
635
636       --umask M
637              set umask to M (local and remote, default: 0077)
638
639       --remote-path PATH
640              use PATH as borg executable on the remote (default: "borg")
641
642       --remote-ratelimit RATE
643              set  remote  network  upload  rate  limit  in kiByte/s (default:
644              0=unlimited)
645
646       --consider-part-files
647              treat part files like normal files (e.g. to list/extract them)
648
649       --debug-profile FILE
650              Write execution profile in Borg format into FILE. For local  use
651              a Python-compatible file can be generated by suffixing FILE with
652              ".pyprof".
653
654       --rsh RSH
655              Use  this  command  to  connect  to  the  'borg  serve'  process
656              (default: 'ssh')
657
658   Examples
659          # Create an archive and log: borg version, files list, return code
660          $ borg create --show-version --list --show-rc /path/to/repo::my-files files
661

BORG INIT

663          borg [common options] init [options] [REPOSITORY]
664
665   Description
666       This  command  initializes  an  empty  repository.  A  repository  is a
667       filesystem directory containing the deduplicated data from zero or more
668       archives.
669
670       Encryption can be enabled at repository init time. It cannot be changed
671       later.
672
673       It is not recommended to work without encryption. Repository encryption
674       protects  you e.g. against the case that an attacker has access to your
675       backup repository.
676
677       But be careful with the key / the passphrase:
678
679       If you want "passphrase-only" security, use one of the  repokey  modes.
680       The key will be stored inside the repository (in its "config" file). In
681       above mentioned attack scenario, the attacker will have  the  key  (but
682       not the passphrase).
683
684       If  you  want  "passphrase and having-the-key" security, use one of the
685       keyfile modes. The key will be stored in your home directory (in  .con‐
686       fig/borg/keys).   In  the  attack  scenario,  the attacker who has just
687       access to your repo won't have the key (and also not the passphrase).
688
689       Make a backup copy of the key file (keyfile mode) or repo  config  file
690       (repokey  mode)  and keep it at a safe place, so you still have the key
691       in case it gets corrupted or lost. Also keep the passphrase at  a  safe
692       place.   The backup that is encrypted with that key won't help you with
693       that, of course.
694
695       Make sure you use a good passphrase. Not too short, not too simple. The
696       real  encryption  /  decryption  key is encrypted with / locked by your
697       passphrase.  If an attacker gets your key, he can't unlock and  use  it
698       without knowing the passphrase.
699
700       Be careful with special or non-ascii characters in your passphrase:
701
702       · Borg  processes  the passphrase as unicode (and encodes it as utf-8),
703         so it does not have problems dealing with even the strangest  charac‐
704         ters.
705
706       · BUT:  that does not necessarily apply to your OS / VM / keyboard con‐
707         figuration.
708
709       So better use a long passphrase made from simple ascii chars  than  one
710       that includes non-ascii stuff or characters that are hard/impossible to
711       enter on a different keyboard layout.
712
713       You can change your passphrase for existing repos at any time, it won't
714       affect the encryption/decryption key or other secrets.
715
716   Encryption modes
717         ┌─────────┬──────────────────┬──────────────────┬──────────────────┐
718         │Hash/MAC │ Not encrypted no │ Not   encrypted, │ Encrypted  (AEAD │
719         │         │ auth             │ but    authenti‐ │ w/    AES)   and │
720         │         │                  │ cated            │ authenticated    │
721         ├─────────┼──────────────────┼──────────────────┼──────────────────┤
722         │SHA-256  │ none             │ authenticated    │ repokey keyfile  │
723         ├─────────┼──────────────────┼──────────────────┼──────────────────┤
724         │BLAKE2b  │ n/a              │ authenti‐repokey-blake2
725         │         │                  │ cated-blake2keyfile-blake2
726         └─────────┴──────────────────┴──────────────────┴──────────────────┘
727
728       Marked modes are new in Borg 1.1 and are not backwards-compatible  with
729       Borg 1.0.x.
730
731       On modern Intel/AMD CPUs (except very cheap ones), AES is usually hard‐
732       ware-accelerated.  BLAKE2b is faster than SHA256  on  Intel/AMD  64-bit
733       CPUs  (except  AMD  Ryzen  and  future CPUs with SHA extensions), which
734       makes authenticated-blake2 faster than none and authenticated.
735
736       On modern ARM CPUs, NEON provides hardware acceleration for SHA256 mak‐
737       ing it faster than BLAKE2b-256 there. NEON accelerates AES as well.
738
739       Hardware acceleration is always used automatically when available.
740
741       repokey  and keyfile use AES-CTR-256 for encryption and HMAC-SHA256 for
742       authentication in an encrypt-then-MAC (EtM) construction. The chunk  ID
743       hash  is  HMAC-SHA256  as  well (with a separate key).  These modes are
744       compatible with Borg 1.0.x.
745
746       repokey-blake2 and keyfile-blake2  are  also  authenticated  encryption
747       modes,  but  use BLAKE2b-256 instead of HMAC-SHA256 for authentication.
748       The chunk ID hash is a keyed BLAKE2b-256 hash.  These modes are new and
749       not compatible with Borg 1.0.x.
750
751       authenticated  mode  uses  no  encryption, but authenticates repository
752       contents through the same HMAC-SHA256 hash as the repokey  and  keyfile
753       modes  (it  uses  it  as  the  chunk  ID  hash). The key is stored like
754       repokey.  This mode is new and not compatible with Borg 1.0.x.
755
756       authenticated-blake2  is  like  authenticated,  but  uses   the   keyed
757       BLAKE2b-256 hash from the other blake2 modes.  This mode is new and not
758       compatible with Borg 1.0.x.
759
760       none mode uses no encryption and no authentication. It uses  SHA256  as
761       chunk  ID hash. Not recommended, rather consider using an authenticated
762       or authenticated/encrypted mode. This mode has possible  denial-of-ser‐
763       vice  issues  when  running  borg  create  on contents controlled by an
764       attacker.  Use it only for new  repositories  where  no  encryption  is
765       wanted and when compatibility with 1.0.x is important. If compatibility
766       with 1.0.x is not important, use authenticated-blake2 or  authenticated
767       instead.  This mode is compatible with Borg 1.0.x.
768
769   Examples
770          # Local repository, repokey encryption, BLAKE2b (often faster, since Borg 1.1)
771          $ borg init --encryption=repokey-blake2 /path/to/repo
772
773          # Local repository (no encryption)
774          $ borg init --encryption=none /path/to/repo
775
776          # Remote repository (accesses a remote borg via ssh)
777          $ borg init --encryption=repokey-blake2 user@hostname:backup
778
779          # Remote repository (store the key your home dir)
780          $ borg init --encryption=keyfile user@hostname:backup
781

BORG CREATE

783          borg [common options] create [options] ARCHIVE [PATH...]
784
785   Description
786       This  command creates a backup archive containing all files found while
787       recursively traversing all paths specified. Paths are added to the  ar‐
788       chive  as they are given, that means if relative paths are desired, the
789       command has to be run from the correct directory.
790
791       When giving '-' as path, borg will read data from  standard  input  and
792       create a file 'stdin' in the created archive from that data.
793
794       The  archive  will  consume  almost no disk space for files or parts of
795       files that have already been stored in other archives.
796
797       The archive name needs to be unique. It must not end  in  '.checkpoint'
798       or  '.checkpoint.N'  (with  N  being a number), because these names are
799       used for checkpoints and treated in special ways.
800
801       In the archive name, you may use  the  following  placeholders:  {now},
802       {utcnow}, {fqdn}, {hostname}, {user} and some others.
803
804       Backup  speed  is  increased by not reprocessing files that are already
805       part of existing archives and weren't modified. The detection of unmod‐
806       ified  files  is  done  by comparing multiple file metadata values with
807       previous values kept in the files cache.
808
809       This  comparison  can  operate  in  different   modes   as   given   by
810       --files-cache:
811
812       · ctime,size,inode (default)
813
814       · mtime,size,inode  (default  behaviour  of  borg  versions  older than
815         1.1.0rc4)
816
817       · ctime,size (ignore the inode number)
818
819       · mtime,size (ignore the inode number)
820
821       · rechunk,ctime (all files are considered  modified  -  rechunk,  cache
822         ctime)
823
824       · rechunk,mtime  (all  files  are  considered modified - rechunk, cache
825         mtime)
826
827       · disabled (disable the files cache, all files  considered  modified  -
828         rechunk)
829
830       inode number: better safety, but often unstable on network filesystems
831
832       Normally, detecting file modifications will take inode information into
833       consideration to improve the  reliability  of  file  change  detection.
834       This is problematic for files located on sshfs and similar network file
835       systems which do not provide stable  inode  numbers,  such  files  will
836       always  be considered modified. You can use modes without inode in this
837       case to improve performance, but reliability of change detection  might
838       be reduced.
839
840       ctime vs. mtime: safety vs. speed
841
842       · ctime  is a rather safe way to detect changes to a file (metadata and
843         contents) as it can not be set from userspace. But,  a  metadata-only
844         change will already update the ctime, so there might be some unneces‐
845         sary chunking/hashing even without content changes. Some  filesystems
846         do not support ctime (change time).
847
848       · mtime  usually  works and only updates if file contents were changed.
849         But mtime can be arbitrarily set from userspace, e.g.  to  set  mtime
850         back  to the same value it had before a content change happened. This
851         can be used maliciously as well as  well-meant,  but  in  both  cases
852         mtime based cache modes can be problematic.
853
854       The  mount  points of filesystems or filesystem snapshots should be the
855       same for every creation of a new archive to ensure fast operation. This
856       is  because  the  file  cache  that  is used to determine changed files
857       quickly uses absolute filenames.  If this  is  not  possible,  consider
858       creating a bind mount to a stable location.
859
860       The  --progress  option shows (from left to right) Original, Compressed
861       and Deduplicated (O, C and D, respectively), then the Number  of  files
862       (N) processed so far, followed by the currently processed path.
863
864       When  using  --stats,  you will get some statistics about how much data
865       was added - the "This Archive" deduplicated size there is  most  inter‐
866       esting  as that is how much your repository will grow. Please note that
867       the "All archives" stats refer to the state after creation.  Also,  the
868       --stats  and  --dry-run options are mutually exclusive because the data
869       is not actually compressed and deduplicated during a dry run.
870
871       See the output of the "borg help patterns" command  for  more  help  on
872       exclude  patterns.  See the output of the "borg help placeholders" com‐
873       mand for more help on placeholders.
874
875       The --exclude patterns are not like tar. In tar --exclude .bundler/gems
876       will  exclude  foo/.bundler/gems.  In borg it will not, you need to use
877       --exclude '*/.bundler/gems' to get the same effect. See borg help  pat‐
878       terns for more information.
879
880       In  addition  to  using  --exclude  patterns,  it  is  possible  to use
881       --exclude-if-present to specify the name of a filesystem object (e.g. a
882       file  or folder name) which, when contained within another folder, will
883       prevent the containing folder from being backed up.   By  default,  the
884       containing  folder  and  all  of  its contents will be omitted from the
885       backup.  If, however, you wish to only include the objects specified by
886       --exclude-if-present in your backup, and not include any other contents
887       of the containing  folder,  this  can  be  enabled  through  using  the
888       --keep-exclude-tags option.
889
890   Item flags
891       --list  outputs  a list of all files, directories and other file system
892       items it considered (no matter whether  they  had  content  changes  or
893       not).  For  each  item, it prefixes a single-letter flag that indicates
894       type and/or status of the item.
895
896       If you are interested only in a subset of that  output,  you  can  give
897       e.g.   --filter=AME  and it will only show regular files with A, M or E
898       status (see below).
899
900       A uppercase character represents the status of a regular file  relative
901       to  the  "files" cache (not relative to the repo -- this is an issue if
902       the files cache is not used). Metadata is stored in any  case  and  for
903       'A'  and  'M'  also new data chunks are stored. For 'U' all data chunks
904       refer to already existing chunks.
905
906       · 'A' = regular file, added (see also a_status_oddity in the FAQ)
907
908       · 'M' = regular file, modified
909
910       · 'U' = regular file, unchanged
911
912       · 'E' = regular file, an error happened  while  accessing/reading  this
913         file
914
915       A lowercase character means a file type other than a regular file, borg
916       usually just stores their metadata:
917
918       · 'd' = directory
919
920       · 'b' = block device
921
922       · 'c' = char device
923
924       · 'h' = regular file, hardlink (to already seen inodes)
925
926       · 's' = symlink
927
928       · 'f' = fifo
929
930       Other flags used include:
931
932       · 'i' = backup data was read from standard input (stdin)
933
934       · '-' = dry run, item was not backed up
935
936       · 'x' = excluded, item was not backed up
937
938       · '?' = missing status code  (if  you  see  this,  please  file  a  bug
939         report!)
940
941   Examples
942          # Backup ~/Documents into an archive named "my-documents"
943          $ borg create /path/to/repo::my-documents ~/Documents
944
945          # same, but list all files as we process them
946          $ borg create --list /path/to/repo::my-documents ~/Documents
947
948          # Backup ~/Documents and ~/src but exclude pyc files
949          $ borg create /path/to/repo::my-files \
950              ~/Documents                       \
951              ~/src                             \
952              --exclude '*.pyc'
953
954          # Backup home directories excluding image thumbnails (i.e. only
955          # /home/<one directory>/.thumbnails is excluded, not /home/*/*/.thumbnails etc.)
956          $ borg create /path/to/repo::my-files /home \
957              --exclude 'sh:/home/*/.thumbnails'
958
959          # Backup the root filesystem into an archive named "root-YYYY-MM-DD"
960          # use zlib compression (good, but slow) - default is lz4 (fast, low compression ratio)
961          $ borg create -C zlib,6 --one-file-system /path/to/repo::root-{now:%Y-%m-%d} /
962
963          # Backup a remote host locally ("pull" style) using sshfs
964          $ mkdir sshfs-mount
965          $ sshfs root@example.com:/ sshfs-mount
966          $ cd sshfs-mount
967          $ borg create /path/to/repo::example.com-root-{now:%Y-%m-%d} .
968          $ cd ..
969          $ fusermount -u sshfs-mount
970
971          # Make a big effort in fine granular deduplication (big chunk management
972          # overhead, needs a lot of RAM and disk space, see formula in internals
973          # docs - same parameters as borg < 1.0 or attic):
974          $ borg create --chunker-params 10,23,16,4095 /path/to/repo::small /smallstuff
975
976          # Backup a raw device (must not be active/in use/mounted at that time)
977          $ dd if=/dev/sdx bs=10M | borg create /path/to/repo::my-sdx -
978
979          # No compression (none)
980          $ borg create --compression none /path/to/repo::arch ~
981
982          # Super fast, low compression (lz4, default)
983          $ borg create /path/to/repo::arch ~
984
985          # Less fast, higher compression (zlib, N = 0..9)
986          $ borg create --compression zlib,N /path/to/repo::arch ~
987
988          # Even slower, even higher compression (lzma, N = 0..9)
989          $ borg create --compression lzma,N /path/to/repo::arch ~
990
991          # Only compress compressible data with lzma,N (N = 0..9)
992          $ borg create --compression auto,lzma,N /path/to/repo::arch ~
993
994          # Use short hostname, user name and current time in archive name
995          $ borg create /path/to/repo::{hostname}-{user}-{now} ~
996          # Similar, use the same datetime format as borg 1.1 will have as default
997          $ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S} ~
998          # As above, but add nanoseconds
999          $ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S.%f} ~
1000
1001          # Backing up relative paths by moving into the correct directory first
1002          $ cd /home/user/Documents
1003          # The root directory of the archive will be "projectA"
1004          $ borg create /path/to/repo::daily-projectA-{now:%Y-%m-%d} projectA
1005

BORG EXTRACT

1007          borg [common options] extract [options] ARCHIVE [PATH...]
1008
1009   Description
1010       This command extracts the contents of an archive. By default the entire
1011       archive is extracted but a subset  of  files  and  directories  can  be
1012       selected  by  passing  a list of PATHs as arguments. The file selection
1013       can further be restricted by using the --exclude option.
1014
1015       See the output of the "borg help patterns" command  for  more  help  on
1016       exclude patterns.
1017
1018       By  using  --dry-run,  you  can do all extraction steps except actually
1019       writing the output data: reading metadata  and  data  chunks  from  the
1020       repo, checking the hash/hmac, decrypting, decompressing.
1021
1022       --progress  can  be slower than no progress display, since it makes one
1023       additional pass over the archive metadata.
1024
1025       NOTE:
1026          Currently, extract always writes into the current working  directory
1027          ("."),  so  make  sure you cd to the right place before calling borg
1028          extract.
1029
1030   Examples
1031          # Extract entire archive
1032          $ borg extract /path/to/repo::my-files
1033
1034          # Extract entire archive and list files while processing
1035          $ borg extract --list /path/to/repo::my-files
1036
1037          # Verify whether an archive could be successfully extracted, but do not write files to disk
1038          $ borg extract --dry-run /path/to/repo::my-files
1039
1040          # Extract the "src" directory
1041          $ borg extract /path/to/repo::my-files home/USERNAME/src
1042
1043          # Extract the "src" directory but exclude object files
1044          $ borg extract /path/to/repo::my-files home/USERNAME/src --exclude '*.o'
1045
1046          # Restore a raw device (must not be active/in use/mounted at that time)
1047          $ borg extract --stdout /path/to/repo::my-sdx | dd of=/dev/sdx bs=10M
1048

BORG CHECK

1050          borg [common options] check [options] [REPOSITORY_OR_ARCHIVE]
1051
1052   Description
1053       The check command verifies the consistency of a repository and the cor‐
1054       responding archives.
1055
1056       First, the underlying repository data files are checked:
1057
1058       · For all segments the segment magic (header) is checked
1059
1060       · For  all  objects  stored in the segments, all metadata (e.g. crc and
1061         size) and all data is read. The read data is checked by size and CRC.
1062         Bit  rot  and  other  types of accidental damage can be detected this
1063         way.
1064
1065       · If we are in repair mode and a integrity error is detected for a seg‐
1066         ment, we try to recover as many objects from the segment as possible.
1067
1068       · In  repair  mode, it makes sure that the index is consistent with the
1069         data stored in the segments.
1070
1071       · If you use a remote repo server via ssh:, the repo check is  executed
1072         on the repo server without causing significant network traffic.
1073
1074       · The repository check can be skipped using the --archives-only option.
1075
1076       Second, the consistency and correctness of the archive metadata is ver‐
1077       ified:
1078
1079       · Is the repo manifest present? If not,  it  is  rebuilt  from  archive
1080         metadata chunks (this requires reading and decrypting of all metadata
1081         and data).
1082
1083       · Check if archive metadata chunk is present. if  not,  remove  archive
1084         from manifest.
1085
1086       · For  all  files  (items) in the archive, for all chunks referenced by
1087         these files, check if chunk is present.  If a chunk  is  not  present
1088         and  we  are  in repair mode, replace it with a same-size replacement
1089         chunk of zeros.  If a previously lost chunk  reappears  (e.g.  via  a
1090         later  backup)  and  we  are in repair mode, the all-zero replacement
1091         chunk will be replaced by the correct chunk.  This  requires  reading
1092         of archive and file metadata, but not data.
1093
1094       · If  we  are  in  repair  mode and we checked all the archives: delete
1095         orphaned chunks from the repo.
1096
1097       · if you use a remote repo server via ssh:, the archive check  is  exe‐
1098         cuted  on  the  client machine (because if encryption is enabled, the
1099         checks will require decryption and this is always  done  client-side,
1100         because key access will be required).
1101
1102       · The  archive  checks can be time consuming, they can be skipped using
1103         the --repository-only option.
1104
1105       The --verify-data option will perform a full integrity verification (as
1106       opposed  to  checking  the  CRC32  of the segment) of data, which means
1107       reading the data from the repository, decrypting and decompressing  it.
1108       This  is  a  cryptographic verification, which will detect (accidental)
1109       corruption. For encrypted repositories it is tamper-resistant as  well,
1110       unless the attacker has access to the keys.
1111
1112       It is also very slow.
1113

BORG RENAME

1115          borg [common options] rename [options] ARCHIVE NEWNAME
1116
1117   Description
1118       This command renames an archive in the repository.
1119
1120       This results in a different archive ID.
1121
1122   Examples
1123          $ borg create /path/to/repo::archivename ~
1124          $ borg list /path/to/repo
1125          archivename                          Mon, 2016-02-15 19:50:19
1126
1127          $ borg rename /path/to/repo::archivename newname
1128          $ borg list /path/to/repo
1129          newname                              Mon, 2016-02-15 19:50:19
1130

BORG LIST

1132          borg [common options] list [options] [REPOSITORY_OR_ARCHIVE] [PATH...]
1133
1134   Description
1135       This command lists the contents of a repository or an archive.
1136
1137       See the "borg help patterns" command for more help on exclude patterns.
1138
1139       The following keys are available for --format:
1140
1141       · NEWLINE: OS dependent line separator
1142
1143       · NL: alias of NEWLINE
1144
1145       · NUL:  NUL  character  for creating print0 / xargs -0 like output, see
1146         barchive/bpath
1147
1148       · SPACE
1149
1150       · TAB
1151
1152       · CR
1153
1154       · LF
1155
1156       Keys for listing repository archives:
1157
1158       · archive: archive name interpreted as text (might be missing  non-text
1159         characters, see barchive)
1160
1161       · name: alias of "archive"
1162
1163       · barchive: verbatim archive name, can contain any character except NUL
1164
1165       · comment:  archive  comment  interpreted  as  text  (might  be missing
1166         non-text characters, see bcomment)
1167
1168       · bcomment: verbatim archive comment, can contain any character  except
1169         NUL
1170
1171       · id: internal ID of the archive
1172
1173       · start: time (start) of creation of the archive
1174
1175       · time: alias of "start"
1176
1177       · end: time (end) of creation of the archive
1178
1179       · hostname: hostname of host on which this archive was created
1180
1181       · username: username of user who created this archive
1182
1183       Keys for listing archive files:
1184
1185       · type
1186
1187       · mode
1188
1189       · uid
1190
1191       · gid
1192
1193       · user
1194
1195       · group
1196
1197       · path: path interpreted as text (might be missing non-text characters,
1198         see bpath)
1199
1200       · bpath: verbatim POSIX path, can contain any character except NUL
1201
1202       · source: link target for links (identical to linktarget)
1203
1204       · linktarget
1205
1206       · flags
1207
1208       · size
1209
1210       · csize: compressed size
1211
1212       · dsize: deduplicated size
1213
1214       · dcsize: deduplicated compressed size
1215
1216       · num_chunks: number of chunks in this file
1217
1218       · unique_chunks: number of unique chunks in this file
1219
1220       · mtime
1221
1222       · ctime
1223
1224       · atime
1225
1226       · isomtime
1227
1228       · isoctime
1229
1230       · isoatime
1231
1232       · md5
1233
1234       · sha1
1235
1236       · sha224
1237
1238       · sha256
1239
1240       · sha384
1241
1242       · sha512
1243
1244       · archiveid
1245
1246       · archivename
1247
1248       · extra: prepends {source} with " -> " for soft links and " link  to  "
1249         for hard links
1250
1251       · health:  either "healthy" (file ok) or "broken" (if file has all-zero
1252         replacement chunks)
1253
1254   Examples
1255          $ borg list /path/to/repo
1256          Monday                               Mon, 2016-02-15 19:15:11
1257          repo                                 Mon, 2016-02-15 19:26:54
1258          root-2016-02-15                      Mon, 2016-02-15 19:36:29
1259          newname                              Mon, 2016-02-15 19:50:19
1260          ...
1261
1262          $ borg list /path/to/repo::root-2016-02-15
1263          drwxr-xr-x root   root          0 Mon, 2016-02-15 17:44:27 .
1264          drwxrwxr-x root   root          0 Mon, 2016-02-15 19:04:49 bin
1265          -rwxr-xr-x root   root    1029624 Thu, 2014-11-13 00:08:51 bin/bash
1266          lrwxrwxrwx root   root          0 Fri, 2015-03-27 20:24:26 bin/bzcmp -> bzdiff
1267          -rwxr-xr-x root   root       2140 Fri, 2015-03-27 20:24:22 bin/bzdiff
1268          ...
1269
1270          $ borg list /path/to/repo::archiveA --format="{mode} {user:6} {group:6} {size:8d} {isomtime} {path}{extra}{NEWLINE}"
1271          drwxrwxr-x user   user          0 Sun, 2015-02-01 11:00:00 .
1272          drwxrwxr-x user   user          0 Sun, 2015-02-01 11:00:00 code
1273          drwxrwxr-x user   user          0 Sun, 2015-02-01 11:00:00 code/myproject
1274          -rw-rw-r-- user   user    1416192 Sun, 2015-02-01 11:00:00 code/myproject/file.ext
1275          ...
1276

BORG DIFF

1278          borg [common options] diff [options] REPO::ARCHIVE1 ARCHIVE2 [PATH...]
1279
1280   Description
1281       This command finds differences (file contents, user/group/mode) between
1282       archives.
1283
1284       A  repository  location  and  an  archive  name  must  be specified for
1285       REPO::ARCHIVE1.  ARCHIVE2 is just another archive name in same  reposi‐
1286       tory (no repository location allowed).
1287
1288       For  archives created with Borg 1.1 or newer diff automatically detects
1289       whether the archives are created with the same chunker params.  If  so,
1290       only chunk IDs are compared, which is very fast.
1291
1292       For  archives prior to Borg 1.1 chunk contents are compared by default.
1293       If you did not create the archives with different chunker params,  pass
1294       --same-chunker-params.   Note that the chunker params changed from Borg
1295       0.xx to 1.0.
1296
1297       See the output of the "borg help patterns" command  for  more  help  on
1298       exclude patterns.
1299
1300   Examples
1301          $ borg init -e=none testrepo
1302          $ mkdir testdir
1303          $ cd testdir
1304          $ echo asdf > file1
1305          $ dd if=/dev/urandom bs=1M count=4 > file2
1306          $ touch file3
1307          $ borg create ../testrepo::archive1 .
1308
1309          $ chmod a+x file1
1310          $ echo "something" >> file2
1311          $ borg create ../testrepo::archive2 .
1312
1313          $ rm file3
1314          $ touch file4
1315          $ borg create ../testrepo::archive3 .
1316
1317          $ cd ..
1318          $ borg diff testrepo::archive1 archive2
1319          [-rw-r--r-- -> -rwxr-xr-x] file1
1320             +135 B    -252 B file2
1321
1322          $ borg diff testrepo::archive2 archive3
1323          added           0 B file4
1324          removed         0 B file3
1325
1326          $ borg diff testrepo::archive1 archive3
1327          [-rw-r--r-- -> -rwxr-xr-x] file1
1328             +135 B    -252 B file2
1329          added           0 B file4
1330          removed         0 B file3
1331

BORG DELETE

1333          borg [common options] delete [options] [TARGET] [ARCHIVE...]
1334
1335   Description
1336       This  command  deletes  an  archive from the repository or the complete
1337       repository.  Disk space is reclaimed accordingly.  If  you  delete  the
1338       complete repository, the local cache for it (if any) is also deleted.
1339
1340       When  using  --stats,  you will get some statistics about how much data
1341       was deleted - the "Deleted data" deduplicated size there is most inter‐
1342       esting  as  that  is how much your repository will shrink.  Please note
1343       that the "All archives" stats refer to the state after deletion.
1344
1345   Examples
1346          # delete a single backup archive:
1347          $ borg delete /path/to/repo::Monday
1348
1349          # delete the whole repository and the related local cache:
1350          $ borg delete /path/to/repo
1351          You requested to completely DELETE the repository *including* all archives it contains:
1352          repo                                 Mon, 2016-02-15 19:26:54
1353          root-2016-02-15                      Mon, 2016-02-15 19:36:29
1354          newname                              Mon, 2016-02-15 19:50:19
1355          Type 'YES' if you understand this and want to continue: YES
1356

BORG PRUNE

1358          borg [common options] prune [options] [REPOSITORY]
1359
1360   Description
1361       The prune command prunes a repository  by  deleting  all  archives  not
1362       matching  any  of the specified retention options. This command is nor‐
1363       mally used by automated backup scripts wanting to keep a certain number
1364       of historic backups.
1365
1366       Also,  prune  automatically removes checkpoint archives (incomplete ar‐
1367       chives left behind by interrupted backup runs) except if the checkpoint
1368       is  the latest archive (and thus still needed). Checkpoint archives are
1369       not considered when comparing archive counts against the retention lim‐
1370       its (--keep-X).
1371
1372       If a prefix is set with -P, then only archives that start with the pre‐
1373       fix are considered for deletion and only those archives  count  towards
1374       the  totals  specified  by  the  rules.  Otherwise, all archives in the
1375       repository are candidates for deletion!  There is no automatic distinc‐
1376       tion between archives representing different contents. These need to be
1377       distinguished by specifying matching prefixes.
1378
1379       If you have multiple sequences of archives  with  different  data  sets
1380       (e.g.  from different machines) in one shared repository, use one prune
1381       call per data set that matches only the respective archives  using  the
1382       -P option.
1383
1384       The  --keep-within  option takes an argument of the form "<int><char>",
1385       where char is "H", "d", "w", "m", "y". For  example,  --keep-within  2d
1386       means  to keep all archives that were created within the past 48 hours.
1387       "1m" is taken to mean "31d". The archives kept with this option do  not
1388       count towards the totals specified by any other options.
1389
1390       A  good  procedure  is to thin out more and more the older your backups
1391       get.  As an example, --keep-daily 7 means to keep the latest backup  on
1392       each  day,  up to 7 most recent days with backups (days without backups
1393       do not count).  The rules are applied  from  secondly  to  yearly,  and
1394       backups  selected by previous rules do not count towards those of later
1395       rules. The time that each backup starts is used for  pruning  purposes.
1396       Dates  and  times  are  interpreted in the local timezone, and weeks go
1397       from Monday to Sunday. Specifying a negative number of archives to keep
1398       means that there is no limit.
1399
1400       The --keep-last N option is doing the same as --keep-secondly N (and it
1401       will keep the last N archives under the assumption that you do not cre‐
1402       ate more than one backup archive in the same second).
1403
1404       When  using  --stats,  you will get some statistics about how much data
1405       was deleted - the "Deleted data" deduplicated size there is most inter‐
1406       esting  as  that  is how much your repository will shrink.  Please note
1407       that the "All archives" stats refer to the state after pruning.
1408
1409   Examples
1410       Be careful, prune is a potentially dangerous command,  it  will  remove
1411       backup archives.
1412
1413       The  default  of  prune  is  to apply to all archives in the repository
1414       unless you restrict its operation to a subset  of  the  archives  using
1415       --prefix.   When  using  --prefix, be careful to choose a good prefix -
1416       e.g. do not use a prefix "foo" if you do not also want to  match  "foo‐
1417       bar".
1418
1419       It  is strongly recommended to always run prune -v --list --dry-run ...
1420       first so you will see what it would do without it actually  doing  any‐
1421       thing.
1422
1423          # Keep 7 end of day and 4 additional end of week archives.
1424          # Do a dry-run without actually deleting anything.
1425          $ borg prune -v --list --dry-run --keep-daily=7 --keep-weekly=4 /path/to/repo
1426
1427          # Same as above but only apply to archive names starting with the hostname
1428          # of the machine followed by a "-" character:
1429          $ borg prune -v --list --keep-daily=7 --keep-weekly=4 --prefix='{hostname}-' /path/to/repo
1430
1431          # Keep 7 end of day, 4 additional end of week archives,
1432          # and an end of month archive for every month:
1433          $ borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=-1 /path/to/repo
1434
1435          # Keep all backups in the last 10 days, 4 additional end of week archives,
1436          # and an end of month archive for every month:
1437          $ borg prune -v --list --keep-within=10d --keep-weekly=4 --keep-monthly=-1 /path/to/repo
1438
1439       There  is  also  a  visualized  prune  example in docs/misc/prune-exam‐
1440       ple.txt:
1441
1442          borg prune visualized
1443          =====================
1444
1445          Assume it is 2016-01-01, today's backup has not yet been made and you have
1446          created at least one backup on each day in 2015 except on 2015-12-19 (no
1447          backup made on that day).
1448
1449          This is what borg prune --keep-daily 14 --keep-monthly 6 would keep.
1450
1451          Backups kept by the --keep-daily rule are marked by a "d" to the right,
1452          backups kept by the --keep-monthly rule are marked by a "m" to the right.
1453
1454          Calendar view
1455          -------------
1456
1457                                      2015
1458                January               February               March
1459          Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
1460                    1  2  3  4                     1                     1
1461           5  6  7  8  9 10 11   2  3  4  5  6  7  8   2  3  4  5  6  7  8
1462          12 13 14 15 16 17 18   9 10 11 12 13 14 15   9 10 11 12 13 14 15
1463          19 20 21 22 23 24 25  16 17 18 19 20 21 22  16 17 18 19 20 21 22
1464          26 27 28 29 30 31     23 24 25 26 27 28     23 24 25 26 27 28 29
1465                                                      30 31
1466
1467                 April                  May                   June
1468          Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
1469                 1  2  3  4  5               1  2  3   1  2  3  4  5  6  7
1470           6  7  8  9 10 11 12   4  5  6  7  8  9 10   8  9 10 11 12 13 14
1471          13 14 15 16 17 18 19  11 12 13 14 15 16 17  15 16 17 18 19 20 21
1472          20 21 22 23 24 25 26  18 19 20 21 22 23 24  22 23 24 25 26 27 28
1473          27 28 29 30           25 26 27 28 29 30 31  29 30m
1474
1475
1476                  July                 August              September
1477          Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
1478                 1  2  3  4  5                  1  2      1  2  3  4  5  6
1479           6  7  8  9 10 11 12   3  4  5  6  7  8  9   7  8  9 10 11 12 13
1480          13 14 15 16 17 18 19  10 11 12 13 14 15 16  14 15 16 17 18 19 20
1481          20 21 22 23 24 25 26  17 18 19 20 21 22 23  21 22 23 24 25 26 27
1482          27 28 29 30 31m       24 25 26 27 28 29 30  28 29 30m
1483                                31m
1484
1485                October               November              December
1486          Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
1487                    1  2  3  4                     1      1  2  3  4  5  6
1488           5  6  7  8  9 10 11   2  3  4  5  6  7  8   7  8  9 10 11 12 13
1489          12 13 14 15 16 17 18   9 10 11 12 13 14 15  14 15 16 17d18d19 20d
1490          19 20 21 22 23 24 25  16 17 18 19 20 21 22  21d22d23d24d25d26d27d
1491          26 27 28 29 30 31m    23 24 25 26 27 28 29  28d29d30d31d
1492                                30m
1493
1494          List view
1495          ---------
1496
1497          --keep-daily 14     --keep-monthly 6
1498          -------------------------------------------------
1499           1. 2015-12-31          (2015-12-31 kept by daily rule)
1500           2. 2015-12-30       1. 2015-11-30
1501           3. 2015-12-29       2. 2015-10-31
1502           4. 2015-12-28       3. 2015-09-30
1503           5. 2015-12-27       4. 2015-08-31
1504           6. 2015-12-26       5. 2015-07-31
1505           7. 2015-12-25       6. 2015-06-30
1506           8. 2015-12-24
1507           9. 2015-12-23
1508          10. 2015-12-22
1509          11. 2015-12-21
1510          12. 2015-12-20
1511              (no backup made on 2015-12-19)
1512          13. 2015-12-18
1513          14. 2015-12-17
1514
1515
1516          Notes
1517          -----
1518
1519          2015-12-31 is kept due to the --keep-daily 14 rule (because it is applied
1520          first), not due to the --keep-monthly rule.
1521
1522          Because of that, the --keep-monthly 6 rule keeps Nov, Oct, Sep, Aug, Jul and
1523          Jun. December is not considered for this rule, because that backup was already
1524          kept because of the daily rule.
1525
1526          2015-12-17 is kept to satisfy the --keep-daily 14 rule - because no backup was
1527          made on 2015-12-19. If a backup had been made on that day, it would not keep
1528          the one from 2015-12-17.
1529
1530          We did not include yearly, weekly, hourly, minutely or secondly rules to keep
1531          this example simple. They all work in basically the same way.
1532
1533          The weekly rule is easy to understand roughly, but hard to understand in all
1534          details. If interested, read "ISO 8601:2000 standard week-based year".
1535
1536

BORG INFO

1538          borg [common options] info [options] [REPOSITORY_OR_ARCHIVE]
1539
1540   Description
1541       This command displays detailed information about the specified  archive
1542       or repository.
1543
1544       Please  note  that the deduplicated sizes of the individual archives do
1545       not add up to the deduplicated size of the repository ("all archives"),
1546       because the two are meaning different things:
1547
1548       This  archive / deduplicated size = amount of data stored ONLY for this
1549       archive = unique chunks of this archive.  All archives  /  deduplicated
1550       size  =  amount  of data stored in the repo = all chunks in the reposi‐
1551       tory.
1552
1553       Borg archives can only contain a limited amount of file metadata.   The
1554       size  of  an archive relative to this limit depends on a number of fac‐
1555       tors, mainly the number of files, the lengths of paths and other  meta‐
1556       data  stored  for  files.  This is shown as utilization of maximum sup‐
1557       ported archive size.
1558
1559   Examples
1560          $ borg info /path/to/repo::2017-06-29T11:00-srv
1561          Archive name: 2017-06-29T11:00-srv
1562          Archive fingerprint: b2f1beac2bd553b34e06358afa45a3c1689320d39163890c5bbbd49125f00fe5
1563          Comment:
1564          Hostname: myhostname
1565          Username: root
1566          Time (start): Thu, 2017-06-29 11:03:07
1567          Time (end): Thu, 2017-06-29 11:03:13
1568          Duration: 5.66 seconds
1569          Number of files: 17037
1570          Command line: /usr/sbin/borg create /path/to/repo::2017-06-29T11:00-srv /srv
1571          Utilization of max. archive size: 0%
1572          ------------------------------------------------------------------------------
1573                                 Original size      Compressed size    Deduplicated size
1574          This archive:               12.53 GB             12.49 GB              1.62 kB
1575          All archives:              121.82 TB            112.41 TB            215.42 GB
1576
1577                                 Unique chunks         Total chunks
1578          Chunk index:                 1015213            626934122
1579
1580          $ borg info /path/to/repo --last 1
1581          Archive name: 2017-06-29T11:00-srv
1582          Archive fingerprint: b2f1beac2bd553b34e06358afa45a3c1689320d39163890c5bbbd49125f00fe5
1583          Comment:
1584          Hostname: myhostname
1585          Username: root
1586          Time (start): Thu, 2017-06-29 11:03:07
1587          Time (end): Thu, 2017-06-29 11:03:13
1588          Duration: 5.66 seconds
1589          Number of files: 17037
1590          Command line: /usr/sbin/borg create /path/to/repo::2017-06-29T11:00-srv /srv
1591          Utilization of max. archive size: 0%
1592          ------------------------------------------------------------------------------
1593                                 Original size      Compressed size    Deduplicated size
1594          This archive:               12.53 GB             12.49 GB              1.62 kB
1595          All archives:              121.82 TB            112.41 TB            215.42 GB
1596
1597                                 Unique chunks         Total chunks
1598          Chunk index:                 1015213            626934122
1599
1600          $ borg info /path/to/repo
1601          Repository ID: d857ce5788c51272c61535062e89eac4e8ef5a884ffbe976e0af9d8765dedfa5
1602          Location: /path/to/repo
1603          Encrypted: Yes (repokey)
1604          Cache: /root/.cache/borg/d857ce5788c51272c61535062e89eac4e8ef5a884ffbe976e0af9d8765dedfa5
1605          Security dir: /root/.config/borg/security/d857ce5788c51272c61535062e89eac4e8ef5a884ffbe976e0af9d8765dedfa5
1606          ------------------------------------------------------------------------------
1607                                 Original size      Compressed size    Deduplicated size
1608          All archives:              121.82 TB            112.41 TB            215.42 GB
1609
1610                                 Unique chunks         Total chunks
1611          Chunk index:                 1015213            626934122
1612

BORG MOUNT

1614          borg [common options] mount [options] REPOSITORY_OR_ARCHIVE MOUNTPOINT [PATH...]
1615
1616   Description
1617       This command mounts an archive as a FUSE filesystem. This can be useful
1618       for  browsing  an  archive  or  restoring  individual files. Unless the
1619       --foreground option is given the command will  run  in  the  background
1620       until the filesystem is umounted.
1621
1622       The  command borgfs provides a wrapper for borg mount. This can also be
1623       used   in   fstab   entries:   /path/to/repo   /mnt/point   fuse.borgfs
1624       defaults,noauto 0 0
1625
1626       To  allow  a  regular  user  to use fstab entries, add the user option:
1627       /path/to/repo /mnt/point fuse.borgfs defaults,noauto,user 0 0
1628
1629       For FUSE configuration and mount options, see the mount.fuse(8)  manual
1630       page.
1631
1632       Additional mount options supported by borg:
1633
1634       · versions:  when  used  with  a repository mount, this gives a merged,
1635         versioned view of the files in the archives. EXPERIMENTAL, layout may
1636         change in future.
1637
1638       · allow_damaged_files:  by  default damaged files (where missing chunks
1639         were replaced with runs of zeros by  borg  check  --repair)  are  not
1640         readable  and  return  EIO  (I/O error). Set this option to read such
1641         files.
1642
1643       · ignore_permissions: for security  reasons  the  "default_permissions"
1644         mount option is internally enforced by borg. "ignore_permissions" can
1645         be given to not enforce "default_permissions".
1646
1647       The BORG_MOUNT_DATA_CACHE_ENTRIES environment  variable  is  meant  for
1648       advanced  users  to tweak the performance. It sets the number of cached
1649       data chunks; additional memory usage can be up to  ~8  MiB  times  this
1650       number. The default is the number of CPU cores.
1651
1652       When  the  daemonized process receives a signal or crashes, it does not
1653       unmount.  Unmounting in these cases could cause an active rsync or sim‐
1654       ilar process to unintentionally delete data.
1655
1656       When  running  in  the foreground ^C/SIGINT unmounts cleanly, but other
1657       signals or crashes do not.
1658

BORG UMOUNT

1660          borg [common options] umount [options] MOUNTPOINT
1661
1662   Description
1663       This command un-mounts a FUSE filesystem that  was  mounted  with  borg
1664       mount.
1665
1666       This  is  a  convenience  wrapper that just calls the platform-specific
1667       shell command - usually this is either umount or fusermount -u.
1668
1669   Examples
1670          # Mounting the repository shows all archives.
1671          # Archives are loaded lazily, expect some delay when navigating to an archive
1672          # for the first time.
1673          $ borg mount /path/to/repo /tmp/mymountpoint
1674          $ ls /tmp/mymountpoint
1675          root-2016-02-14 root-2016-02-15
1676          $ borg umount /tmp/mymountpoint
1677
1678          # Mounting a specific archive is possible as well.
1679          $ borg mount /path/to/repo::root-2016-02-15 /tmp/mymountpoint
1680          $ ls /tmp/mymountpoint
1681          bin  boot  etc      home  lib  lib64  lost+found  media  mnt  opt
1682          root  sbin  srv  tmp  usr  var
1683          $ borg umount /tmp/mymountpoint
1684
1685          # The experimental "versions view" merges all archives in the repository
1686          # and provides a versioned view on files.
1687          $ borg mount -o versions /path/to/repo /tmp/mymountpoint
1688          $ ls -l /tmp/mymountpoint/home/user/doc.txt/
1689          total 24
1690          -rw-rw-r-- 1 user group 12357 Aug 26 21:19 doc.cda00bc9.txt
1691          -rw-rw-r-- 1 user group 12204 Aug 26 21:04 doc.fa760f28.txt
1692          $ borg umount /tmp/mymountpoint
1693
1694          # Archive filters are supported.
1695          # These are especially handy for the "versions view",
1696          # which does not support lazy processing of archives.
1697          $ borg mount -o versions --glob-archives '*-my-home' --last 10 /path/to/repo /tmp/mymountpoint
1698
1699          # Exclusion options are supported.
1700          # These can speed up mounting and lower memory needs significantly.
1701          $ borg mount /path/to/repo /tmp/mymountpoint only/that/path
1702          $ borg mount --exclude '...' /path/to/repo /tmp/mymountpoint
1703
1704   borgfs
1705          $ echo '/mnt/backup /tmp/myrepo fuse.borgfs defaults,noauto 0 0' >> /etc/fstab
1706          $ echo '/mnt/backup::root-2016-02-15 /tmp/myarchive fuse.borgfs defaults,noauto 0 0' >> /etc/fstab
1707          $ mount /tmp/myrepo
1708          $ mount /tmp/myarchive
1709          $ ls /tmp/myrepo
1710          root-2016-02-01 root-2016-02-2015
1711          $ ls /tmp/myarchive
1712          bin  boot  etc      home  lib  lib64  lost+found  media  mnt  opt  root  sbin  srv  tmp  usr  var
1713
1714       NOTE:
1715          borgfs will be automatically provided if  you  used  a  distribution
1716          package,  pip  or  setup.py to install Borg. Users of the standalone
1717          binary  will  have  to  manually  create  a   symlink   (see   pyin‐
1718          staller-binary).
1719

BORG KEY CHANGE-PASSPHRASE

1721          borg [common options] key change-passphrase [options] [REPOSITORY]
1722
1723   Description
1724       The  key files used for repository encryption are optionally passphrase
1725       protected. This command can be used to change this passphrase.
1726
1727       Please note that this command only changes the passphrase, but not  any
1728       secret protected by it (like e.g. encryption/MAC keys or chunker seed).
1729       Thus, changing the passphrase after passphrase and borg key got compro‐
1730       mised  does  not  protect future (nor past) backups to the same reposi‐
1731       tory.
1732
1733   Examples
1734          # Create a key file protected repository
1735          $ borg init --encryption=keyfile -v /path/to/repo
1736          Initializing repository at "/path/to/repo"
1737          Enter new passphrase:
1738          Enter same passphrase again:
1739          Remember your passphrase. Your data will be inaccessible without it.
1740          Key in "/root/.config/borg/keys/mnt_backup" created.
1741          Keep this key safe. Your data will be inaccessible without it.
1742          Synchronizing chunks cache...
1743          Archives: 0, w/ cached Idx: 0, w/ outdated Idx: 0, w/o cached Idx: 0.
1744          Done.
1745
1746          # Change key file passphrase
1747          $ borg key change-passphrase -v /path/to/repo
1748          Enter passphrase for key /root/.config/borg/keys/mnt_backup:
1749          Enter new passphrase:
1750          Enter same passphrase again:
1751          Remember your passphrase. Your data will be inaccessible without it.
1752          Key updated
1753
1754       Fully automated using environment variables:
1755
1756          $ BORG_NEW_PASSPHRASE=old borg init -e=repokey repo
1757          # now "old" is the current passphrase.
1758          $ BORG_PASSPHRASE=old BORG_NEW_PASSPHRASE=new borg key change-passphrase repo
1759          # now "new" is the current passphrase.
1760

BORG KEY EXPORT

1762          borg [common options] key export [options] [REPOSITORY] [PATH]
1763
1764   Description
1765       If repository encryption is used, the repository is inaccessible  with‐
1766       out  the  key.  This command allows to backup this essential key.  Note
1767       that the backup produced does not include the passphrase  itself  (i.e.
1768       the  exported  key  stays  encrypted).  In  order to regain access to a
1769       repository,  one  needs  both  the  exported  key  and   the   original
1770       passphrase.
1771
1772       There  are two backup formats. The normal backup format is suitable for
1773       digital storage as a file. The --paper backup format is  optimized  for
1774       printing  and typing in while importing, with per line checks to reduce
1775       problems with manual input.
1776
1777       For repositories using keyfile encryption the key is saved  locally  on
1778       the  system  that is capable of doing backups. To guard against loss of
1779       this key, the key needs to be backed up independently of the main  data
1780       backup.
1781
1782       For  repositories  using the repokey encryption the key is saved in the
1783       repository in the config file. A backup is thus  not  strictly  needed,
1784       but  guards against the repository becoming inaccessible if the file is
1785       damaged for some reason.
1786

BORG KEY IMPORT

1788          borg [common options] key import [options] [REPOSITORY] [PATH]
1789
1790   Description
1791       This command allows to restore a key  previously  backed  up  with  the
1792       export command.
1793
1794       If  the  --paper  option  is  given,  the import will be an interactive
1795       process in which each line is checked for plausibility before  proceed‐
1796       ing to the next line. For this format PATH must not be given.
1797

BORG UPGRADE

1799          borg [common options] upgrade [options] [REPOSITORY]
1800
1801   Description
1802       Upgrade an existing, local Borg repository.
1803
1804   When you do not need borg upgrade
1805       Not every change requires that you run borg upgrade.
1806
1807       You do not need to run it when:
1808
1809       · moving your repository to a different place
1810
1811       · upgrading to another point release (like 1.0.x to 1.0.y), except when
1812         noted otherwise in the changelog
1813
1814       · upgrading from 1.0.x to 1.1.x, except when  noted  otherwise  in  the
1815         changelog
1816
1817   Borg 1.x.y upgrades
1818       Use  borg  upgrade --tam REPO to require manifest authentication intro‐
1819       duced with Borg 1.0.9 to address security issues. This means that modi‐
1820       fying  the  repository  after  doing this with a version prior to 1.0.9
1821       will raise a validation error,  so  only  perform  this  upgrade  after
1822       updating all clients using the repository to 1.0.9 or newer.
1823
1824       This upgrade should be done on each client for safety reasons.
1825
1826       If  a repository is accidentally modified with a pre-1.0.9 client after
1827       this upgrade, use borg upgrade --tam --force REPO to remedy it.
1828
1829       If you routinely do this you might not  want  to  enable  this  upgrade
1830       (which  will  leave you exposed to the security issue). You can reverse
1831       the upgrade by issuing borg upgrade --disable-tam REPO.
1832
1833       See
1834       https://borgbackup.readthedocs.io/en/stable/changes.html#pre-1-0-9-manifest-spoofing-vulnerability
1835       for details.
1836
1837   Attic and Borg 0.xx to Borg 1.x
1838       This currently supports converting an Attic repository to Borg and also
1839       helps with converting Borg 0.xx to 1.0.
1840
1841       Currently, only LOCAL repositories can be upgraded (issue #465).
1842
1843       Please  note  that  borg  create  (since  1.0.0)  uses bigger chunks by
1844       default than old borg or attic did, so the new chunks won't deduplicate
1845       with  the  old chunks in the upgraded repository.  See --chunker-params
1846       option of borg create and borg recreate.
1847
1848       borg upgrade will change the magic strings in the repository's segments
1849       to   match   the   new  Borg  magic  strings.  The  keyfiles  found  in
1850       $ATTIC_KEYS_DIR or ~/.attic/keys/ will also be converted and copied  to
1851       $BORG_KEYS_DIR or ~/.config/borg/keys.
1852
1853       The  cache files are converted, from $ATTIC_CACHE_DIR or ~/.cache/attic
1854       to $BORG_CACHE_DIR or ~/.cache/borg, but the cache layout between  Borg
1855       and Attic changed, so it is possible the first backup after the conver‐
1856       sion takes longer than expected due to the cache resync.
1857
1858       Upgrade should be able to resume if interrupted, although it will still
1859       iterate  over all segments. If you want to start from scratch, use borg
1860       delete over the copied repository to make sure the cache files are also
1861       removed:
1862          borg delete borg
1863
1864       Unless  --inplace  is  specified,  the  upgrade process first creates a
1865       backup copy of the repository,  in  REPOSITORY.before-upgrade-DATETIME,
1866       using  hardlinks.   This  requires  that  the repository and its parent
1867       directory reside on same filesystem so  the  hardlink  copy  can  work.
1868       This  takes  longer than in place upgrades, but is much safer and gives
1869       progress information (as opposed to cp -al).  Once  you  are  satisfied
1870       with the conversion, you can safely destroy the backup copy.
1871
1872       WARNING:  Running the upgrade in place will make the current copy unus‐
1873       able with older version, with no way of going  back  to  previous  ver‐
1874       sions. This can PERMANENTLY DAMAGE YOUR REPOSITORY!  Attic CAN NOT READ
1875       BORG REPOSITORIES, as the magic strings have  changed.  You  have  been
1876       warned.
1877
1878   Examples
1879          # Upgrade the borg repository to the most recent version.
1880          $ borg upgrade -v /path/to/repo
1881          making a hardlink copy in /path/to/repo.before-upgrade-2016-02-15-20:51:55
1882          opening attic repository with borg and converting
1883          no key file found for repository
1884          converting repo index /path/to/repo/index.0
1885          converting 1 segments...
1886          converting borg 0.xx to borg current
1887          no key file found for repository
1888
1889   Upgrading a passphrase encrypted attic repo
1890       attic  offered  a "passphrase" encryption mode, but this was removed in
1891       borg  1.0  and  replaced  by  the  "repokey"  mode  (which  stores  the
1892       passphrase-protected encryption key into the repository config).
1893
1894       Thus,  to upgrade a "passphrase" attic repo to a "repokey" borg repo, 2
1895       steps are needed, in this order:
1896
1897       · borg upgrade repo
1898
1899       · borg key migrate-to-repokey repo
1900

BORG RECREATE

1902          borg [common options] recreate [options] [REPOSITORY_OR_ARCHIVE] [PATH...]
1903
1904   Description
1905       Recreate the contents of existing archives.
1906
1907       This is an experimental feature. Do not use this on your only backup.
1908
1909       --exclude, --exclude-from,  --exclude-if-present,  --keep-exclude-tags,
1910       and  PATH  have  the exact same semantics as in "borg create". If PATHs
1911       are specified the resulting archive will only contain files from  these
1912       PATHs.
1913
1914       Note that all paths in an archive are relative, therefore absolute pat‐
1915       terns/paths will not match (--exclude, --exclude-from, PATHs).
1916
1917       --recompress allows to change the compression of existing data  in  ar‐
1918       chives.   Due to how Borg stores compressed size information this might
1919       display incorrect information for archives that were not  recreated  at
1920       the same time.  There is no risk of data loss by this.
1921
1922       --chunker-params  will  re-chunk  all files in the archive, this can be
1923       used to have upgraded Borg 0.xx or Attic archives deduplicate with Borg
1924       1.x archives.
1925
1926       USE  WITH CAUTION.  Depending on the PATHs and patterns given, recreate
1927       can be used to permanently delete files from archives.  When in  doubt,
1928       use  --dry-run  --verbose  --list  to see how patterns/PATHS are inter‐
1929       preted.
1930
1931       The archive being recreated is only removed after  the  operation  com‐
1932       pletes.  The  archive  that is built during the operation exists at the
1933       same time at "<ARCHIVE>.recreate". The new archive will have a  differ‐
1934       ent archive ID.
1935
1936       With  --target  the original archive is not replaced, instead a new ar‐
1937       chive is created.
1938
1939       When rechunking space usage can be substantial,  expect  at  least  the
1940       entire  deduplicated  size  of  the archives using the previous chunker
1941       params.   When  recompressing  expect  approx.  (throughput  /   check‐
1942       point-interval) in space usage, assuming all chunks are recompressed.
1943
1944       If  you  recently ran borg check --repair and it had to fix lost chunks
1945       with all-zero replacement chunks, please first run another  backup  for
1946       the same data and re-run borg check --repair afterwards to heal any ar‐
1947       chives that had lost chunks which are still generated  from  the  input
1948       data.
1949
1950       Important:   running   borg   recreate  to  re-chunk  will  remove  the
1951       chunks_healthy metadata of all items with replacement chunks, so  heal‐
1952       ing  will  not  be  possible  any  more  after  re-chunking (it is also
1953       unlikely it would ever work: due to the change of chunking  parameters,
1954       the  missing  chunk  likely  will never be seen again even if you still
1955       have the data that produced it).
1956
1957   Examples
1958          # Make old (Attic / Borg 0.xx) archives deduplicate with Borg 1.x archives.
1959          # Archives created with Borg 1.1+ and the default chunker params are skipped
1960          # (archive ID stays the same).
1961          $ borg recreate /mnt/backup --chunker-params default --progress
1962
1963          # Create a backup with little but fast compression
1964          $ borg create /mnt/backup::archive /some/files --compression lz4
1965          # Then compress it - this might take longer, but the backup has already completed,
1966          # so no inconsistencies from a long-running backup job.
1967          $ borg recreate /mnt/backup::archive --recompress --compression zlib,9
1968
1969          # Remove unwanted files from all archives in a repository.
1970          # Note the relative path for the --exclude option - archives only contain relative paths.
1971          $ borg recreate /mnt/backup --exclude home/icke/Pictures/drunk_photos
1972
1973          # Change archive comment
1974          $ borg create --comment "This is a comment" /mnt/backup::archivename ~
1975          $ borg info /mnt/backup::archivename
1976          Name: archivename
1977          Fingerprint: ...
1978          Comment: This is a comment
1979          ...
1980          $ borg recreate --comment "This is a better comment" /mnt/backup::archivename
1981          $ borg info /mnt/backup::archivename
1982          Name: archivename
1983          Fingerprint: ...
1984          Comment: This is a better comment
1985          ...
1986

BORG EXPORT-TAR

1988          borg [common options] export-tar [options] ARCHIVE FILE [PATH...]
1989
1990   Description
1991       This command creates a tarball from an archive.
1992
1993       When giving '-' as the output FILE, Borg will write  a  tar  stream  to
1994       standard output.
1995
1996       By default (--tar-filter=auto) Borg will detect whether the FILE should
1997       be compressed based on its file extension and pipe the tarball  through
1998       an appropriate filter before writing it to FILE:
1999
2000       · .tar.gz: gzip
2001
2002       · .tar.bz2: bzip2
2003
2004       · .tar.xz: xz
2005
2006       Alternatively  a  --tar-filter  program may be explicitly specified. It
2007       should read the uncompressed tar stream from stdin  and  write  a  com‐
2008       pressed/filtered tar stream to stdout.
2009
2010       The generated tarball uses the GNU tar format.
2011
2012       export-tar  is a lossy conversion: BSD flags, ACLs, extended attributes
2013       (xattrs), atime and ctime are not exported.   Timestamp  resolution  is
2014       limited  to whole seconds, not the nanosecond resolution otherwise sup‐
2015       ported by Borg.
2016
2017       A --sparse option (as found in borg extract) is not supported.
2018
2019       By default the entire archive is extracted but a subset  of  files  and
2020       directories  can  be  selected by passing a list of PATHs as arguments.
2021       The file selection can further be restricted  by  using  the  --exclude
2022       option.
2023
2024       See  the  output  of  the "borg help patterns" command for more help on
2025       exclude patterns.
2026
2027       --progress can be slower than no progress display, since it  makes  one
2028       additional pass over the archive metadata.
2029
2030   Examples
2031          # export as uncompressed tar
2032          $ borg export-tar /path/to/repo::Monday Monday.tar
2033
2034          # exclude some types, compress using gzip
2035          $ borg export-tar /path/to/repo::Monday Monday.tar.gz --exclude '*.so'
2036
2037          # use higher compression level with gzip
2038          $ borg export-tar --tar-filter="gzip -9" testrepo::linux Monday.tar.gz
2039
2040          # export a tar, but instead of storing it on disk,
2041          # upload it to a remote site using curl.
2042          $ borg export-tar /path/to/repo::Monday - | curl --data-binary @- https://somewhere/to/POST
2043
2044          # remote extraction via "tarpipe"
2045          $ borg export-tar /path/to/repo::Monday - | ssh somewhere "cd extracted; tar x"
2046

BORG SERVE

2048          borg [common options] serve [options]
2049
2050   Description
2051       This  command  starts a repository server process. This command is usu‐
2052       ally not used manually.
2053
2054   Examples
2055       borg serve has special support for  ssh  forced  commands  (see  autho‐
2056       rized_keys  example  below):  it will detect that you use such a forced
2057       command and extract the value of the --restrict-to-path option(s).
2058
2059       It will then parse the original command  that  came  from  the  client,
2060       makes  sure  that it is also borg serve and enforce path restriction(s)
2061       as given by the forced command. That way, other options  given  by  the
2062       client (like --info or --umask) are preserved (and are not fixed by the
2063       forced command).
2064
2065       Environment variables (such as  BORG_HOSTNAME_IS_UNIQUE)  contained  in
2066       the  original  command  sent  by  the  client  are not interpreted, but
2067       ignored. If BORG_XXX environment variables should be set  on  the  borg
2068       serve  side,  then  these must be set in system-specific locations like
2069       /etc/environment or in the forced command itself (example below).
2070
2071          # Allow an SSH keypair to only run borg, and only have access to /path/to/repo.
2072          # Use key options to disable unneeded and potentially dangerous SSH functionality.
2073          # This will help to secure an automated remote backup system.
2074          $ cat ~/.ssh/authorized_keys
2075          command="borg serve --restrict-to-path /path/to/repo",restrict ssh-rsa AAAAB3[...]
2076
2077          # Set a BORG_XXX environment variable on the "borg serve" side
2078          $ cat ~/.ssh/authorized_keys
2079          command="export BORG_XXX=value; borg serve [...]",restrict ssh-rsa [...]
2080
2081       NOTE:
2082          The examples above use the restrict directive. This  does  automati‐
2083          cally  block  potential  dangerous  ssh features, even when they are
2084          added in a future update. Thus, this option should be preferred.
2085
2086          If you're using openssh-server < 7.2, however, you have  to  explic‐
2087          itly  specify the ssh features to restrict and cannot simply use the
2088          restrict option as it has been introduced in v7.2. We  recommend  to
2089          use    no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forward‐
2090          ing,no-user-rc in this case.
2091
2092   SSH Configuration
2093       borg serve's pipes (stdin/stdout/stderr)  are  connected  to  the  sshd
2094       process  on  the  server  side.  In  the  event that the SSH connection
2095       between borg serve and the client is disconnected or  stuck  abnormally
2096       (for  example,  due  to  a network outage), it can take a long time for
2097       sshd to notice the client is disconnected. In the meantime,  sshd  con‐
2098       tinues  running, and as a result so does the borg serve process holding
2099       the lock on the repository. This can cause subsequent  borg  operations
2100       on  the  remote  repository  to  fail  with  the  error: Failed to cre‐
2101       ate/acquire the lock.
2102
2103       In order to avoid this, it is  recommended  to  perform  the  following
2104       additional SSH configuration:
2105
2106       Either  in  the  client  side's  ~/.ssh/config file, or in the client's
2107       /etc/ssh/ssh_config file:
2108
2109          Host backupserver
2110                  ServerAliveInterval 10
2111                  ServerAliveCountMax 30
2112
2113       Replacing backupserver with the hostname, FQDN or  IP  address  of  the
2114       borg server.
2115
2116       This  will  cause the client to send a keepalive to the server every 10
2117       seconds. If 30 consecutive keepalives are sent without  a  response  (a
2118       time  of 300 seconds), the ssh client process will be terminated, caus‐
2119       ing the borg process to terminate gracefully.
2120
2121       On   the   server   side's   sshd   configuration    file    (typically
2122       /etc/ssh/sshd_config):
2123
2124          ClientAliveInterval 10
2125          ClientAliveCountMax 30
2126
2127       This  will cause the server to send a keep alive to the client every 10
2128       seconds. If 30 consecutive keepalives are sent without  a  response  (a
2129       time  of  300  seconds),  the server's sshd process will be terminated,
2130       causing the borg serve process to terminate gracefully and release  the
2131       lock on the repository.
2132
2133       If  you  then run borg commands with --lock-wait 600, this gives suffi‐
2134       cient time for the borg serve processes to terminate after the SSH con‐
2135       nection  is  torn  down after the 300 second wait for the keepalives to
2136       fail.
2137
2138       You may, of course, modify the timeout  values  demonstrated  above  to
2139       values that suit your environment and use case.
2140

BORG CONFIG

2142          borg [common options] config [options] REPOSITORY [NAME] [VALUE]
2143
2144   Description
2145       This  command gets and sets options in a local repository or cache con‐
2146       fig file.  For security reasons,  this  command  only  works  on  local
2147       repositories.
2148
2149       To  delete a config value entirely, use --delete. To list the values of
2150       the configuration file or the default values, use --list.  To  get  and
2151       existing  key,  pass only the key name. To set a key, pass both the key
2152       name and the new value. Keys can  be  specified  in  the  format  "sec‐
2153       tion.name"  or  simply "name"; the section will default to "repository"
2154       and "cache" for the repo and cache configs, respectively.
2155
2156       By default, borg config manipulates the repository config  file.  Using
2157       --cache edits the repository cache's config file instead.
2158
2159       NOTE:
2160          The  repository  &  cache config files are some of the only directly
2161          manipulable parts of a repository that aren't  versioned  or  backed
2162          up, so be careful when making changes!
2163
2164   Examples
2165          # find cache directory
2166          $ cd ~/.cache/borg/$(borg config /path/to/repo id)
2167
2168          # reserve some space
2169          $ borg config /path/to/repo additional_free_space 2G
2170
2171          # make a repo append-only
2172          $ borg config /path/to/repo append_only 1
2173

BORG WITH-LOCK

2175          borg [common options] with-lock [options] REPOSITORY COMMAND [ARGS...]
2176
2177   Description
2178       This command runs a user-specified command while the repository lock is
2179       held.
2180
2181       It will first try to acquire the lock (make sure that no  other  opera‐
2182       tion  is running in the repo), then execute the given command as a sub‐
2183       process and wait for its termination, release the lock and  return  the
2184       user command's return code as borg's return code.
2185
2186       NOTE:
2187          If  you  copy  a  repository  with  the  lock held, the lock will be
2188          present in the copy. Thus, before using borg on the copy from a dif‐
2189          ferent host, you need to use "borg break-lock" on the copied reposi‐
2190          tory, because Borg is cautious and  does  not  automatically  remove
2191          stale locks made by a different host.
2192

BORG BREAK-LOCK

2194          borg [common options] break-lock [options] [REPOSITORY]
2195
2196   Description
2197       This  command  breaks the repository and cache locks.  Please use care‐
2198       fully and only while no borg process (on  any  machine)  is  trying  to
2199       access the Cache or the Repository.
2200

BORG BENCHMARK CRUD

2202          borg [common options] benchmark crud [options] REPO PATH
2203
2204   Description
2205       This command benchmarks borg CRUD (create, read, update, delete) opera‐
2206       tions.
2207
2208       It creates input data below the given PATH and backups this  data  into
2209       the given REPO.  The REPO must already exist (it could be a fresh empty
2210       repo or an existing repo, the command will create /  read  /  update  /
2211       delete some archives named borg-benchmark-crud* there.
2212
2213       Make  sure  you  have  free  space there, you'll need about 1GB each (+
2214       overhead).
2215
2216       If your repository is encrypted and borg needs a passphrase  to  unlock
2217       the key, use:
2218
2219       BORG_PASSPHRASE=mysecret borg benchmark crud REPO PATH
2220
2221       Measurements  are done with different input file sizes and counts.  The
2222       file contents are very artificial (either all zero or all random), thus
2223       the  measurement  results  do  not necessarily reflect performance with
2224       real data.  Also, due to the kind of content used,  no  compression  is
2225       used in these benchmarks.
2226
2227       C-  ==  borg  create  (1st archive creation, no compression, do not use
2228       files cache)
2229              C-Z- == all-zero files. full dedup, this is primarily  measuring
2230              reader/chunker/hasher.   C-R- == random files. no dedup, measur‐
2231              ing throughput through all processing stages.
2232
2233       R- == borg extract (extract archive, dry-run, do everything, but do not
2234       write files to disk)
2235              R-Z-  ==  all  zero  files.  Measuring heavily duplicated files.
2236              R-R- == random files. No duplication here, measuring  throughput
2237              through all processing stages, except writing to disk.
2238
2239       U-  == borg create (2nd archive creation of unchanged input files, mea‐
2240       sure files cache speed)
2241              The throughput value is kind of virtual here, it does not  actu‐
2242              ally  read  the  file.   U-Z-  ==  needs to check the 2 all-zero
2243              chunks' existence in the repo.  U-R- == needs to check existence
2244              of a lot of different chunks in the repo.
2245
2246       D- == borg delete archive (delete last remaining archive, measure dele‐
2247       tion + compaction)
2248              D-Z- == few chunks to delete / few segments  to  compact/remove.
2249              D-R- == many chunks to delete / many segments to compact/remove.
2250
2251       Please  note  that there might be quite some variance in these measure‐
2252       ments.  Try multiple measurements and having a otherwise  idle  machine
2253       (and network, if you use it).
2254

MISCELLANEOUS HELP

2256   borg help patterns
2257       The  path/filenames  used  as input for the pattern matching start from
2258       the currently active recursion root. You  usually  give  the  recursion
2259       root(s) when invoking borg and these can be either relative or absolute
2260       paths.
2261
2262       So, when you give relative/ as root, the paths going into  the  matcher
2263       will look like relative/.../file.ext. When you give /absolute/ as root,
2264       they will look like /absolute/.../file.ext. This is meant when we  talk
2265       about "full path" below.
2266
2267       File  patterns  support  these  styles: fnmatch, shell, regular expres‐
2268       sions, path prefixes and path full-matches. By default, fnmatch is used
2269       for  --exclude  patterns  and  shell-style is used for the experimental
2270       --pattern option.
2271
2272       If followed by a colon (':') the first two characters of a pattern  are
2273       used  as a style selector. Explicit style selection is necessary when a
2274       non-default style is desired or when the desired  pattern  starts  with
2275       two alphanumeric characters followed by a colon (i.e. aa:something/*).
2276
2277       Fnmatch, selector fm:
2278              This  is  the  default  style  for --exclude and --exclude-from.
2279              These patterns use a variant of shell pattern syntax,  with  '*'
2280              matching any number of characters, '?' matching any single char‐
2281              acter, '[...]' matching any single character specified,  includ‐
2282              ing  ranges,  and '[!...]' matching any character not specified.
2283              For the purpose of these patterns, the path separator (backslash
2284              for  Windows and '/' on other systems) is not treated specially.
2285              Wrap meta-characters in brackets for a literal match  (i.e.  [?]
2286              to  match  the  literal character ?). For a path to match a pat‐
2287              tern, the full path must match, or it must match from the  start
2288              of the full path to just before a path separator. Except for the
2289              root path, paths will never  end  in  the  path  separator  when
2290              matching  is attempted.  Thus, if a given pattern ends in a path
2291              separator, a '*' is appended before matching is attempted.
2292
2293       Shell-style patterns, selector sh:
2294              This is the default style  for  --pattern  and  --patterns-from.
2295              Like  fnmatch  patterns these are similar to shell patterns. The
2296              difference is that the pattern may include **/ for matching zero
2297              or  more directory levels, * for matching zero or more arbitrary
2298              characters with the exception of any path separator.
2299
2300       Regular expressions, selector re:
2301              Regular expressions similar to those  found  in  Perl  are  sup‐
2302              ported.  Unlike  shell  patterns  regular  expressions  are  not
2303              required to match the full path and any substring match is  suf‐
2304              ficient.  It  is  strongly recommended to anchor patterns to the
2305              start ('^'), to the end ('$') or both.  Path  separators  (back‐
2306              slash  for Windows and '/' on other systems) in paths are always
2307              normalized to a forward slash ('/') before applying  a  pattern.
2308              The  regular  expression syntax is described in the Python docu‐
2309              mentation for the re module.
2310
2311       Path prefix, selector pp:
2312              This pattern style is useful to match whole sub-directories. The
2313              pattern  pp:root/somedir  matches  root/somedir  and  everything
2314              therein.
2315
2316       Path full-match, selector pf:
2317              This pattern style is (only) useful to match full  paths.   This
2318              is  kind  of a pseudo pattern as it can not have any variable or
2319              unspecified   parts   -   the   full   path   must   be   given.
2320              pf:root/file.ext matches root/file.txt only.
2321
2322              Implementation note: this is implemented via very time-efficient
2323              O(1) hashtable lookups (this means you can have huge amounts  of
2324              such patterns without impacting performance much).  Due to that,
2325              this kind of pattern does not respect any context or order.   If
2326              you  use  such  a  pattern  to include a file, it will always be
2327              included (if the  directory  recursion  encounters  it).   Other
2328              include/exclude  patterns  that  would  normally  match  will be
2329              ignored.  Same logic applies for exclude.
2330
2331       NOTE:
2332          re:, sh: and fm: patterns are all implemented on top of  the  Python
2333          SRE  engine. It is very easy to formulate patterns for each of these
2334          types which requires an inordinate amount of time to match paths. If
2335          untrusted users are able to supply patterns, ensure they cannot sup‐
2336          ply re: patterns.  Further, ensure that sh: and  fm:  patterns  only
2337          contain a handful of wildcards at most.
2338
2339       Exclusions  can  be  passed via the command line option --exclude. When
2340       used from within a shell the patterns should be quoted to protect  them
2341       from expansion.
2342
2343       The  --exclude-from  option  permits  loading exclusion patterns from a
2344       text file with one pattern per line. Lines empty or starting  with  the
2345       number  sign  ('#') after removing whitespace on both ends are ignored.
2346       The optional style selector  prefix  is  also  supported  for  patterns
2347       loaded  from a file. Due to whitespace removal paths with whitespace at
2348       the beginning or end can only be excluded using regular expressions.
2349
2350       Examples:
2351
2352          # Exclude '/home/user/file.o' but not '/home/user/file.odt':
2353          $ borg create -e '*.o' backup /
2354
2355          # Exclude '/home/user/junk' and '/home/user/subdir/junk' but
2356          # not '/home/user/importantjunk' or '/etc/junk':
2357          $ borg create -e '/home/*/junk' backup /
2358
2359          # Exclude the contents of '/home/user/cache' but not the directory itself:
2360          $ borg create -e /home/user/cache/ backup /
2361
2362          # The file '/home/user/cache/important' is *not* backed up:
2363          $ borg create -e /home/user/cache/ backup / /home/user/cache/important
2364
2365          # The contents of directories in '/home' are not backed up when their name
2366          # ends in '.tmp'
2367          $ borg create --exclude 're:^/home/[^/]+\.tmp/' backup /
2368
2369          # Load exclusions from file
2370          $ cat >exclude.txt <<EOF
2371          # Comment line
2372          /home/*/junk
2373          *.tmp
2374          fm:aa:something/*
2375          re:^/home/[^/]\.tmp/
2376          sh:/home/*/.thumbnails
2377          EOF
2378          $ borg create --exclude-from exclude.txt backup /
2379       A more general and easier to use way to define filename  matching  pat‐
2380       terns  exists  with  the  experimental  --pattern  and  --patterns-from
2381       options. Using these,  you  may  specify  the  backup  roots  (starting
2382       points)  and patterns for inclusion/exclusion.  A root path starts with
2383       the prefix R, followed by a path (a plain path, not a file pattern). An
2384       include  rule starts with the prefix +, an exclude rule starts with the
2385       prefix -, an exclude-norecurse rule starts with !, all  followed  by  a
2386       pattern.   Inclusion patterns are useful to include paths that are con‐
2387       tained in an excluded path. The first matching pattern is used so if an
2388       include  pattern  matches before an exclude pattern, the file is backed
2389       up. If an exclude-norecurse  pattern  matches  a  directory,  it  won't
2390       recurse  into  it  and won't discover any potential matches for include
2391       rules below that directory.
2392
2393       Note that the default pattern style for --pattern  and  --patterns-from
2394       is  shell  style  (sh:),  so  those  patterns  behave  similar to rsync
2395       include/exclude patterns. The pattern style can be set via the  P  pre‐
2396       fix.
2397
2398       Patterns (--pattern) and excludes (--exclude) from the command line are
2399       considered first (in the  order  of  appearance).  Then  patterns  from
2400       --patterns-from are added. Exclusion patterns from --exclude-from files
2401       are appended last.
2402
2403       Examples:
2404
2405          # backup pics, but not the ones from 2018, except the good ones:
2406          # note: using = is essential to avoid cmdline argument parsing issues.
2407          borg create --pattern=+pics/2018/good --pattern=-pics/2018 repo::arch pics
2408
2409          # use a file with patterns:
2410          borg create --patterns-from patterns.lst repo::arch
2411
2412       The patterns.lst file could look like that:
2413
2414          # "sh:" pattern style is the default, so the following line is not needed:
2415          P sh
2416          R /
2417          # can be rebuild
2418          - /home/*/.cache
2419          # they're downloads for a reason
2420          - /home/*/Downloads
2421          # susan is a nice person
2422          # include susans home
2423          + /home/susan
2424          # don't backup the other home directories
2425          - /home/*
2426
2427   borg help placeholders
2428       Repository (or Archive) URLs, --prefix, --glob-archives, --comment  and
2429       --remote-path values support these placeholders:
2430
2431       {hostname}
2432              The (short) hostname of the machine.
2433
2434       {fqdn} The full name of the machine.
2435
2436       {reverse-fqdn}
2437              The full name of the machine in reverse domain name notation.
2438
2439       {now}  The  current local date and time, by default in ISO-8601 format.
2440              You   can   also   supply   your   own   format   string,   e.g.
2441              {now:%Y-%m-%d_%H:%M:%S}
2442
2443       {utcnow}
2444              The  current  UTC  date and time, by default in ISO-8601 format.
2445              You  can  also  supply  your  own  format  string,  e.g.   {utc‐
2446              now:%Y-%m-%d_%H:%M:%S}
2447
2448       {user} The user name (or UID, if no name is available) of the user run‐
2449              ning borg.
2450
2451       {pid}  The current process ID.
2452
2453       {borgversion}
2454              The version of borg, e.g.: 1.0.8rc1
2455
2456       {borgmajor}
2457              The version of borg, only the major version, e.g.: 1
2458
2459       {borgminor}
2460              The version of borg, only major and minor version, e.g.: 1.0
2461
2462       {borgpatch}
2463              The version of borg, only major, minor and patch version,  e.g.:
2464              1.0.8
2465
2466       If literal curly braces need to be used, double them for escaping:
2467
2468          borg create /path/to/repo::{{literal_text}}
2469
2470       Examples:
2471
2472          borg create /path/to/repo::{hostname}-{user}-{utcnow} ...
2473          borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ...
2474          borg prune --prefix '{hostname}-' ...
2475
2476       NOTE:
2477          systemd  uses  a difficult, non-standard syntax for command lines in
2478          unit files (refer to the systemd.unit(5) manual page).
2479
2480          When invoking borg from unit  files,  pay  particular  attention  to
2481          escaping,  especially  when using the now/utcnow placeholders, since
2482          systemd performs its own %-based variable replacement even in quoted
2483          text.  To  avoid interference from systemd, double all percent signs
2484          ({hostname}-{now:%Y-%m-%d_%H:%M:%S}          becomes          {host‐
2485          name}-{now:%%Y-%%m-%%d_%%H:%%M:%%S}).
2486
2487   borg help compression
2488       It  is  no  problem  to  mix different compression methods in one repo,
2489       deduplication is done on the source data chunks (not on the  compressed
2490       or encrypted data).
2491
2492       If  some  specific  chunk was once compressed and stored into the repo,
2493       creating another backup that also uses this chunk will not  change  the
2494       stored  chunk.  So if you use different compression specs for the back‐
2495       ups, whichever stores a chunk first  determines  its  compression.  See
2496       also borg recreate.
2497
2498       Compression  is lz4 by default. If you want something else, you have to
2499       specify what you want.
2500
2501       Valid compression specifiers are:
2502
2503       none   Do not compress.
2504
2505       lz4    Use lz4 compression. Very  high  speed,  very  low  compression.
2506              (default)
2507
2508       zstd[,L]
2509              Use  zstd  ("zstandard")  compression, a modern wide-range algo‐
2510              rithm.  If you do not explicitely give the compression  level  L
2511              (ranging  from  1  to  22),  it will use level 3.  Archives com‐
2512              pressed with zstd are not compatible with borg < 1.1.4.
2513
2514       zlib[,L]
2515              Use zlib ("gz") compression. Medium speed,  medium  compression.
2516              If  you do not explicitely give the compression level L (ranging
2517              from 0 to 9), it will use level 6.  Giving level  0  (means  "no
2518              compression",  but  still has zlib protocol overhead) is usually
2519              pointless, you better use "none" compression.
2520
2521       lzma[,L]
2522              Use lzma ("xz") compression. Low speed,  high  compression.   If
2523              you  do  not  explicitely  give the compression level L (ranging
2524              from 0 to 9), it will use level 6.  Giving  levels  above  6  is
2525              pointless  and  counterproductive  because  it does not compress
2526              better due to the buffer size used by borg - but it wastes  lots
2527              of CPU cycles and RAM.
2528
2529       auto,C[,L]
2530              Use a built-in heuristic to decide per chunk whether to compress
2531              or not.  The heuristic tries with lz4 whether the data  is  com‐
2532              pressible.  For incompressible data, it will not use compression
2533              (uses "none").  For compressible data, it uses the  given  C[,L]
2534              compression - with C[,L] being any valid compression specifier.
2535
2536       Examples:
2537
2538          borg create --compression lz4 REPO::ARCHIVE data
2539          borg create --compression zstd REPO::ARCHIVE data
2540          borg create --compression zstd,10 REPO::ARCHIVE data
2541          borg create --compression zlib REPO::ARCHIVE data
2542          borg create --compression zlib,1 REPO::ARCHIVE data
2543          borg create --compression auto,lzma,6 REPO::ARCHIVE data
2544          borg create --compression auto,lzma ...
2545

DEBUGGING FACILITIES

2547       There  is  a borg debug command that has some subcommands which are all
2548       not intended for normal use and  potentially  very  dangerous  if  used
2549       incorrectly.
2550
2551       For  example, borg debug put-obj and borg debug delete-obj will only do
2552       what their name suggests: put objects into repo / delete  objects  from
2553       repo.
2554
2555       Please note:
2556
2557       · they will not update the chunks cache (chunks index) about the object
2558
2559       · they  will  not  update  the  manifest  (so no automatic chunks index
2560         resync is triggered)
2561
2562       · they will not check  whether  the  object  is  in  use  (e.g.  before
2563         delete-obj)
2564
2565       · they will not update any metadata which may point to the object
2566
2567       They  exist  to  improve  debugging  capabilities without direct system
2568       access, e.g.  in case you ever run into some  severe  malfunction.  Use
2569       them only if you know what you are doing or if a trusted Borg developer
2570       tells you what to do.
2571
2572       Borg has a --debug-topic TOPIC option to enable specific debugging mes‐
2573       sages. Topics are generally not documented.
2574
2575       A --debug-profile FILE option exists which writes a profile of the main
2576       program's execution to a  file.  The  format  of  these  files  is  not
2577       directly  compatible  with  the Python profiling tools, since these use
2578       the "marshal" format, which is not intended to be secure  (quoting  the
2579       Python  docs: "Never unmarshal data received from an untrusted or unau‐
2580       thenticated source.").
2581
2582       The borg debug profile-convert command can be used to take a Borg  pro‐
2583       file  and  convert  it  to  a  profile file that is compatible with the
2584       Python tools.
2585
2586       Additionally, if the filename specified for --debug-profile  ends  with
2587       ".pyprof"  a  Python  compatible  profile  is  generated.  This is only
2588       intended for local use by developers.
2589

ADDITIONAL NOTES

2591       Here are misc. notes about topics that are maybe not covered in  enough
2592       detail in the usage section.
2593
2594   --chunker-params
2595       The  chunker  params  influence  how  input  files  are cut into pieces
2596       (chunks) which are then considered for deduplication. They also have  a
2597       big  impact  on  resource  usage  (RAM and disk space) as the amount of
2598       resources needed is (also) determined by the total amount of chunks  in
2599       the repository (see cache-memory-usage for details).
2600
2601       --chunker-params=10,23,16,4095 results in a fine-grained deduplication|
2602       and creates a big amount of chunks and thus uses a lot of resources  to
2603       manage  them. This is good for relatively small data volumes and if the
2604       machine has a good amount of free RAM and disk space.
2605
2606       --chunker-params=19,23,21,4095 (default) results  in  a  coarse-grained
2607       deduplication and creates a much smaller amount of chunks and thus uses
2608       less resources. This is good for relatively big data volumes and if the
2609       machine has a relatively low amount of free RAM and disk space.
2610
2611       If  you  already  have  made some archives in a repository and you then
2612       change chunker params, this of  course  impacts  deduplication  as  the
2613       chunks will be cut differently.
2614
2615       In  the worst case (all files are big and were touched in between back‐
2616       ups), this will store all content into the repository again.
2617
2618       Usually, it is not that bad though:
2619
2620       · usually most files are not touched, so it will just  re-use  the  old
2621         chunks it already has in the repo
2622
2623       · files smaller than the (both old and new) minimum chunksize result in
2624         only one chunk anyway, so the resulting chunks are same and  dedupli‐
2625         cation will apply
2626
2627       If  you  switch  chunker  params to save resources for an existing repo
2628       that already has some backup  archives,  you  will  see  an  increasing
2629       effect over time, when more and more files have been touched and stored
2630       again using the bigger chunksize and  all  references  to  the  smaller
2631       older chunks have been removed (by deleting / pruning archives).
2632
2633       If  you want to see an immediate big effect on resource usage, you bet‐
2634       ter start a new repository when changing chunker params.
2635
2636       For more details, see chunker_details.
2637
2638   --noatime / --noctime
2639       You can use these borg create options to not store the respective time‐
2640       stamp into the archive, in case you do not really need it.
2641
2642       Besides  saving a little space for the not archived timestamp, it might
2643       also affect metadata  stream  deduplication:  if  only  this  timestamp
2644       changes  between  backups  and  is stored into the metadata stream, the
2645       metadata stream chunks won't deduplicate just because of that.
2646
2647   --nobsdflags
2648       You can use this to not query and store (or not extract and  set)  bsd‐
2649       flags  -  in case you don't need them or if they are broken somehow for
2650       your fs.
2651
2652       On Linux, dealing with the  bsflags  needs  some  additional  syscalls.
2653       Especially when dealing with lots of small files, this causes a notica‐
2654       ble overhead, so you can use this option also for  speeding  up  opera‐
2655       tions.
2656
2657   --umask
2658       If  you  use --umask, make sure that all repository-modifying borg com‐
2659       mands (create, delete, prune) that access the  repository  in  question
2660       use the same --umask value.
2661
2662       If  multiple machines access the same repository, this should hold true
2663       for all of them.
2664
2665   --read-special
2666       The --read-special option is special - you do not want to  use  it  for
2667       normal full-filesystem backups, but rather after carefully picking some
2668       targets for it.
2669
2670       The option --read-special triggers special treatment for block and char
2671       device files as well as FIFOs. Instead of storing them as such a device
2672       (or FIFO), they will get opened, their content will be read and in  the
2673       backup archive they will show up like a regular file.
2674
2675       Symlinks will also get special treatment if (and only if) they point to
2676       such a special file: instead of storing them as a symlink,  the  target
2677       special file will get processed as described above.
2678
2679       One intended use case of this is backing up the contents of one or mul‐
2680       tiple block devices, like e.g. LVM snapshots or inactive  LVs  or  disk
2681       partitions.
2682
2683       You  need  to  be careful about what you include when using --read-spe‐
2684       cial, e.g. if you include /dev/zero, your backup will never terminate.
2685
2686       Restoring such files' content is currently only supported one at a time
2687       via  --stdout  option (and you have to redirect stdout to where ever it
2688       shall go, maybe directly into an existing device file of your choice or
2689       indirectly via dd).
2690
2691       To  some  extent, mounting a backup archive with the backups of special
2692       files via borg mount and then loop-mounting the image files from inside
2693       the  mount  point  will  work.  If  you plan to access a lot of data in
2694       there, it likely will scale and perform better if you do not  work  via
2695       the FUSE mount.
2696
2697   Example
2698       Imagine  you have made some snapshots of logical volumes (LVs) you want
2699       to backup.
2700
2701       NOTE:
2702          For some scenarios, this is a good method to get  "crash-like"  con‐
2703          sistency  (I  call it crash-like because it is the same as you would
2704          get if you just hit the reset button or your machine would  abrubtly
2705          and  completely  crash).   This is better than no consistency at all
2706          and a good method for some use cases, but likely not good enough  if
2707          you have databases running.
2708
2709       Then  you  create  a  backup archive of all these snapshots. The backup
2710       process will see a "frozen" state of the  logical  volumes,  while  the
2711       processes  working  in  the original volumes continue changing the data
2712       stored there.
2713
2714       You also add the output of lvdisplay to your backup, so you can see the
2715       LV sizes in case you ever need to recreate and restore them.
2716
2717       After the backup has completed, you remove the snapshots again.
2718
2719          $ # create snapshots here
2720          $ lvdisplay > lvdisplay.txt
2721          $ borg create --read-special /path/to/repo::arch lvdisplay.txt /dev/vg0/*-snapshot
2722          $ # remove snapshots here
2723
2724       Now, let's see how to restore some LVs from such a backup.
2725
2726          $ borg extract /path/to/repo::arch lvdisplay.txt
2727          $ # create empty LVs with correct sizes here (look into lvdisplay.txt).
2728          $ # we assume that you created an empty root and home LV and overwrite it now:
2729          $ borg extract --stdout /path/to/repo::arch dev/vg0/root-snapshot > /dev/vg0/root
2730          $ borg extract --stdout /path/to/repo::arch dev/vg0/home-snapshot > /dev/vg0/home
2731
2732   Append-only mode
2733       A  repository  can  be  made  "append-only", which means that Borg will
2734       never overwrite or delete committed data  (append-only  refers  to  the
2735       segment  files, but borg will also reject to delete the repository com‐
2736       pletely). This is useful for scenarios where a  backup  client  machine
2737       backups  remotely  to  a backup server using borg serve, since a hacked
2738       client machine cannot delete backups on the server permanently.
2739
2740       To activate append-only mode, set append_only to 1  in  the  repository
2741       config:
2742
2743          borg config /path/to/repo append_only 1
2744
2745       Note  that  you  can  go  back-and-forth between normal and append-only
2746       operation with borg config; it's not a "one way trip."
2747
2748       In append-only mode Borg will create a transaction log in the  transac‐
2749       tions file, where each line is a transaction and a UTC timestamp.
2750
2751       In  addition,  borg  serve can act as if a repository is in append-only
2752       mode with its  option  --append-only.  This  can  be  very  useful  for
2753       fine-tuning access control in .ssh/authorized_keys
2754
2755          command="borg serve --append-only ..." ssh-rsa <key used for not-always-trustable backup clients>
2756          command="borg serve ..." ssh-rsa <key used for backup management>
2757
2758       Running borg init via a borg serve --append-only server will not create
2759       an append-only repository. Running borg init --append-only  creates  an
2760       append-only repository regardless of server settings.
2761
2762   Example
2763       Suppose  an  attacker remotely deleted all backups, but your repository
2764       was in append-only mode. A transaction log in this situation might look
2765       like this:
2766
2767          transaction 1, UTC time 2016-03-31T15:53:27.383532
2768          transaction 5, UTC time 2016-03-31T15:53:52.588922
2769          transaction 11, UTC time 2016-03-31T15:54:23.887256
2770          transaction 12, UTC time 2016-03-31T15:55:54.022540
2771          transaction 13, UTC time 2016-03-31T15:55:55.472564
2772
2773       From  your  security  logs  you  conclude the attacker gained access at
2774       15:54:00 and all the backups where deleted or replaced  by  compromised
2775       backups.  From the log you know that transactions 11 and later are com‐
2776       promised. Note that the transaction ID is the name of the last file  in
2777       the transaction. For example, transaction 11 spans files 6 to 11.
2778
2779       In  a real attack you'll likely want to keep the compromised repository
2780       intact to analyze what the attacker tried to achieve. It's also a  good
2781       idea  to  make  this  copy just in case something goes wrong during the
2782       recovery. Since recovery is done by deleting some files,  a  hard  link
2783       copy (cp -al) is sufficient.
2784
2785       The  first  step  to  reset  the  repository to transaction 5, the last
2786       uncompromised transaction, is to remove the hints.N, index.N and
2787       ``
2788       integrity.N``files in the repository (these files  are  always  expend‐
2789       able). In this example N is 13.
2790
2791       Then  remove  or move all segment files from the segment directories in
2792       data/ starting with file 6:
2793
2794          rm data/**/{6..13}
2795
2796       That's all to do in the repository.
2797
2798       If you want to access this rollbacked repository  from  a  client  that
2799       already has a cache for this repository, the cache will reflect a newer
2800       repository state than what you actually have  in  the  repository  now,
2801       after the rollback.
2802
2803       Thus, you need to clear the cache:
2804
2805          borg delete --cache-only repo
2806
2807       The  cache  will  get rebuilt automatically. Depending on repo size and
2808       archive count, it may take a while.
2809
2810       You  also  will  need  to  remove  ~/.config/borg/security/REPOID/mani‐
2811       fest-timestamp.
2812
2813   Drawbacks
2814       As  data  is only appended, and nothing removed, commands like prune or
2815       delete won't free disk space, they merely tag data as deleted in a  new
2816       transaction.
2817
2818       Be  aware that as soon as you write to the repo in non-append-only mode
2819       (e.g. prune, delete or create archives from an admin machine), it  will
2820       remove  the  deleted  objects permanently (including the ones that were
2821       already marked as deleted, but not removed, in append-only mode). Auto‐
2822       mated  edits  to the repository (such as a cron job running borg prune)
2823       will render append-only mode moot if data is deleted.
2824
2825       Even if an archive appears to be available, it is possible an  attacker
2826       could delete just a few chunks from an archive and silently corrupt its
2827       data. While in append-only mode, this is  reversible,  but  borg  check
2828       should  be  run  before  a  writing/pruning operation on an append-only
2829       repository to catch accidental or malicious corruption:
2830
2831          # run without append-only mode
2832          borg check --verify-data repo && borg compact repo
2833
2834       Aside from checking repository & archive integrity you may want to also
2835       manually check backups to ensure their content seems correct.
2836
2837   Further considerations
2838       Append-only  mode  is  not respected by tools other than Borg. rm still
2839       works on the repository. Make sure that backup client machines only get
2840       to access the repository via borg serve.
2841
2842       Ensure that no remote access is possible if the repository is temporar‐
2843       ily set to normal mode for e.g. regular pruning.
2844
2845       Further protections can be  implemented,  but  are  outside  of  Borg's
2846       scope. For example, file system snapshots or wrapping borg serve to set
2847       special permissions or ACLs on new data files.
2848
2849   SSH batch mode
2850       When running Borg using an automated script, ssh might still ask for  a
2851       password,  even  if there is an SSH key for the target server. Use this
2852       to make scripts more robust:
2853
2854          export BORG_RSH='ssh -oBatchMode=yes'
2855

AUTHOR

2857       The Borg Collective (see AUTHORS file)
2858
2860       2010-2019 Jonas Borgström, 2015-2019 The Borg Collective  (see  AUTHORS
2861       file)
2862
2863
2864
2865
28661.1.10                            2019-07-24                           BORG(1)
Impressum