create.rst 2.5 KB

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