create.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 /mnt/disk/docs, but strip path prefix using the slashdot hack
  10. $ borg create /path/to/repo::docs /mnt/disk/./docs
  11. # Backup ~/Documents and ~/src but exclude pyc files
  12. $ borg create my-files \
  13. ~/Documents \
  14. ~/src \
  15. --exclude '*.pyc'
  16. # Backup home directories excluding image thumbnails (i.e. only
  17. # /home/<one directory>/.thumbnails is excluded, not /home/*/*/.thumbnails etc.)
  18. $ borg create my-files /home --exclude 'sh:home/*/.thumbnails'
  19. # Backup the root filesystem into an archive named "root-archive"
  20. # use zlib compression (good, but slow) - default is lz4 (fast, low compression ratio)
  21. $ borg create -C zlib,6 --one-file-system root-archive /
  22. # Backup into an archive name like FQDN-root
  23. $ borg create '{fqdn}-root' /
  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 example.com-root .
  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 docs):
  33. $ borg create --chunker-params buzhash,10,23,16,4095 small /smallstuff
  34. # Backup a raw device (must not be active/in use/mounted at that time)
  35. $ borg create --read-special --chunker-params fixed,4194304 my-sdx /dev/sdX
  36. # Backup a sparse disk image (must not be active/in use/mounted at that time)
  37. $ borg create --sparse --chunker-params fixed,4194304 my-disk my-disk.raw
  38. # No compression (none)
  39. $ borg create --compression none arch ~
  40. # Super fast, low compression (lz4, default)
  41. $ borg create arch ~
  42. # Less fast, higher compression (zlib, N = 0..9)
  43. $ borg create --compression zlib,N arch ~
  44. # Even slower, even higher compression (lzma, N = 0..9)
  45. $ borg create --compression lzma,N arch ~
  46. # Only compress compressible data with lzma,N (N = 0..9)
  47. $ borg create --compression auto,lzma,N arch ~
  48. # Use short hostname and user name as archive name
  49. $ borg create '{hostname}-{user}' ~
  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 'daily-projectA' projectA
  54. # Use external command to determine files to archive
  55. # Use --paths-from-stdin with find to back up only files less than 1MB in size
  56. $ find ~ -size -1000k | borg create --paths-from-stdin small-files-only
  57. # Use --paths-from-command with find to back up files from only a given user
  58. $ borg create --paths-from-command joes-files -- find /srv/samba/shared -user joe
  59. # Use --paths-from-stdin with --paths-delimiter (for example, for filenames with newlines in them)
  60. $ find ~ -size -1000k -print0 | borg create \
  61. --paths-from-stdin \
  62. --paths-delimiter "\0" \
  63. smallfiles-handle-newline