如何备份应用程序的数据库
How to backup an application's database
我正在尝试编写一个脚本来备份由应用程序管理的数据库,想知道是否有更简单的方法来执行此操作。我想我把它弄复杂了。
基本上我会停止应用程序服务(除了数据库)并将其保存到一个文本文件中,读取该文件直到它提供适当的输出。然后,我 运行 一个将数据库导出到两个文件的脚本,并将输出写入另一个文本文件,读取直到成功。然后,我再次启动服务。
代码如下:
#!/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 脚本:
while IFS=' ' read -r line || [[ -n "$line"]]; do
echo "Text read from file: $line"
done < ""
#run as follows:
#chmod +x rr.sh
#./rr.sh filename.txt
这实际上是我的第一个脚本,所以请在解释时记住这一点!
bash
不直接进行字符串比较;您需要使用特定的命令。
while [[ "$(./rr.sh /tmp/tmp/systemtables.txt)" != "[system tables export successful]" ]]
do
我正在尝试编写一个脚本来备份由应用程序管理的数据库,想知道是否有更简单的方法来执行此操作。我想我把它弄复杂了。
基本上我会停止应用程序服务(除了数据库)并将其保存到一个文本文件中,读取该文件直到它提供适当的输出。然后,我 运行 一个将数据库导出到两个文件的脚本,并将输出写入另一个文本文件,读取直到成功。然后,我再次启动服务。
代码如下:
#!/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 脚本:
while IFS=' ' read -r line || [[ -n "$line"]]; do
echo "Text read from file: $line"
done < ""
#run as follows:
#chmod +x rr.sh
#./rr.sh filename.txt
这实际上是我的第一个脚本,所以请在解释时记住这一点!
bash
不直接进行字符串比较;您需要使用特定的命令。
while [[ "$(./rr.sh /tmp/tmp/systemtables.txt)" != "[system tables export successful]" ]]
do