quickstart.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 any backup can be taken a repository has to be initialized::
  11. $ attic init /somewhere/my-backup.attic
  12. 2. Backup the ``~/src`` and ``~/Documents`` directories into an archive called
  13. *first-backup*::
  14. $ attic create -v /somwhere/my-backup.attic::first-backup ~/src ~/Documents
  15. 3. The next day create a new archive called *second-backup*::
  16. $ attic create -v --stats /somwhere/my-backup.attic::second-backup ~/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`` causes |project_name| to output
  19. statistics about the newly created archive such as the amount of unique
  20. data (not shared with other archives).
  21. 4. List all archives in the repository::
  22. $ attic list /somewhere/my-backup.attic
  23. 5. List the contents of the *first-backup* archive::
  24. $ attic list /somewhere/my-backup.attic::first-backup
  25. 6. Restore the *first-backup* archive::
  26. $ attic extract -v /somwhere/my-backup.attic::first-backup
  27. 7. Recover disk space by manually deleting the *first-backup* archive::
  28. $ attic delete /somwhere/my-backup.attic::first-backup
  29. Automating backups
  30. ------------------
  31. The following example script backups up ``/home`` and
  32. ``/var/www`` to a remote server. The script also uses the
  33. :ref:`attic_prune` subcommand to maintain a certain number
  34. of old archives::
  35. #!/bin/sh
  36. REPOSITORY=username@remoteserver.com:backup.attic
  37. # Backup all of /home and /var/www except a few
  38. # excluded directories
  39. attic create --stats \
  40. $REPOSITORY::hostname-`date +%Y-%m-%d` \
  41. /home \
  42. /var/www \
  43. --exclude /home/*/.cache \
  44. --exclude /home/Ben/Music/Justin\ Bieber \
  45. --exclude *.pyc
  46. # Use the `prune` subcommand to maintain 7 daily, 4 weekly
  47. # and 6 monthly archives.
  48. attic prune -v $REPOSITORY --daily=7 --weekly=4 --monthly=6
  49. .. Note::
  50. This script assumes the repository has already been initalized with
  51. :ref:`attic_init`.
  52. .. _encrypted_repos:
  53. Repository encryption
  54. ---------------------
  55. Repository encryption is enabled at repository encryption time::
  56. $ attic init --passphrase | --key-file
  57. When repository encryption is enabled all data is encrypted using 256-bit AES_
  58. encryption and the integrity and authenticity is verified using `HMAC-SHA256`_.
  59. |project_name| supports two different methods to derive the AES and HMAC keys.
  60. Passphrase based encryption
  61. This method uses a user supplied passphrase to derive the keys using the
  62. PBKDF2_ key derivation function. This method is convenient to use and
  63. secure as long as a *strong* passphrase is used.
  64. .. Note::
  65. For automated backups the passphrase can be specified using the
  66. `ATTIC_PASSPHRASE` environment variable.
  67. Key file based encryption
  68. This method generates random keys at repository initialization time that
  69. are stored in a password protected file in the ``~/.attic/keys/`` directory.
  70. This method is secure and suitable for automated backups.
  71. .. Note::
  72. The repository data is totally inaccessible without the key file
  73. so it must be kept **safe**.
  74. .. _remote_repos:
  75. Remote repositories
  76. -------------------
  77. |project_name| can initialize and access repositories on remote hosts as the
  78. host is accessible using SSH and |project_name| is installed.
  79. The following syntax is used to address remote repositories::
  80. $ attic init user@hostname:repository.attic
  81. or::
  82. $ attic init ssh://user@hostname:port/repository.attic