usage.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. This command initializes an empty :ref:`repository <repository_def>`.
  15. A repository is a filesystem directory
  16. containing the deduplicated data from zero or more archives.
  17. Encryption is enabled at repository initialization time.
  18. Examples
  19. ~~~~~~~~
  20. ::
  21. # Local backup repository
  22. $ attic init /data/mybackuprepo.attic
  23. # Remote backup repository
  24. $ attic init user@hostname:mybackuprepo.attic
  25. # Encrypted remote backup repository
  26. $ attic init --encryption=passphrase user@hostname:mybackuprepo.attic
  27. .. include:: usage/create.rst.inc
  28. This command creates a backup archive containing all files found while
  29. recursively traversing all paths specified. The archive will consume almost
  30. no disk space for files or parts of files that have already been stored in
  31. other archives.
  32. Examples
  33. ~~~~~~~~
  34. ::
  35. # Backup ~/Documents into an archive named "my-documents"
  36. $ attic create /data/myrepo.attic::my-documents ~/Documents
  37. # Backup ~/Documents and ~/src but exclude pyc files
  38. $ attic create /data/myrepo.attic::my-files \
  39. ~/Documents \
  40. ~/src \
  41. --exclude '*.pyc'
  42. # Backup the root filesystem into an archive named "root-YYYY-MM-DD"
  43. NAME="root-`date +%Y-%m-%d`"
  44. $ attic create /data/myrepo.attic::$NAME / --do-not-cross-mountpoints
  45. .. include:: usage/extract.rst.inc
  46. This command extracts the contents of an archive. By default the entire
  47. archive is extracted but a subset of files and directories can be selected
  48. by passing a list of ``PATHs`` as arguments. The file selection can further
  49. be restricted by using the ``--exclude`` option.
  50. Examples
  51. ~~~~~~~~
  52. ::
  53. # Extract entire archive
  54. $ attic extract /data/myrepo::my-files
  55. # Extract entire archive and list files while processing
  56. $ attic extract -v /data/myrepo::my-files
  57. # Extract the "src" directory
  58. $ attic extract /data/myrepo::my-files home/USERNAME/src
  59. # Extract the "src" directory but exclude object files
  60. $ attic extract /data/myrepo::my-files home/USERNAME/src --exclude '*.o'
  61. .. include:: usage/check.rst.inc
  62. The check command verifies the consistency of a repository. Any inconsistencies
  63. found are reported to the standard error stream and the command will have a
  64. non zero exit code.
  65. .. include:: usage/delete.rst.inc
  66. This command deletes an archive from the repository. Any disk space not
  67. shared with any other existing archive is also reclaimed.
  68. .. include:: usage/list.rst.inc
  69. This command lists the contents of a repository or an archive.
  70. Examples
  71. ~~~~~~~~
  72. ::
  73. $ attic list /data/myrepo
  74. my-files Thu Aug 1 23:33:22 2013
  75. my-documents Thu Aug 1 23:35:43 2013
  76. root-2013-08-01 Thu Aug 1 23:43:55 2013
  77. root-2013-08-02 Fri Aug 2 15:18:17 2013
  78. ...
  79. $ attic list /data/myrepo::root-2013-08-02
  80. drwxr-xr-x root root 0 Jun 05 12:06 .
  81. lrwxrwxrwx root root 0 May 31 20:40 bin -> usr/bin
  82. drwxr-xr-x root root 0 Aug 01 22:08 etc
  83. drwxr-xr-x root root 0 Jul 15 22:07 etc/ImageMagick-6
  84. -rw-r--r-- root root 1383 May 22 22:25 etc/ImageMagick-6/colors.xml
  85. ...
  86. .. include:: usage/prune.rst.inc
  87. The ``prune`` command prunes a repository by deleting archives not matching
  88. any of the specified retention options. This command is normally
  89. used by automated backup scripts wanting to keep a certain number of historic
  90. backups.
  91. Examples
  92. ~~~~~~~~
  93. ::
  94. # Keep 7 end of day and 4 additional end of week archives:
  95. $ attic prune /data/myrepo --keep-daily=7 --keep-weekly=4
  96. # Same as above but only apply to archive names starting with "foo":
  97. $ attic prune /data/myrepo --keep-daily=7 --keep-weekly=4 --prefix=foo
  98. # Keep 7 end of day, 4 additional end of week archives,
  99. # and an end of month archive for every month:
  100. $ attic prune /data/myrepo --keep-daily=7 --keep-weekly=4 --monthly=-1
  101. # Keep all backups in the last 10 days, 4 additional end of week archives,
  102. # and an end of month archive for every month:
  103. $ attic prune /data/myrepo --keep-within=10d --keep-weekly=4 --monthly=-1
  104. .. include:: usage/info.rst.inc
  105. This command displays some detailed information about the specified archive.
  106. Examples
  107. ~~~~~~~~
  108. ::
  109. $ attic info /data/myrepo::root-2013-08-02
  110. Name: root-2013-08-02
  111. Fingerprint: bc3902e2c79b6d25f5d769b335c5c49331e6537f324d8d3badcb9a0917536dbb
  112. Hostname: myhostname
  113. Username: root
  114. Time: Fri Aug 2 15:18:17 2013
  115. Command line: /usr/bin/attic create --stats /data/myrepo::root-2013-08-02 / --do-not-cross-mountpoints
  116. Number of files: 147429
  117. Original size: 5344169493 (4.98 GB)
  118. Compressed size: 1748189642 (1.63 GB)
  119. Unique data: 64805454 (61.80 MB)
  120. .. include:: usage/mount.rst.inc
  121. This command mounts an archive as a FUSE filesystem. This can be useful for
  122. browsing an archive or restoring individual files. Unless the ``--foreground``
  123. option is given the command will run in the background until the filesystem
  124. is ``umounted``.
  125. Examples
  126. ~~~~~~~~
  127. ::
  128. $ attic mount /data/myrepo::root-2013-08-02 /tmp/mymountpoint
  129. $ ls /tmp/mymountpoint
  130. bin boot etc lib lib64 mnt opt root sbin srv usr var
  131. $ fusermount -u /tmp/mymountpoint
  132. .. include:: usage/change-passphrase.rst.inc
  133. The key files used for repository encryption are optionally passphrase
  134. protected. This command can be used to change this passphrase.
  135. Examples
  136. ~~~~~~~~
  137. ::
  138. # Create a key file protected repository
  139. $ attic init --key-file /tmp/encrypted-repo
  140. Initializing repository at "/tmp/encrypted-repo"
  141. Enter passphrase (empty for no passphrase):
  142. Enter same passphrase again:
  143. Key file "/home/USER/.attic/keys/tmp_encrypted_repo" created.
  144. Keep this file safe. Your data will be inaccessible without it.
  145. # Change key file passphrase
  146. $ attic change-passphrase /tmp/encrypted-repo
  147. Enter passphrase for key file /home/USER/.attic/keys/tmp_encrypted_repo:
  148. New passphrase:
  149. Enter same passphrase again:
  150. Key file "/home/USER/.attic/keys/tmp_encrypted_repo" updated