【Shell脚本】TDS离线备份还原

简介: 作者:gnuhpc 出处:http://www.cnblogs.com/gnuhpc/ Offline Backup/Restore the TDS 1.Preparation (1) Logon to the Server as root.

作者: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/


               作者:gnuhpc
               出处:http://www.cnblogs.com/gnuhpc/
               除非另有声明,本网站采用知识共享“署名 2.5 中国大陆”许可协议授权。


分享到:

目录
相关文章
|
2月前
|
Shell
一个用于添加/删除定时任务的shell脚本
一个用于添加/删除定时任务的shell脚本
106 1
|
1月前
|
Shell Linux 测试技术
6种方法打造出色的Shell脚本
6种方法打造出色的Shell脚本
59 2
6种方法打造出色的Shell脚本
|
28天前
|
缓存 监控 Shell
如何使用 HBase Shell 进行数据的实时监控和备份?
如何使用 HBase Shell 进行数据的实时监控和备份?
|
25天前
|
XML JSON 监控
Shell脚本要点和难点以及具体应用和优缺点介绍
Shell脚本在系统管理和自动化任务中扮演着重要角色。尽管存在调试困难、可读性差等问题,但其简洁高效、易于学习和强大的功能使其在许多场景中不可或缺。通过掌握Shell脚本的基本语法、常用命令和函数,并了解其优缺点,开发者可以编写出高效的脚本来完成各种任务,提高工作效率。希望本文能为您在Shell脚本编写和应用中提供有价值的参考和指导。
53 1
|
1月前
|
Ubuntu Shell 开发工具
ubuntu/debian shell 脚本自动配置 gitea git 仓库
这是一个自动配置 Gitea Git 仓库的 Shell 脚本,支持 Ubuntu 20+ 和 Debian 12+ 系统。脚本会创建必要的目录、下载并安装 Gitea,创建 Gitea 用户和服务,确保 Gitea 在系统启动时自动运行。用户可以选择从官方或小绿叶技术博客下载安装包。
45 2
|
2月前
|
监控 网络协议 Shell
ip和ip网段攻击拦截系统-绿叶结界防火墙系统shell脚本
这是一个名为“小绿叶技术博客扫段攻击拦截系统”的Bash脚本,用于监控和拦截TCP攻击。通过抓取网络数据包监控可疑IP,并利用iptables和firewalld防火墙规则对这些IP进行拦截。同时,该系统能够查询数据库中的白名单,确保合法IP不受影响。此外,它还具备日志记录功能,以便于后续分析和审计。
51 6
|
1月前
|
运维 监控 Shell
深入理解Linux系统下的Shell脚本编程
【10月更文挑战第24天】本文将深入浅出地介绍Linux系统中Shell脚本的基础知识和实用技巧,帮助读者从零开始学习编写Shell脚本。通过本文的学习,你将能够掌握Shell脚本的基本语法、变量使用、流程控制以及函数定义等核心概念,并学会如何将这些知识应用于实际问题解决中。文章还将展示几个实用的Shell脚本例子,以加深对知识点的理解和应用。无论你是运维人员还是软件开发者,这篇文章都将为你提供强大的Linux自动化工具。
|
2月前
|
监控 Unix Shell
shell脚本编程学习
【10月更文挑战第1天】shell脚本编程
79 12
|
2月前
|
存储 运维 监控
自动化运维:使用Shell脚本简化日常任务
【9月更文挑战第35天】在IT运维的日常工作中,重复性的任务往往消耗大量的时间。本文将介绍如何通过编写简单的Shell脚本来自动化这些日常任务,从而提升效率。我们将一起探索Shell脚本的基础语法,并通过实际案例展示如何应用这些知识来创建有用的自动化工具。无论你是新手还是有一定经验的运维人员,这篇文章都会为你提供新的视角和技巧,让你的工作更加轻松。
69 2
|
3月前
|
Shell
shell脚本变量 $name ${name}啥区别
shell脚本变量 $name ${name}啥区别