Advertisement
Guest User

EEEROCK

a guest
Nov 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/bash
  2. mkdir JUSTFORBACKUP
  3. echo "Path to Directory, EXAMPLE:/home/admin00/Desktop/aaa/"
  4. #read pathToDirectory
  5. echo "Rasshirenie, EXAMPLE:.txt"
  6. #read rasshirenie
  7. pathToDirectory="/home/admin00/Desktop/aaa/"
  8. rasshirenie=".txt"
  9. maxCopiesCount=5
  10. currentDate=$(date +%Y-%m-%d-%S)
  11. #firstsize=$(du -bS *.txt $pathToDirectory)
  12.  
  13.  
  14. #archivate
  15. tar -cf JUSTFORBACKUP/ArchiveForBackup$currentDate.tar $pathToDirectory*$rasshirenie
  16.  
  17.  
  18. #check if archive is bad
  19. tar -xf JUSTFORBACKUP/ArchiveForBackup$currentDate.tar >> /dev/null; echo $?
  20.  
  21.  
  22. #delete old copies
  23. allCount=$((ls -f JUSTFORBACKUP)|(wc -l))
  24. copiesCount=$(($allCount-2))  #get Copies count
  25. differnce=$(($copiesCount-$maxCopiesCount))
  26. #if [[$differnce=1]]; then rm -r "JUSTFORBACKUP/1" fi
  27.  
  28.  
  29. #time when you do this
  30. #cat <(crontab -l) <(echo "0 0 * * 5/home/admin00/Desktop/backup.sh") | crontab -
  31. #(crontab -l 2>&/dev/null; echo "0 0 * * 5/home/admin00/Desktop/backup.sh")|crontab -
  32. #crontab -l|{cat; echo "0 0 * * 5/home/admin00/Desktop/backup.sh";}|crontab -
  33. #does backup every friday
  34. # in terminal: crontab -e, then 0 0 * * 5/home/admin00/Desktop/backup.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement