create.rst 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .. include:: create.rst.inc
  2. Examples
  3. ~~~~~~~~
  4. ::
  5. # Backup ~/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. # Backup ~/Documents and ~/src but exclude pyc files
  10. $ borg create 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 my-files /home --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 --one-file-system root-{now:%Y-%m-%d} /
  20. # Backup into an archive name like FQDN-root-TIMESTAMP
  21. $ borg create '{fqdn}-root-{now}' /
  22. # Backup 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 docs):
  31. $ borg create --chunker-params buzhash,10,23,16,4095 small /smallstuff
  32. # Backup a raw device (must not be active/in use/mounted at that time)
  33. $ borg create --read-special --chunker-params fixed,4194304 my-sdx /dev/sdX
  34. # Backup a sparse disk image (must not be active/in use/mounted at that time)
  35. $ borg create --sparse --chunker-params fixed,4194304 my-disk my-disk.raw
  36. # No compression (none)
  37. $ borg create --compression none arch ~
  38. # Super fast, low compression (lz4, default)
  39. $ borg create arch ~
  40. # Less fast, higher compression (zlib, N = 0..9)
  41. $ borg create --compression zlib,N arch ~
  42. # Even slower, even higher compression (lzma, N = 0..9)
  43. $ borg create --compression lzma,N arch ~
  44. # Only compress compressible data with lzma,N (N = 0..9)
  45. $ borg create --compression auto,lzma,N arch ~
  46. # Use short hostname, user name and current time in archive name
  47. $ borg create '{hostname}-{user}-{now}' ~
  48. # Similar, use the same datetime format that is default as of borg 1.1
  49. $ borg create '{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S}' ~
  50. # As above, but add nanoseconds
  51. $ borg create '{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S.%f}' ~
  52. # Backing up relative paths by moving into the correct directory first
  53. $ cd /home/user/Documents
  54. # The root directory of the archive will be "projectA"
  55. $ borg create 'daily-projectA-{now:%Y-%m-%d}' projectA
  56. # Use external command to determine files to archive
  57. # Use --paths-from-stdin with find to back up only files less than 1MB in size
  58. $ find ~ -size -1000k | borg create --paths-from-stdin small-files-only
  59. # Use --paths-from-command with find to back up files from only a given user
  60. $ borg create --paths-from-command joes-files -- find /srv/samba/shared -user joe
  61. # Use --paths-from-stdin with --paths-delimiter (for example, for filenames with newlines in them)
  62. $ find ~ -size -1000k -print0 | borg create \
  63. --paths-from-stdin \
  64. --paths-delimiter "\0" \
  65. smallfiles-handle-newline