create.rst 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .. include:: create.rst.inc
  2. Examples
  3. ~~~~~~~~
  4. ::
  5. # Backup ~/Documents into an archive named "my-documents"
  6. $ borg create /path/to/repo::my-documents ~/Documents
  7. # same, but list all files as we process them
  8. $ borg create --list /path/to/repo::my-documents ~/Documents
  9. # Backup ~/Documents and ~/src but exclude pyc files
  10. $ borg create /path/to/repo::my-files \
  11. ~/Documents \
  12. ~/src \
  13. --exclude '*.pyc'
  14. # Backup home directories excluding image thumbnails (i.e. only
  15. # /home/*/.thumbnails is excluded, not /home/*/*/.thumbnails)
  16. $ borg create /path/to/repo::my-files /home \
  17. --exclude 're:^/home/[^/]+/\.thumbnails/'
  18. # Do the same using a shell-style pattern
  19. $ borg create /path/to/repo::my-files /home \
  20. --exclude 'sh:/home/*/.thumbnails'
  21. # Backup the root filesystem into an archive named "root-YYYY-MM-DD"
  22. # use zlib compression (good, but slow) - default is lz4 (fast, low compression ratio)
  23. $ borg create -C zlib,6 /path/to/repo::root-{now:%Y-%m-%d} / --one-file-system
  24. # Backup a remote host locally ("pull" style) using sshfs
  25. $ mkdir sshfs-mount
  26. $ sshfs root@example.com:/ sshfs-mount
  27. $ cd sshfs-mount
  28. $ borg create /path/to/repo::example.com-root-{now:%Y-%m-%d} .
  29. $ cd ..
  30. $ fusermount -u sshfs-mount
  31. # Make a big effort in fine granular deduplication (big chunk management
  32. # overhead, needs a lot of RAM and disk space, see formula in internals
  33. # docs - same parameters as borg < 1.0 or attic):
  34. $ borg create --chunker-params 10,23,16,4095 /path/to/repo::small /smallstuff
  35. # Backup a raw device (must not be active/in use/mounted at that time)
  36. $ dd if=/dev/sdx bs=10M | borg create /path/to/repo::my-sdx -
  37. # No compression (default)
  38. $ borg create /path/to/repo::arch ~
  39. # Super fast, low compression
  40. $ borg create --compression lz4 /path/to/repo::arch ~
  41. # Less fast, higher compression (N = 0..9)
  42. $ borg create --compression zlib,N /path/to/repo::arch ~
  43. # Even slower, even higher compression (N = 0..9)
  44. $ borg create --compression lzma,N /path/to/repo::arch ~
  45. # Use short hostname, user name and current time in archive name
  46. $ borg create /path/to/repo::{hostname}-{user}-{now} ~
  47. # Similar, use the same datetime format as borg 1.1 will have as default
  48. $ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S} ~
  49. # As above, but add nanoseconds
  50. $ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S.%f} ~
  51. # Backing up relative paths by moving into the correct directory first
  52. $ cd /home/user/Documents
  53. # The root directory of the archive will be "projectA"
  54. $ borg create /path/to/repo::daily-projectA-{now:%Y-%m-%d} projectA