Before you can restore a database, make sure that the following conditions are met:
You must have DBA privileges.
The server and database that you wish to restore must be shut down.
You must be connected to the utility_db database. For information on utility_db and how to set privileges for using it, see the Sybase IQ Installation and Configuration Guide for your platform. For instructions on starting utility_db, see “Creating a database with SQL”.
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. Restoring individual files is not supported. However, you can move database files to a new location, using the RENAME clause of the RESTORE command.