首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何备份应用程序的数据库

如何备份应用程序的数据库
EN

Stack Overflow用户
提问于 2017-10-17 13:14:07
回答 1查看 31关注 0票数 0

我正在尝试编写一个脚本来备份由应用程序管理的数据库,并且想知道是否有一种更简单的方法来实现它。我想我把事情弄复杂了。

基本上,我将停止应用程序服务(除了数据库之外),并将其保存到文本文件中,文本文件被读取,直到它给出适当的输出。然后,我运行一个脚本,将数据库导出到两个文件,并将输出写入另一个文本文件,该文本文件被读取,直到成功。然后,我再次启动服务。

以下是代码:

代码语言:javascript
复制
#!/bin/bash

#Make sure to run in the right folder!

echo "Here it will stop the manager services"

/etc/init.d/arcsight_services stop manager > /tmp/tmp/mangerstatusdown.txt

while [["./rr.sh /tmp/tmp/managerstatusdown.txt" != "[manager status down]"]]

do 

    echo "Not Ready Yet"
    read -p "Do you think it's ready to move on?"

done 

echo "Now it will export the database"

/opt/arcsight/manager/bin/arcsight export_system_tables > /tmp/tmp/systemtables.txt

while [["./rr.sh /tmp/tmp/systemtables.txt" != "[system tables export successful]" ]]
do 

    echo "Not Ready Yet"
    read -p "Do you think it's ready to move on?"

done

echo "Here it will start the manager again"

/etc/init.d/arcsight_services start manager

这是引用的rr.sh脚本:

代码语言:javascript
复制
while IFS=' ' read -r line || [[ -n "$line"]]; do
    echo "Text read from file:  $line"
done < "$1"


#run as follows:
#chmod +x rr.sh
#./rr.sh filename.txt

这实际上是我的第一个剧本,所以当你解释的时候请记住这一点!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-17 13:23:01

bash不直接进行字符串比较;您需要使用特定的命令。

代码语言:javascript
复制
while [[ "$(./rr.sh /tmp/tmp/systemtables.txt)" != "[system tables export successful]" ]]
do 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46791094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档