作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

Offline Backup/Restore the TDS

1.Preparation
(1) Logon to the Server as root.
(2) Open a terminal, check if there is the script named tarbackup.sh in /usr/local/bin directory
(3) Make sure you know the instance name  you want to backup in TDS ("instance" hereinafter called for short ) and the location the backup file will be put ("path" hereinafter called for short ).
2.Do the backup operation
(1)Run the script
$/usr/local/bin/tarbackup.sh instance path
E.g.:   /usr/local/bin/tarbackup.sh idsinst /opt/backup
The script will mainly do three operations below:
   1)Stop the instance.
   2)Backup the instance(/opt/ibm/ldap/V6.1/sbin/idsdbback)
   3)Tar the backupfile and move it to the directory specified
   4)Start the instance.
So you have to confirm that each operation has been executed correctly.The script will give you the opportunity to do this and Please notice the hints the script tells you, It's helpful.When It prints out"Done,Bye", the whole process of backup is finished.
3.Restore the TDS backup
Make sure you know the instance name you want to backup in TDS ("instance" hereinafter called for short ) and the location the backup file has be put ("path" hereinafter called for short ) and the archive filename of the backup("name" hereinafter called for short )
Run the script
$/usr/local/bin/untarbackup.sh instance path name
E.g.:
/usr/local/bin/untarbackup.sh idsinst /opt/backup 2009_Mar_26.tar.gz
The script will mainly do three operations below:
1)Stop the instance.
2)Untar the backup archive.
3)Restore the instance(/opt/ibm/ldap/V6.1/sbin/idsdbrestore)
4)Start the instance.
So you have to confirm that each operation has been executed correctly.The script will give you the opportunity to do this and Please notice the hints the script tells you, It's helpful.When It prints out"Done,Bye", the whole process of restore is finished.
tarbackup.sh:
#!/bin/bash
yes_or_no()
{
    while true
    do
        echo -ne "/33[36m"
        echo "Please check if the instance you want to $1 has been already done correctly(y/n):"
        echo -ne "/e[0m"
        echo -ne "/33[31m"
        echo  "Hints:If this requirement (or message) /"$2/" meets(or printed) ,It's done correctly!"
        echo -ne "/e[0m"
        read -s -n 1 confirm
        case $confirm in
            Y|y)return 0;;
            N|n)echo "Error happened ,Exit!";exit 1;;
            * )echo "Please enter Y/y or N/n";echo -e "/n";;
        esac
    done
}
INSTANCE=$1
backup_path=$2
time_info=`date "+%Y_%b_%d"`
if [ ! -d "/backup" ];then
    mkdir /backup
    chmod 777 /backup
