Before you can restore a database, make sure that the following conditions are met:
You must have DBA privileges.
To restore read-only files or dbspaces from an archive backup, the database may be running and the administrator may connect to the database when issuing the RESTORE statement. The read-only file pathname need not match the names in the backup, if they otherwise match the database system table information.
The database must not be running to restore a FULL, INCREMENTAL SINCE FULL, or INCREMENTAL restore of either a READWRITE FILES ONLY or an all files backup.
The database may or may not be running to restore a backup of read-only files. When restoring specific files in a read-only dbspace or read-only files in a read-write dbspace except for IQ_SYSTEM_MAIN, the dbspace must be offline. This restriction does not apply to IQ_SYSTEM_MAIN. Selective restore can be used to restore a read-only dbspace, as long as the dbspace is still in the same read-only state.
To restore all files in a database or from a read-write files only backup, you must be connected to the utility_db database. For information on utility_db and how to set privileges for using it, see the Installation and Configuration Guide for your platform. For instructions on starting utility_db, see “Utility database server security”.
When restoring all the files in the database or from a read-write files only backup, no user can be connected to the database being restored. RESTORE exits with an error if there are any active Read Only or Read/Write users of the specified database.
Sybase recommends that you use two startup switches to restrict connections:
Use -gd DBA so that only users with DBA authority can start and stop databases on a running server. (Note that the client must already have a connection to the server to start or stop the database, so this switch does not prevent connections.)
Use -gm 1 to allow a single connection plus one DBA connection above the limit so that a DBA can connect and drop others in an emergency.
An alternate way to restrict connections is to specify
sa_server_option('disable_connections', 'ON')
just after you start the connection where you are restoring and
sa_server_option('disable_connections', 'OFF')
on the same connection after restoring. The disadvantage is that this method precludes emergency access from another DBA connection.
You must restore the database to the appropriate server, and that server must have the archive devices you need. When you use the Sybase-provided restore, you need the same number of archive devices (that is, the disk files or tape drives) as when the backup was created.
For a full restore, the catalog store (by default the .db file) and the transaction log (by default the .log file) must not exist in the location you are restoring to. If either of these files exists, you must delete it or move it to a different directory before doing the full restore.
When a full restore begins, it destroys all old database files and then recreates them. The requirement that you manually delete the catalog store and transaction log files protects you from doing a full restore accidentally.
For any incremental restore, the catalog store (.db) must exist. If it exists, but in a different location than the one you are restoring to, you must follow the procedure described in “Moving database files”. If it does not exist, you can only do a full restore. (If you do a full restore before any incremental restore, the correct files will be in place.)
For any incremental restore, the database must not have changed since the last restore.
Restore requires exclusive access to the database and to the server. To gives the DBA greater control over inadvertent opens of the database., start the database server with the -gd DBA option set, but do not start the database you are restoring. RESTORE automatically starts the database in such a way that no other users can connect to it.
You must restore an entire backup or set of backups, including the full backup and all subsequent incremental backups. Restoring individual files from a backup archive is supported for read-only dbspaces and files alone. However, you can move database files to a new location using the RENAME clause of the RESTORE command.