Netbackup For Sybase
Netbackup For Sybase
Netbackup For Sybase
Abstract
Simplified Step by Step Guide for Sybase Database Backup and Restore using Netbackup
Ahmed Atef
Ahmed.Atef@intercom.com.eg
Netbackup for Sybase
Contents
About Netbackup for Sybase ........................................................................................................................ 3
Summary about this Guide ........................................................................................................................... 3
Responsibilities ............................................................................................................................................. 4
Netbackup Administrator ......................................................................................................................... 4
Sybase database Administrator ................................................................................................................ 4
Planning and Deploying the Solution ............................................................................................................ 5
Sybase Database Version and OS level ..................................................................................................... 6
Get Sybase Database Version using Isql ............................................................................................... 6
Get Sybase Database Version using DBIsql ........................................................................................... 7
Get OS Level ........................................................................................................................................ 10
Sizing for Sybase Backup ......................................................................................................................... 11
Get Sybase Database Size using Isql ................................................................................................... 11
Get Sybase Database Size using DBIsql ............................................................................................... 13
Sybase Environment Variables................................................................................................................ 16
Get the Sybase Server name ............................................................................................................... 16
Get the Sybase home directory .......................................................................................................... 17
Netbackup Deployment and Configuration ............................................................................................ 18
Installing Netbackup Client ................................................................................................................. 18
Configuring Netbackup Client ............................................................................................................. 24
Backup Sybase database ............................................................................................................................. 26
Creating Backup Scripts .......................................................................................................................... 26
Coping the scripts................................................................................................................................ 26
Editing Backup Script .......................................................................................................................... 27
Creating Backup Policies ......................................................................................................................... 38
Database Backup Policy ...................................................................................................................... 38
Configuration files Backup Policy ........................................................................................................ 42
Restore Sybase Database ............................................................................................................................ 46
Listing Backups and Creating Scripts....................................................................................................... 46
Listing available backups ..................................................................................................................... 47
Editing the restore script .................................................................................................................... 48
Editing the load script ......................................................................................................................... 52
Creating a database for restore .............................................................................................................. 59
AHMED ATEF 1
Netbackup for Sybase
AHMED ATEF 2
Netbackup for Sybase
This guide is for those who administer Netbackup on an environment that contains one or more Sybase
database servers, Or a Sybase database administrators who are riddled by the amount of Sybase servers
on their environment that need to be backed up and secured.
Note this Guide is prepared using Netbackup 7.7.1 on windows and Sybase database ASE 16 on Linux, it
may be inappropriate for your environment if you are using different versions, so please review your
version documentation to see if there is any new features or changes.
AHMED ATEF 3
Netbackup for Sybase
Responsibilities
Whenever it comes to responsibilities conflicts appears, and at this part of the document, I am going to
clarify the scope of work based on the administrator role.
Netbackup Administrator
At this case the Netbackup administrator is responsible for planning the backup strategy with the Sybase
database administrator, Providing the Netbackup Client Software with the prober version for the Sybase
database environment, Installing and Configuring the Netbackup Client Software on Sybase database
servers, Creating the Prober Backup Policies and Schedules according to the plan, Monitoring backup
and restore jobs status, training the database administrator on how to restore a Sybase database in case
of corruption or data loss and troubleshoot any problems related to the backup or restore jobs.
At this case the Sybase database administrator is responsible for providing Sybase database
environment variables, Providing the prober backup schedules, retention periods and type of backup,
Creating databases for restores and restoring databases.
AHMED ATEF 4
Netbackup for Sybase
First thing first what version of Netbackup Client is compatible with your Sybase database version and
OS, here comes the Sybase database administrator and provide the Netbackup administrator with the
Sybase database version and OS level.
Second for sizing you will need to know the size of the Sybase databases that you need to backup and
how long it will be retained at what frequency of backup, here comes the Sybase database administrator
and provide the Netbackup administrator with the database sizes.
Third and before deployment of Netbackup Client Software we need to get both Sybase server name
and Sybase home directory.
Fourth is deploying and configuring the Netbackup Client Software on the Sybase database server
AHMED ATEF 5
Netbackup for Sybase
Using the provided data the Netbackup Administrator will check “Netbackup Compatibility Matrix” and
prepare the prober Netbackup Client Software version source.
From Terminal the Sybase Database Administrator will Change directory to /opt/sap/OCS-16_0/bin/
assuming that Sybase home is /opt/sap/
Then he will connect to the Sybase database server using ./isql –Usa –SSAP assuming that the Sybase
database server name is SAP
After connecting and entering the password the following query should be used
use master
go
go
AHMED ATEF 6
Netbackup for Sybase
AHMED ATEF 7
Netbackup for Sybase
Then enters the prober user name and password to connect to the Sybase database server
AHMED ATEF 8
Netbackup for Sybase
Go
Go
F5 key to execute
AHMED ATEF 9
Netbackup for Sybase
Get OS Level
Using terminal the Sybase database administrator executes the following command
“uname –a”
AHMED ATEF 10
Netbackup for Sybase
At this part the Sybase database administrator will provide the Netbackup administrator with the
required schedule of backup according to the business needs including both full database dump and
transaction logs dump, also he will provide the required retention periods for every backup and the sizes
of all databases to be backed up.
Also the Netbackup Administrator will have to calculate the required amount of storage using the data
provided
Required Storage Size = DB size * (Number of Backups during the retention period)
Note from the following queries use the data_used and the log_used as your reference.
Then he will connect to the Sybase database server using ./isql –Usa –SSAP assuming that the Sybase
database server name is SAP
AHMED ATEF 11
Netbackup for Sybase
After connecting and entering the password the following query should be used
use master
go
ceiling(100 * (1 - 1.0 * sum(case when u.segmap != 4 then curunreservedpgs(u.dbid, u.lstart, u.unreservedpgs) end) / sum(case when u.segmap
!= 4 then u.size end))) as data_used_pct,
ceiling(100 * (1 - 1.0 * lct_admin("logsegment_freepages",d.dbid) / sum(case when u.segmap in (4, 7) then u.size end))) as log_used_pct
group by d.dbid
order by db_name(d.dbid)
go
AHMED ATEF 12
Netbackup for Sybase
AHMED ATEF 13
Netbackup for Sybase
Then enters the prober user name and password to connect to the Sybase database server
AHMED ATEF 14
Netbackup for Sybase
go
ceiling(100 * (1 - 1.0 * sum(case when u.segmap != 4 then curunreservedpgs(u.dbid, u.lstart, u.unreservedpgs) end) / sum(case when u.segmap
!= 4 then u.size end))) as data_used_pct,
ceiling(100 * (1 - 1.0 * lct_admin("logsegment_freepages",d.dbid) / sum(case when u.segmap in (4, 7) then u.size end))) as log_used_pct
group by d.dbid
order by db_name(d.dbid)
go
F5 key to execute
AHMED ATEF 15
Netbackup for Sybase
AHMED ATEF 16
Netbackup for Sybase
AHMED ATEF 17
Netbackup for Sybase
Run “su – root” and enter the root password to switch to the root user, then change directory to the
location of Netbackup client software, then extract it using “tar –zxvf file-name.tar.gz”
AHMED ATEF 18
Netbackup for Sybase
After the file is extracted change directory inside the directory extracted and run the “./install” to start
the installation wizard, then input “Y” to continue with the installation wizard.
AHMED ATEF 19
Netbackup for Sybase
After the preinstall checker finishes input “Y” to continue with the installation wizard.
AHMED ATEF 20
Netbackup for Sybase
When the installation wizard prompts you for the Netbackup master server type in the name of your
Netbackup master server and press enter.
AHMED ATEF 21
Netbackup for Sybase
When the installation wizard prompts you for the Netbackup client name make sure the name is correct
and then input “Y” to continue with the installation.
AHMED ATEF 22
Netbackup for Sybase
After the installation ends review the installation progress and make sure there is no errors.
AHMED ATEF 23
Netbackup for Sybase
In case you are using windows then copy the following file from the Netbackup master server
“C:\Program Files\Veritas\NetBackup\DbExt\sybase\libsybackup.dll”
%SYBASE%\ASE-12_*\lib\
Then create the log directories (log directories are mandatory for backup success)
Using terminal the Netbackup administrator will use root user to create the log directories
Run “su – root” and enter the root password to switch to the root user, then creates the log directories
using “/usr/openv/netbackup/logs/mklogdir” and change directory to the location of Netbackup client
software installation directory using “cd /usr/openv/netbackup/”, and finally change the permissions of
the logs directory using “chmod 777 –R logs”
AHMED ATEF 24
Netbackup for Sybase
After creating the logs you will need to configure NetBackup Client for the Sybase database instance.
Using terminal the NetBackup administrator will use root user to execute the following command
Run “su – root” and enter the root password to switch to the root user, then execute
“/usr/openv/netbackup/bin/sybase_config”, And when it prompts you for the Sybase instance home
path input “/opt/sap” assuming that Sybase home is /opt/sap/ then if you have any more instances
input “Y” and input the home directory for every instance and when there is no more instances input
“N” and you are done configuring Netbackup for Sybase database backup.
AHMED ATEF 25
Netbackup for Sybase
Run “su – root” and enter the root password to switch to the root user, then creates the scripts
directory running “mkdir /sybase”, then copies the scripts running
“cp /usr/openv/netbackup/ext/db_ext/sybase/scripts/sybase_mydb_* /sybase” , and finally change the
permissions of the copied scripts running “chmod 777 /sybase/sybase_mydb_*”.
Note according to the security policy you may be using 775 to prevent normal users from executing the
scripts.
AHMED ATEF 26
Netbackup for Sybase
In this example I will be editing the backup script for master database
Using terminal the Netbackup administrator will change directory to the scripts directory running
“cd /sybase” the edit the file using vi tool running “vi sybase_master_backup”
AHMED ATEF 27
Netbackup for Sybase
Then the backup administrator will edit the Sybase database instance home directory in the script using
insert mode by clicking “i” and when done editing presses escape key.
AHMED ATEF 28
Netbackup for Sybase
Then the backup administrator will edit the Sybase database server name in the script using insert mode
by clicking “i” and when done editing presses escape key.
AHMED ATEF 29
Netbackup for Sybase
Then the backup administrator will edit the Sybase database name in the script using insert mode by
clicking “i” and when done editing presses escape key.
AHMED ATEF 30
Netbackup for Sybase
Then the backup administrator will edit the Sybase configuration files backup policy in the script using
insert mode by clicking “i” and when done editing presses escape key.
The configuration files backup policy is a user backup policy used to backup the Sybase configuration
files after a successful database full dump.
AHMED ATEF 31
Netbackup for Sybase
Then the backup administrator will edit the Sybase configuration files location in the script using insert
mode by clicking “i” and when done editing presses escape key.
The configuration files location is where you find “(Server Name).cfg” file which in this case
“/opt/sap/ASE-16_0” assuming that “/opt/sap” is the home directory.
AHMED ATEF 32
Netbackup for Sybase
Then the backup administrator will edit the Sybase automatic database dump schedule name in the
script using insert mode by clicking “i” and when done editing presses escape key.
In this case my Sybase automatic database dump schedule name was “FULL” marked in red.
Note any other automatic schedule name will run a transaction log backup.
AHMED ATEF 33
Netbackup for Sybase
Then the backup administrator will edit the Sybase application backup schedule name in the script using
insert mode by clicking “i” and when done editing presses escape key.
AHMED ATEF 34
Netbackup for Sybase
Then the backup administrator will edit the Sybase user name and password used for backup in the
script using insert mode by clicking “i” and when done editing presses escape key.
AHMED ATEF 35
Netbackup for Sybase
Then the backup administrator will edit the Sybase stripe configuration in the script using insert mode
by clicking “i” and when done editing presses escape key.
Replace "Default-Application-Backup" with the Application Backup Schedule name used for database
backup
Copy the line as many times as the No. of Streams you want to use
Notes
Do not use too many streams it may affect the performance of SAP Server (use 8 Streams for Example).
AHMED ATEF 36
Netbackup for Sybase
The marked if statement below is for the backup of Sybase configuration file after a successful database
dump, just hash it as below in every database backup script except for the master database, as you do
not want to backup the same configuration files as many times as the number of databases you have.
After the editing is done you will press escape key to exit insert mode then input “:wq” and press enter
to write changes and exit vi editing tool.
AHMED ATEF 37
Netbackup for Sybase
AHMED ATEF 38
Netbackup for Sybase
With three schedules, the first is “Application Backup” schedule created by default named “Default-
Application-Backup” and the retention in this backup is the applied retention, the second is “Automatic
Backup” schedule named “FULL” as in the backup script and it is for database dump, the third is also
“Automatic Backup” schedule named “TL” or any other name except for “FULL” that we used in the
backup script and it is for transaction log dump.
AHMED ATEF 39
Netbackup for Sybase
AHMED ATEF 40
Netbackup for Sybase
AHMED ATEF 41
Netbackup for Sybase
AHMED ATEF 42
Netbackup for Sybase
With a “User Backup” schedule named “Full” or any name you want.
Note this schedule is called by the backup script after a successful database dump only.
AHMED ATEF 43
Netbackup for Sybase
AHMED ATEF 44
Netbackup for Sybase
With “/opt/sap/ASE-16_0” as the backup selection assuming that “/opt/sap” is the Sybase home.
AHMED ATEF 45
Netbackup for Sybase
But no worries, the restore is not that hard you will just have to be prepared.
First list available backups and prepare a template restore and load scripts and learn how to use them.
Second In situation of database does not exist, create a new empty one with the proper size.
After this step you will be ready to execute the restore, but if you do not have a database to restore to
you will have to create a new one for the restore process.
AHMED ATEF 46
Netbackup for Sybase
Using terminal the Sybase database administrator will change directory to “/usr/openv/netbackup/bin”,
then executes “./bplist –S nbusrv.nbu.loc –C sap –t 7 –R /”, this will list all the available Sybase database
backups, Below is explanation for the command and the output
bplist –S nbusrv.nbu.loc -C SAP -t 7 -R /
"Backup Server Name" "Sybase Backed up Server Name" "Policy Type Sybase (7)"
/"Server Name" . "Database Name" . "Data Dump (D) or Transaction Dump (T) . "Strip No. " . "Backup ID" . "Backup Date &Time"
AHMED ATEF 47
Netbackup for Sybase
Using terminal the Sybase database administrator will change directory to “/sybase” running “cd
/sybase” then edit the restore script using vi editing tool running “vi sybase_mydb_restore”.
In the vi editing tool he will use the insert mode by pressing “i” key to edit the sybase home directory
then pressing escape key to exit the editing mode.
AHMED ATEF 48
Netbackup for Sybase
The Sybase database administrator will use the insert mode by pressing “i” key to edit the Sybase Server
name then pressing escape key to exit the editing mode.
AHMED ATEF 49
Netbackup for Sybase
The Sybase database administrator will use the insert mode by pressing “i” key to edit the loaddb script
location then pressing escape key to exit the editing mode.
Note that the load database is already copied to “/sybase” in a previous step.
AHMED ATEF 50
Netbackup for Sybase
The Sybase database administrator will use the insert mode by pressing “i” key to edit the user name
and password used for restore then pressing escape key to exit the editing mode.
After the editing is done you will press escape key to exit insert mode then input “:wq” and press enter
to write changes and exit vi editing tool.
AHMED ATEF 51
Netbackup for Sybase
Using terminal the Sybase database administrator will change directory to “/sybase” running “cd
/sybase” then edit the load script using vi editing tool running “vi sybase_mydb_load”.
In the vi editing tool he will use the insert mode by pressing “i” key to edit the destination database for
full database dump restore then pressing escape key to exit the editing mode.
AHMED ATEF 52
Netbackup for Sybase
In the vi editing tool he will use the insert mode by pressing “i” key to edit the database dump backup ID
for restore then pressing escape key to exit the editing mode.
Note in case you did not use stripes in backup you will only need that line without the “stripe on” lines.
AHMED ATEF 53
Netbackup for Sybase
In the vi editing tool he will use the insert mode by pressing “i” key to edit the Stripe on lines according
to the backup set available then pressing escape key to exit the editing mode.
Note in this case backup stripes are 8 starting 1 to 8 with the database dump backup ID stripe number 0.
AHMED ATEF 54
Netbackup for Sybase
In the vi editing tool he will use the insert mode by pressing “i” key to edit the destination database for
transaction log restore then pressing escape key to exit the editing mode.
AHMED ATEF 55
Netbackup for Sybase
In the vi editing tool he will use the insert mode by pressing “i” key to edit the database transaction log
backup ID for restore then pressing escape key to exit the editing mode.
Note in case you did not use stripes in backup you will only need that line without the “stripe on” lines.
The database transaction log dump will always have stripe ID “0”.
AHMED ATEF 56
Netbackup for Sybase
In the vi editing tool he will use the insert mode by pressing “i” key to edit the Stripe on lines according
to the backup set available then pressing escape key to exit the editing mode.
Note in this case backup stripes are 8 starting 1 to 8 with the database transaction log dump backup ID
stripe number 0.
AHMED ATEF 57
Netbackup for Sybase
In the vi editing tool he will use the insert mode by pressing “i” key to edit the database name to be
online then pressing escape key to exit the editing mode.
After the editing is done you will press escape key to exit insert mode then input “:wq” and press enter
to write changes and exit vi editing tool.
AHMED ATEF 58
Netbackup for Sybase
From Terminal the Sybase Database Administrator will Change directory to /opt/sap/OCS-16_0/bin/
assuming that Sybase home is /opt/sap/
Then he will connect to the Sybase database server using ./isql –Usa –SSAP assuming that the Sybase
database server name is SAP
AHMED ATEF 59
Netbackup for Sybase
After connecting and entering the password a similar query should be used
use master
go
disk init
size = ########
go
disk init
size = ########
go
Create the data base pointing at the devices that you created
AHMED ATEF 60
Netbackup for Sybase
From Terminal the Sybase Database Administrator will run /opt/sap/DBISQL-16_0/bin/dbisql assuming
that Sybase home is /opt/sap/
AHMED ATEF 61
Netbackup for Sybase
Then enters the prober user name and password to connect to the Sybase database server
AHMED ATEF 62
Netbackup for Sybase
go
disk init
size = ########
go
disk init
size = ########
go
Create the data base pointing at the devices that you created
F5 key to execute
AHMED ATEF 63
Netbackup for Sybase
AHMED ATEF 64
Netbackup for Sybase
AHMED ATEF 65
Netbackup for Sybase
AHMED ATEF 66
Netbackup for Sybase
Troubleshooting
This is the funny part that I love, I know that some of you disagree with me, but this is the part you get
to know how Netbackup works in the background and become an expert.
Whenever you have backup or restore issues “/usr/openv/netbackup/logs/bphdb” log directory is your
friend
Also for backup progress you may use “/usr/openv/netbackup/logs/sybackup” log directory.
AHMED ATEF 67