Shell script: TDS offline backup recovery

Source: Internet
Author: User
Tags gz file ldap

Author: gnuhpc
Source: 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 [36 m"
Echo "please check if the instance you want to $1 has been already done correctly (y/N ):"
Echo-ne "/E [0 m"
Echo-ne "/33 [31 m"
Echo "hints: if this requirement (or message)/" $2/"meets (or printed), it's done correctly! "
Echo-ne "/E [0 m"
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 [36 m"
Echo "Please wait ..."
Echo-ne "/E [0 m"
/Opt/IBM/ldap/v6.1/sbin/ibmslapd-I $ instance-K
Yes_or_no "stop" "terminated direcrory server instance XXX normally"
Echo-ne "/33 [36 m"
Echo "Please wait ..."
Echo-ne "/E [0 m"
/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 3 m 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 [36 m"
Echo "please check if the instance you want to $1 has been already done correctly (y/N ):"
Echo-ne "/E [0 m"
Echo-ne "/33 [31 m"
Echo "hints: if this requirement (or message)/" $2/"meets (or printed), it's done correctly! "
Echo-ne "/E [0 m"
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 [36 m"
Echo "Please wait ..."
Echo-ne "/E [0 m"
/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 [36 m"
Echo "Please wait ..."
Echo-ne "/E [0 m"
/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! "

Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.