rsync_disk.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # rsync script
  3. # exit when any command fails
  4. set -e
  5. ### set variables
  6. username=$(echo "$USER")
  7. ### set directories
  8. DIR="/run/media/$username/"
  9. ### set USAGE message
  10. MESSAGE="USAGE: rsync_usb <device_name> <dry/run>"
  11. # go to home dir
  12. cd ~
  13. # check parameters
  14. if [ -z "$1" ]; then
  15. echo $MESSAGE
  16. exit 1
  17. fi
  18. if [ -z "$2" ]; then
  19. echo $MESSAGE
  20. exit 1
  21. fi
  22. # set variables
  23. DEVICE=$1
  24. # set source/target
  25. SOURCEDIR=~
  26. TARGETDIR="$DIR$DEVICE/backup"
  27. echo "SOURCE: $SOURCEDIR"
  28. echo "TARGET: $TARGETDIR"
  29. # dry run set
  30. if [ "$2" = "dry" ]; then
  31. DRY_RUN=n
  32. echo "DRY_RUN: YES"
  33. else
  34. if [ "$2" = "run" ]; then
  35. DRY_RUN=
  36. echo "DRY_RUN: NO"
  37. else
  38. echo $MESSAGE
  39. exit 1
  40. fi
  41. fi
  42. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/Documentos" "$TARGETDIR/backup/"
  43. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.bash_aliases" "$TARGETDIR/backup/"
  44. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.tmux.conf" "$TARGETDIR/backup/"
  45. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/script" "$TARGETDIR/backup/"
  46. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.picom.conf" "$TARGETDIR/backup/"
  47. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.rtorrent.rc" "$TARGETDIR/backup/"
  48. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.vimrc" "$TARGETDIR/backup/"
  49. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.xinitrc" "$TARGETDIR/backup/"
  50. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.fehbg" "$TARGETDIR/backup/"
  51. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.bashrc" "$TARGETDIR/backup/"
  52. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.bash_profile" "$TARGETDIR/backup/"
  53. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/Documentacion" "$TARGETDIR/backup/"
  54. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.Xdefaults" "$TARGETDIR/backup/"
  55. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/.Xresources" "$TARGETDIR/backup/"
  56. rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/books" "$TARGETDIR/"
  57. #rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/games/doom" "$TARGETDIR/games/"
  58. #rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/games/doom3" "$TARGETDIR/games/"
  59. #rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/games/quake" "$TARGETDIR/games/"
  60. #rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/games/quake2" "$TARGETDIR/games/"
  61. #rsync -vhru"$DRY_RUN" --size-only --delete "$SOURCEDIR/games/wolf3d" "$TARGETDIR/games/"