2
0

create.rst 2.8 KB

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