Guest User

Untitled

a guest
Jan 22nd, 2020
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #!/usr/bin/env/bash
  3. checkIfAnyTimeIsAdded(){
  4. if [ -n $inc ] || [ -n $full ]; then
  5. if [[ -n $inc && -n $full ]]; then
  6. echo "You can't give both arguments for incremental and full backup"
  7. exit 0
  8. fi
  9. else
  10. echo "You have to give type of backup"
  11. exit 0
  12. fi
  13. }
  14. checkIfNameIsFilled(){
  15. if [ ! -n $name ]; then
  16. echo "you have to put a name argument !"
  17. exit 0
  18. fi
  19. }
  20. checkIfNameIsFilled(){
  21. if [ ! -n $name ]; then
  22. echo "you have to put a name argument !"
  23. exit 0
  24. fi
  25. }
  26. checkIfNumberIsADigit(){
  27. if [[ ! $number =~ [[:digit:]]+ ]];
  28. then
  29. echo "$typeOfBackup przyjmuje tylko wartość w sekundach"
  30. exit 1
  31. fi
  32. }
  33. year=`date +%Y`
  34. month=`date +%m`
  35. day=`date +%d`
  36. hour=`date +%H`
  37. minute=`date +%M`
  38. dateOfSnar=_$year"_"$month"_"$day"_"$hour"_"$minute
  39. _main() {
  40. backupLogs='logs.txt'
  41. BACKUPFILE=backup-$(date +%m-%d-%Y)
  42. # archive=${1:-$BACKUPFILE}
  43. name=''
  44. full_interval='' # format daty 'minuty godziny dni miesiące'
  45. inc_interval=''
  46. path=''
  47. ext=''
  48. backupDir=''
  49. IFS=','
  50. while [ "$1" != "" ]; do
  51. case $1 in
  52. '-h' | '--help')
  53. help
  54. exit 0
  55. ;;
  56. '-v' | '--version')
  57. info
  58. exit 0
  59. ;;
  60. --ext=) shift
  61. ext=$@
  62. extData= "find ./ -name $@ + |"
  63. ;;
  64. --name=) shift
  65. name="$1"
  66. ;;
  67. --path=) shift
  68. path=$1
  69. ;;
  70. --full-interval=)
  71. $typeOfBackup= "--full-interval"
  72. full="full"
  73. shift
  74. ;;
  75. --inc-interval=) shift
  76. inf="inc"
  77. $typeOfBackup= "--inc-interval"
  78. inc_interval="--listed-incremental=.snar"
  79. echo $dateOfSnar
  80. cat >> incrementalBackupsDates
  81. ;;
  82. --gzip)
  83. gzip=".gz";;
  84. --backup-dir=) shift
  85. backupDir=$1
  86. ;;
  87. * )
  88. usage
  89. exit 1
  90. esac
  91. shift
  92. done
  93. echo 'sadda'
  94. }
  95. checkIfNameIsFilled
  96. checkIfAnyTimeIsAdded
  97. checkIfScriptIsRunning
  98. #source ./logsCreator.sh -c
  99. _main "$@"
  100. echo "after main"
  101.  
  102. # sudo tar -xvpzf backup.tar.gz -C /recover
  103.  
  104. # sudo crontab -e
  105.  
  106. echo tar -cvzp -f $backupDir/$name/$name$inc$full$date.tar$gzip $path $inc_interval $full_interval $archive
  107.  
  108.  
  109. # sudo tar -cv $name $backupDir $inc_interval $archive $gzip
  110. # source ./logsCreator.sh -r
  111. exit 0
RAW Paste Data