Backup Restore
Backup Restore
10 - 2
Two Ways To Backup Sybase IQ Data
Database backup
Full backup – makes a complete copy of the database
incremental backup – copies all transactions since the last
backup of any type – copies all transactions since the last full
Incremental-since-full backup
backups
Can run concurrently with other database operations, except
metadata changes
The process backs up committed data
10 - 3
Database Backup Methods
Full
Full backup of Catalog Store
Full backup of IQ Store
Default action
Incremental
Full backup of Catalog Store
Backs up changes to IQ Store since last backup of any type
Incremental-since-full
Full backup of Catalog Store
Backs up changes to IQ Store since last full backup
10 - 4
Backup Process Steps
First, the Catalog Store (dbname.db) is backed up for a database, then
the transaction log file (dbname.log – only when the database is SA),
and then all the dbspace files for the IQ Store
10 - 5
Archive Devices
Archive devices can be either disk or magnetic tape drives
Disk backups must go to file systems, not raw devices
8mm
10 - 6
BACKUP DATABASE Syntax
BACKUP DATABASE
Sybase IQ 15 Additions
... { READWRITE FILES ONLY |
READONLY dbspace-or-file [, …]}
... [CRC ON | OFF]
... [ATTENDED ON | OFF]
... [BLOCK FACTOR integer]
... [{FULL|INCREMENTAL|INCREMENTAL SINCE FULL}]
... [ { VIRTUAL DECOUPLED |
VIRTUAL ENCAPSULATED 'shell_command' } ]
... TO 'archive_device' [SIZE #_of_KB integer ]
[ STACKER #_of_tapes_in_stack integer ] ...
... [WITH COMMENT ’string’]
10 - 7
Which Files and Where
DBSPACES | FILES
Sybase IQ 15.0 introduces the concept and implementation of
one or more dbfiles within a dbspace
Accommodates the architectural enhancement
TO
Specifies the name of the archive_device to be used for
backup, delimited with single quotation marks
Archive_device is a file name or tape drive device name for
devices
10 - 9
Attended/Unattended
Attended
Operator must be present
Prompts to mount archive media
Default action
Unattended
No prompts are issued
Must make appropriate size estimates and set up devices in
advance
10 - 10
Backup Options
FULL
Specifies a full backup and is the default action
All blocks in use in the database are saved to the archive
device(s)
INCREMENTAL
Specifies an incremental backup
All blocks changed since the last backup of any kind are
10 - 11 Continued …
Backup Options
VIRTUAL DECOUPLED
Specifies a decoupled virtual backup
For the backup to be complete:
Copy the IQ dbspaces after the decoupled virtual backup
finishes
And then perform a non-virtual incremental backup
VIRTUAL ENCAPSULATED
Specifies an encapsulated virtual backup
‘shell-command’ argument can be a string or variable
of 2GB
STACKER
Indicates that Sybase IQ is being backed up to an
automatically loaded multitape stacker device
Specify the number of tapes in that device
10 - 13
Simple Backup Examples
Example:
BACKUP DATABASE
INCREMENTAL
TO '/dev/rmt/0n' SIZE 15000
WITH COMMENT 'March 17 incremental backup of mydb
database'
Makes a full backup of the database to one tape device
Catalog Store is backed up first, then the IQ Store
Example using new syntax introduced in Sybase IQ 15 that shows a
backup of dbspace and dbfiles:
BACKUP DATABASE READONLY DBSPACES dsp2, dsp3
READONLY FILES dsp4_f1, dsp5_f2 TO ‘bkp.RO’
Take note that the keyword INCREMENTAL is not allowed with
READONLY FILES
10 - 14
Validating the Database
Should run sp_iqcheckdb before a backup to make sure the
database is in a usable state
Syntax:
sp_iqcheckdb 'mode target[ …][resources resource-
percent]'
10 - 15
Backup
MODULE TOPICS Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
10 - 25
Restore Features
Allows parallel restore using multiple tape drives
Can restore full database
10 - 26
Before a Restore...
Must have Database Administrator privileges
Must have exclusive access
Set using the switch: -gd DBA
Must be connected to the utility_db database as DBA
No user can be connected to the database being restored
For a full restore, the Catalog Store and the Transaction Log
(.db and .log files) must not exist
For an incremental restore, the Catalog Store and the
characters
10 - 28 Continued …
RESTORE DATABASE
RENAME option
Specifies a dbspace (in 12.7) or a dbfile (in 15.0) to be created
on a different path
Cannot rename the transaction log using this option
To move or rename the log file use the DBLOG utility
10 - 29
Examples
BACKUP statement and two possible RESTORE statements:
BACKUP DATABASE
READONLY DBSPACES iq_main TO '/system1/IQ15/IQ-
15_0/demo/backup/iqmain'
RESTORE statement 1:
10 - 31
Continued …
Moving Database Files
To move any database file other than the catalog store
Identify the files using sysfile
Back up the database
10 - 33
Selective Backup
Backs up either all READWRITE dbspaces or specific
READONLY dbspaces or dbfiles
Can take a READONLY selective backup and restore all
objects from this backup
Can take an all-inclusive backup and restore read-only files
10 - 34
Dealing with Restore Failures
Key point! Restore operation is not transactional
If restore fails mid-way, the files restored until that point may not
be in consistent state
If the files restored are inconsistent, the operation must be
10 - 36
IQ Backup and Restore Performance
Multiple tape drives provide the best performance
Set CRC OFF in the BACKUP command to improve the
10 - 37
Estimating Dump Size
Sybase IQ backs up
compressed data (no
zeros)
sp_iqstatus
Main IQ Blocks
Used
output gives size of
compressed data
Use
19089 * 4096 +
catalog store =
Total Bytes
10 - 38
Backup
MODULE TOPICS Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
10 - 39
sp_iqbackupsummary
Summarizes backup operations performed
DBA authority required
Syntax:
sp_iqbackupsummary [timestamp]
timestamp specifies the interval for which to report backup
operations
If a timestamp is specified, the procedure returns only those
records with bu_time greater than or equal to that time
If no timestamp is specified, the procedure returns all the
10 - 40
Summary Information Detail
Column descriptions:
Column name Description
backup_id Identifier for the backup transaction
Syntax:
sp_iqbackupdetails [backup_id]
backup_id specifies the backup operation transaction identifier
10 - 42
Detail Information Retrieved
Column descriptions:
Column name Description
backup_id Identifier for the backup transaction.
backup_time Time of the backup.
backup_type Type of backup: “Full,” “Incremental since incremental,” or “Incremental since full.”
selective_type Subtype of backup: “All,” “All RW files,” or “RO file.”
dbspace_name Name of the dbspace from ISYSIQBACKUPHISTORYDETAIL. If it matches the
dbspace name in ISYSDBSPACE for a given dbspace_id. Otherwise “null.”
dbspace_rwstatus “ReadWrite” or “Read Only.”
dbspace_size Size of dbspace at time of backup in MB.
dbspace_backup_size Size of data backed up in the dbspace.
dbfile_id Identifier for the dbfile
dbfile_name The logical file name if it was not renamed after the backup operation. If renamed,
“null.”
dbfile size in MB Size of the dbfile, in MB
dbfile_backup_size Size of the dbfile backup, in MB
dbfile_path The dbfile path from ISYSBACKUPDETAIL, if it matches the physical file path
10 - 43 (‘file_name’) in ISYSDBFILE for a given dbspace_id and the dbfile_id. Otherwise “null.”
sp_iqrestoreaction
Shows what restore actions are needed to bring database to
a consistent state with a given past date
Syntax:
sp_iqrestoreaction [ timestamp ]
Result Information:
When successful, suggests restore actions that will return the
database to a consistent state
Returns an error if database cannot be brought to a consistent
10 - 44
Backup
MODULE TOPICS Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
10 - 45
dblog Utility
Utility program to manipulate the transaction log for your
database file (.log file)
The executable will be in the path
Syntax:
dblog [options] database-file
Use dblog to:
Create a new transaction log
Recommended after a successful restore as a matter of routine
Start or Stop a mirror for the transaction log
The database must run with a transaction log
10 - 46
Continued …
dblog Utility
dblog Switches Options
-t log-name (Set the transaction log name)
-m mirror-name (Set transaction log mirror name)
Example:
Start a new database transaction log for iqdemo
dblog –t demolog.log iqdemo
10 - 47
db_backupheader
Utility used to read the backup archive file
It does not connect to the database
Syntax:
db_backupheader <first backup file>
The backup archive information includes:
Backup information
Database information at the time of the backup
Creator: "DBA"
Total Tapes: "1"
Backup Type: "Full"
Media: "Othr"
Backup Version: "6"
Backup Method: "Arch"
Backup Location: "/home/sybase/iqdemo.bu"
Filler: 0x0
10 - 50
dbbackup Utility
Makes a copy of the IQ Transaction Log
Syntax:
10 - 51
dbbackup Options
Option Description
@data Read options from the specified environment variable or
configuration file
-c "keyword=value; ... " Supply database connection parameters
-l (lowercase L) file Live backup of the transaction log to a file
-q Quiet mode — do not print messages
-r Copy the old transaction log to a new name and start a
new empty log
-xo filename Truncate (delete and restart) the transaction log
10 - 52
Live Backup of Transaction Log
Must use option –l (lowercase L)
Install and configure Sybase IQ on the secondary machine
Periodically, make a full backup to the secondary machine
Run a live backup of the transaction log to the secondary machine
using:
dbbackup -l path\filename.log –c
"connection_string“
10 - 53
Module Summary
During the course of this module, you have learned:
How to do develop a data backup and restore strategy
How to schedule routine backups
Mixing full and incremental backups
Restores should be tested on a periodic basis
How to use sp_iqcheckdb to validate the database before a
db_backupheader
10 - 54
Continued …
Module Summary
Methodology for using technology provided by some SAN
manufacturers to "mirror" a Sybase IQ database which can be
used in lieu of a full database backup
The shadow devices and files can be used to start an instance
10 - 55