usage.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. .. include:: global.rst.inc
  2. .. _detailed_usage:
  3. Usage
  4. =====
  5. |project_name| consists of a number of commands. Each command accepts
  6. a number of arguments and options. The following sections will describe each
  7. command in detail.
  8. Quiet by default
  9. ----------------
  10. Like most UNIX commands |project_name| is quiet by default but the ``-v`` or
  11. ``--verbose`` option can be used to get the program to output more status
  12. messages as it is processing.
  13. .. include:: usage/init.rst.inc
  14. Examples
  15. ~~~~~~~~
  16. ::
  17. # Local repository
  18. $ borg init /mnt/backup
  19. # Remote repository (accesses a remote borg via ssh)
  20. $ borg init user@hostname:backup
  21. # Encrypted remote repository
  22. $ borg init --encryption=passphrase user@hostname:backup
  23. .. include:: usage/create.rst.inc
  24. Examples
  25. ~~~~~~~~
  26. ::
  27. # Backup ~/Documents into an archive named "my-documents"
  28. $ borg create /mnt/backup::my-documents ~/Documents
  29. # Backup ~/Documents and ~/src but exclude pyc files
  30. $ borg create /mnt/backup::my-files \
  31. ~/Documents \
  32. ~/src \
  33. --exclude '*.pyc'
  34. # Backup the root filesystem into an archive named "root-YYYY-MM-DD"
  35. NAME="root-`date +%Y-%m-%d`"
  36. $ borg create /mnt/backup::$NAME / --do-not-cross-mountpoints
  37. # Backup huge files with little chunk management overhead
  38. $ borg create --chunker-params 19,23,21,4095 /mnt/backup::VMs /srv/VMs
  39. .. include:: usage/extract.rst.inc
  40. Examples
  41. ~~~~~~~~
  42. ::
  43. # Extract entire archive
  44. $ borg extract /mnt/backup::my-files
  45. # Extract entire archive and list files while processing
  46. $ borg extract -v /mnt/backup::my-files
  47. # Extract the "src" directory
  48. $ borg extract /mnt/backup::my-files home/USERNAME/src
  49. # Extract the "src" directory but exclude object files
  50. $ borg extract /mnt/backup::my-files home/USERNAME/src --exclude '*.o'
  51. .. include:: usage/check.rst.inc
  52. .. include:: usage/delete.rst.inc
  53. .. include:: usage/list.rst.inc
  54. Examples
  55. ~~~~~~~~
  56. ::
  57. $ borg list /mnt/backup
  58. my-files Thu Aug 1 23:33:22 2013
  59. my-documents Thu Aug 1 23:35:43 2013
  60. root-2013-08-01 Thu Aug 1 23:43:55 2013
  61. root-2013-08-02 Fri Aug 2 15:18:17 2013
  62. ...
  63. $ borg list /mnt/backup::root-2013-08-02
  64. drwxr-xr-x root root 0 Jun 05 12:06 .
  65. lrwxrwxrwx root root 0 May 31 20:40 bin -> usr/bin
  66. drwxr-xr-x root root 0 Aug 01 22:08 etc
  67. drwxr-xr-x root root 0 Jul 15 22:07 etc/ImageMagick-6
  68. -rw-r--r-- root root 1383 May 22 22:25 etc/ImageMagick-6/colors.xml
  69. ...
  70. .. include:: usage/prune.rst.inc
  71. Examples
  72. ~~~~~~~~
  73. ::
  74. # Keep 7 end of day and 4 additional end of week archives:
  75. $ borg prune /mnt/backup --keep-daily=7 --keep-weekly=4
  76. # Same as above but only apply to archive names starting with "foo":
  77. $ borg prune /mnt/backup --keep-daily=7 --keep-weekly=4 --prefix=foo
  78. # Keep 7 end of day, 4 additional end of week archives,
  79. # and an end of month archive for every month:
  80. $ borg prune /mnt/backup --keep-daily=7 --keep-weekly=4 --keep-monthly=-1
  81. # Keep all backups in the last 10 days, 4 additional end of week archives,
  82. # and an end of month archive for every month:
  83. $ borg prune /mnt/backup --keep-within=10d --keep-weekly=4 --keep-monthly=-1
  84. .. include:: usage/info.rst.inc
  85. Examples
  86. ~~~~~~~~
  87. ::
  88. $ borg info /mnt/backup::root-2013-08-02
  89. Name: root-2013-08-02
  90. Fingerprint: bc3902e2c79b6d25f5d769b335c5c49331e6537f324d8d3badcb9a0917536dbb
  91. Hostname: myhostname
  92. Username: root
  93. Time: Fri Aug 2 15:18:17 2013
  94. Command line: /usr/bin/borg create --stats /mnt/backup::root-2013-08-02 / --do-not-cross-mountpoints
  95. Number of files: 147429
  96. Original size: 5344169493 (4.98 GB)
  97. Compressed size: 1748189642 (1.63 GB)
  98. Unique data: 64805454 (61.80 MB)
  99. .. include:: usage/mount.rst.inc
  100. Examples
  101. ~~~~~~~~
  102. ::
  103. $ borg mount /mnt/backup::root-2013-08-02 /tmp/mymountpoint
  104. $ ls /tmp/mymountpoint
  105. bin boot etc lib lib64 mnt opt root sbin srv usr var
  106. $ fusermount -u /tmp/mymountpoint
  107. .. include:: usage/change-passphrase.rst.inc
  108. Examples
  109. ~~~~~~~~
  110. ::
  111. # Create a key file protected repository
  112. $ borg init --encryption=keyfile /mnt/backup
  113. Initializing repository at "/mnt/backup"
  114. Enter passphrase (empty for no passphrase):
  115. Enter same passphrase again:
  116. Key file "/home/USER/.borg/keys/mnt_backup" created.
  117. Keep this file safe. Your data will be inaccessible without it.
  118. # Change key file passphrase
  119. $ borg change-passphrase /mnt/backup
  120. Enter passphrase for key file /home/USER/.borg/keys/mnt_backup:
  121. New passphrase:
  122. Enter same passphrase again:
  123. Key file "/home/USER/.borg/keys/mnt_backup" updated
  124. .. include:: usage/serve.rst.inc
  125. Examples
  126. ~~~~~~~~
  127. ::
  128. # Allow an SSH keypair to only run |project_name|, and only have access to /mnt/backup.
  129. # This will help to secure an automated remote backup system.
  130. $ cat ~/.ssh/authorized_keys
  131. command="borg serve --restrict-to-path /mnt/backup" ssh-rsa AAAAB3[...]