basic.tcl 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Configuration for send -h
  2. # Tries to emulate a human typing
  3. # Tweak this if typing is too fast or too slow
  4. set send_human {.05 .1 1 .01 .2}
  5. # The screencast uses relative paths "Wallpaper"
  6. # We should not mess with the contents of whatever cwd happened to be
  7. cd [exec mktemp -d]
  8. file mkdir Wallpaper/bigcollection
  9. exec touch Wallpaper/deer.jpg
  10. set script {
  11. # Here you'll see some basic commands to start working with borg.
  12. # Note: This teaser screencast was made with __BORG_VERSION__ – older or newer borg versions may behave differently.
  13. # But let's start.
  14. # First of all, you can always get help:
  15. borg help
  16. # These are a lot of commands, so better we start with a few:
  17. # Let's create a repo on an external drive…
  18. borg init --encryption=repokey /media/backup/borgdemo
  19. # This uses the repokey encryption. You may look at "borg help init" or the online doc at https://borgbackup.readthedocs.io/ for other modes.
  20. # So now, let's create our first (compressed) backup.
  21. borg create --stats --progress --compression lz4 /media/backup/borgdemo::backup1 Wallpaper
  22. # That's nice, so far.
  23. # So let's add a new file…
  24. echo "new nice file" > Wallpaper/newfile.txt
  25. borg create --stats --progress --compression lz4 /media/backup/borgdemo::backup2 Wallpaper
  26. # Wow, this was a lot faster!
  27. # Notice the "Deduplicated size" for "This archive"!
  28. # Borg recognized that most files did not change and deduplicated them.
  29. # But what happens, when we move a dir and create a new backup?
  30. mv Wallpaper/bigcollection Wallpaper/bigcollection_NEW
  31. borg create --stats --progress --compression lz4 /media/backup/borgdemo::backup3 Wallpaper
  32. # Still quite fast…
  33. # But when you look at the "deduplicated file size" again, you see that borg also recognized that only the dir and not the files changed in this backup.
  34. # Now lets look into a repo.
  35. borg list /media/backup/borgdemo
  36. # You'll see a list of all backups.
  37. # You can also use the same command to look into an archive. But we better filter the output here:
  38. borg list /media/backup/borgdemo::backup3 | grep 'deer.jpg'
  39. # Oh, we found our picture. Now extract it…
  40. mv Wallpaper Wallpaper.orig
  41. borg extract /media/backup/borgdemo::backup3 Wallpaper/deer.jpg
  42. # And check that it's the same:
  43. diff -s Wallpaper/deer.jpg Wallpaper.orig/deer.jpg
  44. # And, of course, we can also create remote repos via ssh when borg is setup there. This command creates a new remote repo in a subdirectory called "demo":
  45. borg init --encryption=repokey borgdemo@remoteserver.example:./demo
  46. # Easy, isn't it? That's all you need to know for basic usage.
  47. # If you want to see more, have a look at the screencast showing the "advanced usage".
  48. # In any case, enjoy using borg!
  49. }
  50. set script [string trim $script]
  51. set script [string map [list __BORG_VERSION__ [exec borg -V]] $script]
  52. set script [split $script \n]
  53. foreach line $script {
  54. send_user "$ "
  55. send_user -h $line\n
  56. spawn -noecho /bin/sh -c $line
  57. expect {
  58. "Enter new passphrase: " {
  59. send -h "correct horse battery staple\n"
  60. exp_continue
  61. }
  62. "Enter same passphrase again: " {
  63. send -h "correct horse battery staple\n"
  64. exp_continue
  65. }
  66. "Enter passphrase for key /media/backup/borgdemo: " {
  67. send -h "correct horse battery staple\n"
  68. exp_continue
  69. }
  70. -ex {Do you want your passphrase to be displayed for verification? [yN]: } {
  71. send \n
  72. exp_continue
  73. }
  74. eof
  75. }
  76. }