usage.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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/verify.rst.inc
  62. This command is similar to :ref:`attic_extract` but instead of writing any
  63. files to disk the command just verifies that all files are extractable and
  64. not corrupt. |project_name| will not compare the the archived files with the
  65. files on disk.
  66. .. include:: usage/check.rst.inc
  67. The check command verifies the consistency of a repository. Any inconsistencies
  68. found are reported to the standard error stream and the command will have a
  69. non zero exit code.
  70. .. include:: usage/delete.rst.inc
  71. This command deletes an archive from the repository. Any disk space not
  72. shared with any other existing archive is also reclaimed.
  73. .. include:: usage/list.rst.inc
  74. This command lists the contents of a repository or an archive.
  75. Examples
  76. ~~~~~~~~
  77. ::
  78. $ attic list /data/myrepo
  79. my-files Thu Aug 1 23:33:22 2013
  80. my-documents Thu Aug 1 23:35:43 2013
  81. root-2013-08-01 Thu Aug 1 23:43:55 2013
  82. root-2013-08-02 Fri Aug 2 15:18:17 2013
  83. ...
  84. $ attic list /data/myrepo::root-2013-08-02
  85. drwxr-xr-x root root 0 Jun 05 12:06 .
  86. lrwxrwxrwx root root 0 May 31 20:40 bin -> usr/bin
  87. drwxr-xr-x root root 0 Aug 01 22:08 etc
  88. drwxr-xr-x root root 0 Jul 15 22:07 etc/ImageMagick-6
  89. -rw-r--r-- root root 1383 May 22 22:25 etc/ImageMagick-6/colors.xml
  90. ...
  91. .. include:: usage/prune.rst.inc
  92. The ``prune`` command prunes a repository by deleting archives not matching
  93. any of the specified retention options. This command is normally
  94. used by automated backup scripts wanting to keep a certain number of historic
  95. backups.
  96. Examples
  97. ~~~~~~~~
  98. ::
  99. # Keep 7 end of day and 4 additional end of week archives
  100. $ attic prune /data/myrepo --daily=7 --weekly=4
  101. # Same as above but only apply to archive names starting with "foo"
  102. $ attic prune /data/myrepo --daily=7 --weekly=4 --prefix=foo
  103. # Keep 7 end of day, 4 additional end of week archives, and an
  104. # end of month archive for every month:
  105. $ attic prune /data/myrepo --daily=7 --weekly=4 --monthly=-1
  106. .. include:: usage/info.rst.inc
  107. This command displays some detailed information about the specified archive.
  108. Examples
  109. ~~~~~~~~
  110. ::
  111. $ attic info /data/myrepo::root-2013-08-02
  112. Name: root-2013-08-02
  113. Fingerprint: bc3902e2c79b6d25f5d769b335c5c49331e6537f324d8d3badcb9a0917536dbb
  114. Hostname: myhostname
  115. Username: root
  116. Time: Fri Aug 2 15:18:17 2013
  117. Command line: /usr/bin/attic create --stats /data/myrepo::root-2013-08-02 / --do-not-cross-mountpoints
  118. Number of files: 147429
  119. Original size: 5344169493 (4.98 GB)
  120. Compressed size: 1748189642 (1.63 GB)
  121. Unique data: 64805454 (61.80 MB)
  122. .. include:: usage/mount.rst.inc
  123. This command mounts an archive as a FUSE filesystem. This can be useful for
  124. browsing an archive or restoring individual files. Unless the ``--foreground``
  125. option is given the command will run in the background until the filesystem
  126. is ``umounted``.
  127. Examples
  128. ~~~~~~~~
  129. ::
  130. $ attic mount /data/myrepo::root-2013-08-02 /tmp/mymountpoint
  131. $ ls /tmp/mymountpoint
  132. bin boot etc lib lib64 mnt opt root sbin srv usr var
  133. $ fusermount -u /tmp/mymountpoint
  134. .. include:: usage/change-passphrase.rst.inc
  135. The key files used for repository encryption are optionally passphrase
  136. protected. This command can be used to change this passphrase.
  137. Examples
  138. ~~~~~~~~
  139. ::
  140. # Create a key file protected repository
  141. $ attic init --key-file /tmp/encrypted-repo
  142. Initializing repository at "/tmp/encrypted-repo"
  143. Enter passphrase (empty for no passphrase):
  144. Enter same passphrase again:
  145. Key file "/home/USER/.attic/keys/tmp_encrypted_repo" created.
  146. Keep this file safe. Your data will be inaccessible without it.
  147. # Change key file passphrase
  148. $ attic change-passphrase /tmp/encrypted-repo
  149. Enter passphrase for key file /home/USER/.attic/keys/tmp_encrypted_repo:
  150. New passphrase:
  151. Enter same passphrase again:
  152. Key file "/home/USER/.attic/keys/tmp_encrypted_repo" updated