Advertisement
NAGPV

архивация agpv

Jan 14th, 2022
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. basePath=/home/agpv/
  4.  
  5. dirPath=${basePath}folder/
  6. files="$(ls $dirPath)"
  7. vcs=${basePath}vcs.txt
  8. log=${basePath}log.txt
  9.  
  10. timeNow=$(date +%Y-%m-%d\ %H:%M:%S)
  11. echo $vcs
  12.  
  13. if [ ! -e $vcs]
  14. then
  15. touch $vcs
  16. echo $basePath
  17. fi
  18.  
  19. if [ ! -e $log]
  20. then
  21. touch $log
  22. fi
  23.  
  24. for file in $files
  25. do
  26. if [ -e ${dirPath}${file}.tgz]
  27. then
  28. echo "Архив ${file} существует: ${timeNow}" >> $log
  29. lastWritefile = $(grep "^${file}:" $vcs)
  30. lastUpdateTimeFile = ${lastWriteFile##*:}
  31. modif = ${stat -c%Z ${dirPath}${file}}
  32. if ["$lastUpdateTime" != "$modif"]
  33. then
  34. echo "Архивация измененных файлов: ${timeNow}" >> $log
  35. tar -zcf $dirPath$file $dirPath
  36. fi
  37. else
  38. echo "Создание архива ${timeNow}" >> $log
  39. tar -zcf $dirPath$file.tgz $dirPath
  40. fi
  41. echo "${file}:$(stat -c%Z ${dirPath}${file})" >> $vcs
  42. echo "Запись данных файла в vcs" >> $log
  43. done
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement