create.rst 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 onto a remote host ("push" style) via ssh to port 2222,
  22. # logging in as user "borg" and storing into /path/to/repo
  23. $ borg create ssh://borg@backup.example.org:2222/path/to/repo::{fqdn}-root-{now} /
  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 /path/to/repo::example.com-root-{now:%Y-%m-%d} .
  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
  33. # docs - same parameters as borg < 1.0 or attic):
  34. $ borg create --chunker-params buzhash,10,23,16,4095 /path/to/repo::small /smallstuff
  35. # Backup a raw device (must not be active/in use/mounted at that time)
  36. $ dd if=/dev/sdx bs=4M | borg create --chunker-params fixed,4194304 /path/to/repo::my-sdx -
  37. # No compression (none)
  38. $ borg create --compression none /path/to/repo::arch ~
  39. # Super fast, low compression (lz4, default)
  40. $ borg create /path/to/repo::arch ~
  41. # Less fast, higher compression (zlib, N = 0..9)
  42. $ borg create --compression zlib,N /path/to/repo::arch ~
  43. # Even slower, even higher compression (lzma, N = 0..9)
  44. $ borg create --compression lzma,N /path/to/repo::arch ~
  45. # Only compress compressible data with lzma,N (N = 0..9)
  46. $ borg create --compression auto,lzma,N /path/to/repo::arch ~
  47. # Use short hostname, user name and current time in archive name
  48. $ borg create /path/to/repo::{hostname}-{user}-{now} ~
  49. # Similar, use the same datetime format that is default as of borg 1.1
  50. $ borg create /path/to/repo::{hostname}-{user}-{now:%Y-%m-%dT%H:%M:%S} ~
  51. # As above, but add nanoseconds
  52. $ borg create /path/to/repo::{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 /path/to/repo::daily-projectA-{now:%Y-%m-%d} projectA