fi
echo -ne "/33[36m"
echo "Please Wait..."
echo -ne "/e[0m"
/opt/ibm/ldap/V6.1/sbin/ibmslapd -I $INSTANCE -k
yes_or_no "stop" "Terminated direcrory server instance XXX normally"
echo -ne "/33[36m"
echo "Please Wait..."
echo -ne "/e[0m"
/opt/ibm/ldap/V6.1/sbin/idsdbback -I $INSTANCE -b /backup/tdsbackup -k /backup/
tar -czf "$time_info".tar.gz /backup >/dev/null 2&>1
mv "$time_info".tar.gz $backup_path
ls -lh $backup_path/"$time_info".tar.gz
yes_or_no "Backup" "if the size tar.gz file is greater than 3M it's correct"
/opt/ibm/ldap/V6.1/sbin/ibmslapd -I $INSTANCE
yes_or_no "Start" "Server starting"
rm -f /backup/*
echo "Done,Bye!"
untarbackup.sh
#!/bin/bash
yes_or_no()
{
    while true
    do
        echo -ne "/33[36m"
        echo "Please check if the instance you want to $1 has been already done correctly(y/n):"
        echo -ne "/e[0m"
        echo -ne "/33[31m"
        echo  "Hints:If this requirement (or message) /"$2/" meets(or printed) ,It's done correctly!"
        echo -ne "/e[0m"
        read -s -n 1 confirm
        case $confirm in
            Y|y)return 0;;
            N|n)echo "Error happened ,Exit!";exit 1;;
            * )echo "Please enter Y/y or N/n";echo -e "/n";;
        esac
    done
}
INSTANCE=$1
backup_path=$2
time_info=`date "+%Y_%b_%d"`
file=$3
echo -ne "/33[36m"
echo "Please Wait..."
echo -ne "/e[0m"
/opt/ibm/ldap/V6.1/sbin/ibmslapd -I $INSTANCE -k
yes_or_no "stop" "Terminated direcrory server instance XXX normally"
tar zxvf "$backup_path"/"$file" -C $backup_path #>/dev/null 2&>1
echo -ne "/33[36m"
echo "Please Wait..."
echo -ne "/e[0m"
/opt/ibm/ldap/V6.1/sbin/idsdbrestore -I $INSTANCE -k $backup_path/backup/
yes_or_no "Restore" "From the message We can know that A lot of items have been restored"
/opt/ibm/ldap/V6.1/sbin/ibmslapd -I $INSTANCE
yes_or_no "Start" "Server starting"
rm -rf $backup_path/backup/
echo "Done,Bye!"

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

【Shell脚本】TDS离线备份还原相关推荐

  1. 用shell脚本实现定时备份数据库

    1.备份数据库的方法 可以使用命令查看 ls  /usr/local/mysql/bin 这个mysqldump就是系统内置的用来备份数据库的工具. 2.实现方法 ①先随便进入一个位置创建一个目录 ② ...

  2. shell脚本实现自动化备份

    shell脚本实现自动化备份 1.备份规则: 在生产环境中有若干服务器需要定时将服务器中应用程序,以及数据库等进行备份.要求在本地服务器中保存近一周的备份,备份服务器中保存最近一月的备份文件.     ...

  3. shell——脚本实现数据库备份

    一.如何使用脚本对数据库进行备份 命令找出数据库: 安装数据库并进行安全初始化: 编写数据库备份脚本: 测试脚本:

  4. Linux shell脚本、定时备份mysql数据库、sendMail邮件发送

    数据库备份 定时任务 邮件发送 一.数据库备份 vim /sqlbackup/mysql_backup.sh#!/bin/sh ###定义变量#### date=`date "+%Y-%m- ...

  5. rsync+shell脚本完成自动化备份

    在/root/.ssh目录下vi创建一个copy.sh脚本文件 写入以下内容 设置权限 ./copy.sh执行脚本 在接收端查看文件传输成功 vi /etc/crontab 进入添加自动完成指令 修改 ...

  6. 新手学习Linux——rsync+shell脚本完成自动化备份

    (自行理解) -------------------分割线----------------- 首先关掉防火墙 iptables -F iptables -X iptables -Z iptables ...

  7. mysql增量备份二进制日志,mysql增量备份二进制日志shell脚本

    mysql增量备份二进制日志shell脚本 mysql增量备份二进制日志shell exit?0 echo?"?"?>>$log_file echo?"End ...

  8. 一个备份MySQL数据库的简单Shell脚本(转)

    Shell脚本是我们写不同类型命令的一种脚本,这些命令在这一个文件中就可以执行.我们也可以逐一敲入命令手动执行.如果我们要使用shell脚本就必须在一开始把这些命令写到一个文本文件中,以后就可以随意反 ...

  9. [原创]MYSQL周期备份shell脚本

    这个脚本是实现阿里云mysql数据库全量周期备份的shell脚本,实现备份数据按一周星期几分开存放.一下是脚本内容: #!/bin/bash echo `date`echo "backup ...

最新文章

  1. 字节数组拼接打印以及list小技巧
  2. Hadoop详解(四):HDFS shell操作和Java API操作
  3. container_of 用法解析
  4. Android之RecyclerView 实现真正的Gallery效果
  5. 2019/4/17 Linux学习
  6. gui显示文本动态框
  7. HOG特征(Histogram of Gradient)总结
  8. C# Socket SSL通讯笔记
  9. 大数据技术笔记之数据采集和预处理
  10. Adobe Premiere(pr)2021 安装教程【64位】
  11. 51单片机流水灯画图打板焊元件历程
  12. 独家研究 I 某新一线城市中高端养老社区项目(CCRC)入住客户画像深度洞察研究报告
  13. tzoj 3847 Mowing the Lawn (单调队列 )
  14. 空气质量指数,主要污染物PM10、PM2.5、CO、NO2、SO2详解
  15. win 桌面图标小箭头
  16. 网络编程中,同步传输和异步传输有什么区别
  17. 三代日期类的基本使用
  18. 根据电路建立微分方程
  19. NB-IoT智能配电柜测温监测系统解决方案
  20. 网页防篡改技术的前世与今生

热门文章

  1. shiro多Realm分别授权
  2. 接口测试工具-Jmeter使用笔记(九:跨线程组传递变量)
  3. c语言程序改错输入5结果为15,《C语言程序设计教学课件》程序改错(自我总结).doc...
  4. Spring MVC处理用户请求的完整流程
  5. php ajax实现上移,jquery实现标签上移、下移、置顶_jquery
  6. java对象属性的作用域类型_java 对象和类
  7. android tools add native support,使用NDK进行开发android
  8. ef mysql不显示所有表_mysql中显示当前数据库下的所有表,包括视图。
  9. 32位linux时间戳,32位unix时间戳哪一年用尽
  10. 金融数据分析与挖掘实战练习2.1-2.4