create.rst 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. .. include:: create.rst.inc
  2. Examples
  3. ~~~~~~~~
  4. ::
  5. # Back up ~/Documents into an archive named "my-documents"
  6. $ borg create my-documents ~/Documents
  7. # same, but list all files as we process them
  8. $ borg create --list my-documents ~/Documents
  9. # Back up ~/Documents and ~/src but exclude pyc files
  10. $ borg create my-files \
  11. ~/Documents \
  12. ~/src \
  13. --exclude '*.pyc'
  14. # Back up home directories excluding image thumbnails (i.e. only
  15. # /home/<one directory>/.thumbnails is excluded, not /home/*/*/.thumbnails etc.)
  16. $ borg create my-files /home --exclude 'sh:home/*/.thumbnails'
  17. # Back up 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 --one-file-system root-{now:%Y-%m-%d} /
  20. # Back up into an archive name like FQDN-root-TIMESTAMP
  21. $ borg create '{fqdn}-root-{now}' /
  22. # Back up a remote host locally ("pull" style) using sshfs
  23. $ mkdir sshfs-mount
  24. $ sshfs root@example.com:/ sshfs-mount
  25. $ cd sshfs-mount
  26. $ borg create example.com-root-{now:%Y-%m-%d} .
  27. $ cd ..
  28. $ fusermount -u sshfs-mount
  29. # Make a big effort in fine granular deduplication (big chunk management
  30. # overhead, needs a lot of RAM and disk space, see formula in internals
  31. # docs - same parameters as borg < 1.0):
  32. $ borg create --chunker-params buzhash,10,23,16,4095 small /smallstuff
  33. # Back up a raw device (must not be active/in use/mounted at that time)
  34. $ borg create --read-special --chunker-params fixed,4194304 my-sdx /dev/sdX
  35. # Back up a sparse disk image (must not be active/in use/mounted at that time)
  36. $ borg create --sparse --chunker-params fixed,4194304 my-disk my-disk.raw
  37. # No compression (none)
  38. $ borg create --compression none arch ~
  39. # Super fast, low compression (lz4, default)
  40. $ borg create arch ~
  41. # Less fast, higher compression (zlib, N = 0..9)
  42. $ borg create --compression zlib,N arch ~
  43. # Even slower, even higher compression (lzma, N = 0..9)
  44. $ borg create --compression lzma,N arch ~
  45. # Only compress compressible data with lzma,N (N = 0..9)
  46. $ borg create --compression auto,lzma,N arch ~
  47. # Use short hostname, user name and current time in archive name
  48. $ borg create '{hostname}-{user}-{now}' ~
  49. # Similar, use the same datetime format that is default as of borg 1.1
  50. $ borg create '{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S}' ~
  51. # As above, but add nanoseconds
  52. $ borg create '{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S.%f}' ~
  53. # Backing up relative paths by moving into the correct directory first
  54. $ cd /home/user/Documents
  55. # The root directory of the archive will be "projectA"
  56. $ borg create 'daily-projectA-{now:%Y-%m-%d}' projectA
  57. # Use external command to determine files to archive
  58. # Use --paths-from-stdin with find to back up only files less than 1MB in size
  59. $ find ~ -size -1000k | borg create --paths-from-stdin small-files-only
  60. # Use --paths-from-command with find to back up files only from a given user
  61. $ borg create --paths-from-command joes-files -- find /srv/samba/shared -user joe
  62. # Use --paths-from-stdin with --paths-delimiter (for example, for filenames with newlines in them)
  63. $ find ~ -size -1000k -print0 | borg create \
  64. --paths-from-stdin \
  65. --paths-delimiter "\0" \
  66. smallfiles-handle-newline