Advertisement
v1ral_ITS

Extremely easy create compressed backup shell script

Jun 17th, 2020
1,488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.01 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #/#/ Define any tools needed here seperated only by a "\:space:"\
  4. needed_tool=' yad archivemount '
  5.  
  6. #//* Begin System Tool Search
  7. require_tools ()
  8. {
  9.     local NOT_AVAIL=""
  10.     for TOOL in $needed_tool; do
  11.         if [ "`which $TOOL`" 2> /dev/null == "" ]; then
  12.     NOT_AVAIL="$NOT_AVAIL $TOOL";
  13.     fi
  14.     done
  15.     if [[ "$NOT_AVAIL" != "" ]]; then
  16.     echo "ERROR: The following required tool(s) cannot be found: $NOT_AVAIL"
  17.         exit 3
  18.     fi
  19. }
  20.  
  21. # Check file system tools before we start
  22. require_tools || exit 1
  23.  
  24. # VARIABLES
  25. THIS_DIR=$PWD/TMP_ARCH
  26. MK_DIR=$(mkdir $THIS_DIR)
  27. FILE=./backup.$(date | sed -e "s/\ /./g").tar
  28. DESTIN="$(yad --title "Choose Direcotory To Backup" --file-selection --directory)"
  29.  
  30. # PREPERATION
  31. touch "$FILE"
  32. $MK_DIR
  33. archivemount "$FILE" "$THIS_DIR"
  34.  
  35. # ADDING FILE TO ARCHIVE
  36. cp -r -v "$DESTIN" "$THIS_DIR"
  37. echo -e "To continue press [e]nter: "
  38. read NULL
  39.  
  40. # UNMOUNT
  41. fusermount -u $THIS_DIR
  42.  
  43. # CLEANUP
  44. rm -R $THIS_DIR
  45. rm "$FILE".orig
  46.  
  47. # FINISH
  48. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement