Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- basePath=/home/agpv/
- dirPath=${basePath}folder/
- files="$(ls $dirPath)"
- vcs=${basePath}vcs.txt
- log=${basePath}log.txt
- timeNow=$(date +%Y-%m-%d\ %H:%M:%S)
- echo $vcs
- if [ ! -e $vcs]
- then
- touch $vcs
- echo $basePath
- fi
- if [ ! -e $log]
- then
- touch $log
- fi
- for file in $files
- do
- if [ -e ${dirPath}${file}.tgz]
- then
- echo "Архив ${file} существует: ${timeNow}" >> $log
- lastWritefile = $(grep "^${file}:" $vcs)
- lastUpdateTimeFile = ${lastWriteFile##*:}
- modif = ${stat -c%Z ${dirPath}${file}}
- if ["$lastUpdateTime" != "$modif"]
- then
- echo "Архивация измененных файлов: ${timeNow}" >> $log
- tar -zcf $dirPath$file $dirPath
- fi
- else
- echo "Создание архива ${timeNow}" >> $log
- tar -zcf $dirPath$file.tgz $dirPath
- fi
- echo "${file}:$(stat -c%Z ${dirPath}${file})" >> $vcs
- echo "Запись данных файла в vcs" >> $log
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement