Backup Restore
Backup Restore
Backup Restore
MODULE TOPICS
Backup
10 - 2
Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
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
10 - 3
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
10 - 5
Archive Devices
Archive devices can be either disk or magnetic tape drives
Disk backups must go to file systems, not raw devices
Supported tape devices:
10 - 6
Sybase IQ 15 Additions
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
DBSPACES | FILES
Sybase IQ 15.0 introduces the concept and implementation of
one or more dbfiles within a dbspace
Accommodates the architectural enhancement
Dbfiles are not present in Sybase IQ 12.7
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
the archive file
Must use separate TO clauses if using multiple archive
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
saved to the archive device(s)
10 - 11
Continued
Backup Options
VIRTUAL DECOUPLED
Specifies a decoupled virtual backup
For the backup to be complete:
VIRTUAL ENCAPSULATED
Specifies an encapsulated virtual backup
shell-command argument can be a string or variable
containing a string executed as part of the encapsulated
virtual backup
Shell commands execute a system-level backup of the IQ
Store as part of the backup operation
10 - 12
Archive Options
SIZE (KB)
Maximum size of the backed up data on that stripe
Should specify for unattended tape backups on platforms that
do not reliably detect the end-of-tape marker
Should also specify whether backup to disk is not the default
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
Example:
BACKUP DATABASE
INCREMENTAL
TO '/dev/rmt/0n' SIZE 15000
WITH COMMENT 'March 17 incremental backup of mydb
database'
10 - 14
Syntax:
sp_iqcheckdb 'mode target[ ][resources resourcepercent]'
10 - 15
MODULE TOPICS
Backup
10 - 25
Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
Restore Features
Allows parallel restore using multiple tape drives
Can restore full database
Can restore from incremental database backup
Can restore to a new location
10 - 26
Before a Restore...
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
Transaction Log must exist
For restoring a multiplex database, the server must be started
with the multiplex override switch, -iqmpx_ov 1
10 - 27
RESTORE DATABASE
Syntax:
RESTORE DATABASE 'database-name'
[ restore-option ... ]
FROM 'archive_device' ...
restore-option:
Version 15.0 only
READONLY dbspace-or-file [, ]
KEY key_spec
RENAME file-name TO new-file-path ...
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
10 - 29
Examples
RESTORE statement 1:
RESTORE DATABASE 'iqdemo'
READONLY DBSPACES iq_main FROM '/system1/IQ15/IQ15_0/demo/backup/iqmain'
RESTORE statement 2:
RESTORE DATABASE 'iqdemo'
FROM '/system1/IQ15/IQ-15_0/demo/backup/iqmain'
10 - 30
10 - 31
Continued
10 - 33
Selective Backup
10 - 34
10 - 35
10 - 36
10 - 37
Main IQ Blocks
Used
output gives size of
compressed data
Use
19089 * 4096 +
catalog store =
Total Bytes
10 - 38
MODULE TOPICS
Backup
10 - 39
Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
sp_iqbackupsummary
Summarizes backup operations performed
DBA authority required
Syntax:
sp_iqbackupsummary [timestamp]
10 - 40
Column descriptions:
10 - 41
Column name
Description
backup_id
backup_time
backup_type
selective_type
virtual_type
depends_on_id
creator
backup_size
user_comment
User comment
backup_command
sp_iqbackupdetails
Shows all the dbfiles backed up in a particular backup
specified by its transaction identifier
DBA authority required
Syntax:
sp_iqbackupdetails [backup_id]
10 - 42
Column descriptions:
Column name
Description
backup_id
backup_time
backup_type
selective_type
dbspace_name
dbspace_rwstatus
dbspace_size
dbspace_backup_size
dbfile_id
dbfile_name
The logical file name if it was not renamed after the backup operation. If renamed,
null.
dbfile size in MB
dbfile_backup_size
dbfile_path
The dbfile path from ISYSBACKUPDETAIL, if it matches the physical file path
(file_name) in ISYSDBFILE for a given dbspace_id and the dbfile_id. Otherwise null.
10 - 43
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
state for the timestamp
10 - 44
MODULE TOPICS
Backup
10 - 45
Restore
Diagnostic Stored Procedures
Utilities: dblog and db_backupheader
dblog Utility
Syntax:
dblog [options] database-file
10 - 46
Continued
dblog Utility
Example:
10 - 47
demolog.log
iqdemo
db_backupheader
Syntax:
db_backupheader <first backup file>
10 - 48
Continued
db_backupheader
Partial sample:
IQ Backup Header Display of File: "iqdemo.bu.1"
Volumn Header: "VOL10000014"
Header 1: "HDR1000000000000000000000000000000000"
Header 2: "HDR2D000000000000"
Backup Data Record:
DB Name: "iqdemo.db"
DB Type: "ASIQ"
Current Backup ID: "28683"
Depends On ID: "0"
Last Full ID: "0"
Creation Date: "2009-06-16 00:59:00.000"
10 - 49
Continued
db_backupheader
Partial sample:
Creator: "DBA"
Total Tapes: "1"
Backup Type: "Full"
Media: "Othr"
Backup Version: "6"
Backup Method: "Arch"
Backup Location: "/home/sybase/iqdemo.bu"
Filler: 0x0
Backup Data Record Extended:
...
10 - 50
dbbackup Utility
Makes a copy of the IQ Transaction Log
Syntax:
10 - 51
dbbackup Options
10 - 52
Option
Description
@data
-l (lowercase L) file
-q
-r
-xo filename
10 - 53
If the primary machine becomes unusable, you can restart your database
using the secondary machine
Database file and the transaction log hold the information needed to
restart
Module Summary
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
of IQ to perform maintenance tasks such as sp_iqcheckdb
10 - 55