basic.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Here you'll see some basic commands to start working with borg.
  2. # Note: This teaser screencast was made with borg version 1.1.0 – older or newer borg versions may behave differently.
  3. # But let's start.
  4. # First of all, you can always get help:
  5. borg help
  6. # These are a lot of commands, so better we start with a few:
  7. # Let's create a repo on an external drive…
  8. borg init --encryption=repokey /media/backup/borgdemo
  9. # This uses the repokey encryption. You may look at "borg help init" or the online doc at https://borgbackup.readthedocs.io/ for other modes.
  10. # So now, let's create our first (compressed) backup.
  11. borg create --stats --progress --compression lz4 /media/backup/borgdemo::backup1 Wallpaper
  12. # That's nice, so far.
  13. # So let's add a new file…
  14. echo "new nice file" > Wallpaper/newfile.txt
  15. <up>
  16. borg create --stats --progress --compression lz4 /media/backup/borgdemo::backup2 Wallpaper
  17. # Wow, this was a lot faster!
  18. # Notice the "Deduplicated size" for "This archive"!
  19. # Borg recognized that most files did not change and deduplicated them.
  20. # But what happens, when we move a dir and create a new backup?
  21. mv …
  22. borg create --stats --progress --compression lz4 /media/backup/borgdemo::backup3 Wallpaper
  23. # Still quite fast…
  24. # 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.
  25. # Now lets look into a repo.
  26. borg list /media/backup/borgdemo
  27. # You'll see a list of all backups.
  28. # You can also use the same command to look into an archive. But we better filter the output here:
  29. borg list /media/backup/borgdemo::backup3 | grep 'deer.jpg'
  30. # Oh, we found our picture. Now extract it…
  31. mv Wallpaper Wallpaper.orig
  32. borg extract /media/backup/borgdemo::backup3 <copy>
  33. # And check that it's the same:
  34. diff -s Wallpaper/deer.jpg Wallpaper.orig/deer.jpg
  35. # 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":
  36. borg init --encryption=repokey borgdemo@remoteserver.example:./demo
  37. # Easy, isn't it? That's all you need to know for basic usage.
  38. # If you want to see more, have a look at the screencast showing the "advanced usage".
  39. # In any case, enjoy using borg!