quickstart.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. .. include:: global.rst.inc
  2. .. _quickstart:
  3. Quick Start
  4. ===========
  5. This chapter will get you started with |project_name|. The first section
  6. presents a simple step by step example that uses |project_name| to backup data.
  7. The next section continues by showing how backups can be automated.
  8. A step by step example
  9. ----------------------
  10. 1. Before a backup can be made a repository has to be initialized::
  11. $ attic init /somewhere/my-repository.attic
  12. 2. Backup the ``~/src`` and ``~/Documents`` directories into an archive called
  13. *Monday*::
  14. $ attic create /somwhere/my-repository.attic::Monday ~/src ~/Documents
  15. 3. The next day create a new archive called *Tuesday*::
  16. $ attic create --stats /somwhere/my-repository.attic::Tuesday ~/src ~/Documents
  17. This backup will be a lot quicker and a lot smaller since only new never
  18. before seen data is stored. The ``--stats`` option causes |project_name| to
  19. output statistics about the newly created archive such as the amount of unique
  20. data (not shared with other archives)::
  21. Archive name: Tuesday
  22. Archive fingerprint: 387a5e3f9b0e792e91ce87134b0f4bfe17677d9248cb5337f3fbf3a8e157942a
  23. Start time: Tue Mar 25 12:00:10 2014
  24. End time: Tue Mar 25 12:00:10 2014
  25. Duration: 0.08 seconds
  26. Number of files: 358
  27. Original size Compressed size Deduplicated size
  28. This archive: 57.16 MB 46.78 MB 151.67 kB
  29. All archives: 114.02 MB 93.46 MB 44.81 MB
  30. 4. List all archives in the repository::
  31. $ attic list /somewhere/my-repository.attic
  32. Monday Mon Mar 24 11:59:35 2014
  33. Tuesday Tue Mar 25 12:00:10 2014
  34. 5. List the contents of the *Monday* archive::
  35. $ attic list /somewhere/my-repository.attic::Monday
  36. drwxr-xr-x user group 0 Jan 06 15:22 home/user/Documents
  37. -rw-r--r-- user group 7961 Nov 17 2012 home/user/Documents/Important.doc
  38. ...
  39. 6. Restore the *Monday* archive::
  40. $ attic extract /somwhere/my-repository.attic::Monday
  41. 7. Recover disk space by manually deleting the *Monday* archive::
  42. $ attic delete /somwhere/my-backup.attic::Monday
  43. .. Note::
  44. Attic is quiet by default. Add the ``-v`` or ``--verbose`` option to
  45. get progress reporting during command execution.
  46. Automating backups
  47. ------------------
  48. The following example script backs up ``/home`` and
  49. ``/var/www`` to a remote server. The script also uses the
  50. :ref:`attic_prune` subcommand to maintain a certain number
  51. of old archives::
  52. #!/bin/sh
  53. REPOSITORY=username@remoteserver.com:repository.attic
  54. # Backup all of /home and /var/www except a few
  55. # excluded directories
  56. attic create --stats \
  57. $REPOSITORY::hostname-`date +%Y-%m-%d` \
  58. /home \
  59. /var/www \
  60. --exclude /home/*/.cache \
  61. --exclude /home/Ben/Music/Justin\ Bieber \
  62. --exclude '*.pyc'
  63. # Use the `prune` subcommand to maintain 7 daily, 4 weekly
  64. # and 6 monthly archives.
  65. attic prune -v $REPOSITORY --keep-daily=7 --keep-weekly=4 --keep-monthly=6
  66. .. _encrypted_repos:
  67. Repository encryption
  68. ---------------------
  69. Repository encryption is enabled at repository creation time::
  70. $ attic init --encryption=passphrase|keyfile PATH
  71. When repository encryption is enabled all data is encrypted using 256-bit AES_
  72. encryption and the integrity and authenticity is verified using `HMAC-SHA256`_.
  73. All data is encrypted before being written to the repository. This means that
  74. an attacker that manages to compromise the host containing an encrypted
  75. archive will not be able to access any of the data.
  76. |project_name| supports two different methods to derive the AES and HMAC keys.
  77. Passphrase based encryption
  78. This method uses a user supplied passphrase to derive the keys using the
  79. PBKDF2_ key derivation function. This method is convenient to use since
  80. there is no key file to keep track of and secure as long as a *strong*
  81. passphrase is used.
  82. .. Note::
  83. For automated backups the passphrase can be specified using the
  84. `ATTIC_PASSPHRASE` environment variable.
  85. Key file based encryption
  86. This method generates random keys at repository initialization time that
  87. are stored in a password protected file in the ``~/.attic/keys/`` directory.
  88. The key file is a printable text file. This method is secure and suitable
  89. for automated backups.
  90. .. Note::
  91. The repository data is totally inaccessible without the key file
  92. so it must be kept **safe**.
  93. .. _remote_repos:
  94. Remote repositories
  95. -------------------
  96. |project_name| can initialize and access repositories on remote hosts if the
  97. host is accessible using SSH. This is fastest and easiest when |project_name|
  98. is installed on the remote host, in which case the following syntax is used::
  99. $ attic init user@hostname:repository.attic
  100. or::
  101. $ attic init ssh://user@hostname:port/repository.attic
  102. If it is not possible to install |project_name| on the remote host,
  103. it is still possible to use the remote host to store a repository by
  104. mounting the remote filesystem, for example, using sshfs::
  105. $ sshfs user@hostname:/path/to/folder /tmp/mymountpoint
  106. $ attic init /tmp/mymountpoint/repository.attic
  107. $ fusermount -u /tmp/mymountpoint
  108. However, be aware that sshfs doesn't fully implement POSIX locks, so
  109. you must be sure to not have two processes trying to access the same
  110. repository at the same time.