MD5 脚本。如果 md5check 重试下载脚本失败,如何创建脚本
我运行了一个脚本,用于从我的服务器下载备份。
正在通过 MD5 检查文件是否相同。
这是我的脚本:
if [[ ! "$1" =~ ^[0-9]{8}$ ]] || [[ ! "$2" =~ ^[0-9\.]+$ ]] || [[ ! "$3" =~ ^[A-Z0-9]+$ ]]
then
echo "Gebruik: backup_downloaden.sh jjjjmmdd ipadres naam"
exit 1
fi
cd /home/backups/Servers
scp -i /home/backups/.ssh/dedecaan_backups backups@$2:$3-$1-0500.tgz.gpg .
scp -i /home/backups/.ssh/dedecaan_backups backups@$2:$3-$1-0500.tgz.gpg.md5 .
scp -i /home/backups/.ssh/dedecaan_backups backups@$2:$3-$1-0500.tgz.gpg.volledig .
date > $3-$1.log
ls -l $3-$1-* --time-style=long-iso >> $3-$1.log
md5sum.textutils -c $3-$1-0500.tgz.gpg.md5 >> $3-$1.log
scp -i /home/backups/.ssh/dedecaan_backups $3-$1.log backups@$2:$3-$1.log
# logs altijd ook naar de productieserver kopiëren
scp -i /home/backups/.ssh/dedecaan_backups $3-$1.log [email protected]:$3-$1.log
我希望如果检查失败,下载作业会重新开始。我该怎么做?
谢谢
I got a script running for the downloading of the backups from my server.
The files are being checked by MD5 is they are both the same.
Here is my script:
if [[ ! "$1" =~ ^[0-9]{8}$ ]] || [[ ! "$2" =~ ^[0-9\.]+$ ]] || [[ ! "$3" =~ ^[A-Z0-9]+$ ]]
then
echo "Gebruik: backup_downloaden.sh jjjjmmdd ipadres naam"
exit 1
fi
cd /home/backups/Servers
scp -i /home/backups/.ssh/dedecaan_backups backups@$2:$3-$1-0500.tgz.gpg .
scp -i /home/backups/.ssh/dedecaan_backups backups@$2:$3-$1-0500.tgz.gpg.md5 .
scp -i /home/backups/.ssh/dedecaan_backups backups@$2:$3-$1-0500.tgz.gpg.volledig .
date > $3-$1.log
ls -l $3-$1-* --time-style=long-iso >> $3-$1.log
md5sum.textutils -c $3-$1-0500.tgz.gpg.md5 >> $3-$1.log
scp -i /home/backups/.ssh/dedecaan_backups $3-$1.log backups@$2:$3-$1.log
# logs altijd ook naar de productieserver kopiëren
scp -i /home/backups/.ssh/dedecaan_backups $3-$1.log [email protected]:$3-$1.log
I want if the check fails that the download job starts over again. How can I do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我们看一下文档:
info coreutils 'md5sum invoice'
(如手册页man md5sum
所示):所以基本上,您需要检查
md5sum.textutils
的返回值,如果返回值不是0
则返回到开头代码>.最后执行的命令的返回值存储在$?
中。let's take a look at the doc:
info coreutils 'md5sum invocation'
(as told from the man pageman md5sum
):so basically, you need to check for the return value of
md5sum.textutils
, and go back to the beginning if the return value is not0
. the return value of the last command executed is stored in$?
.