copydb(1sql)
Name
copydb − creates command files to copy out a database and restore it.
Syntax
copydb [options] dbname [ tablename]...
Description
The copydb command creates two sql command procedures in the current directory:
copy.out Contains instructions to copy the entire database or selected tables into files. Note that table access is subject to privileges granted the user running copydb.
copy.in Contains instructions to use the files created by copy.out to create tables and indexes and perform database modifications.
Note that execution of the copydb command does not restore a database but rather creates sql command procedures that you run to restore a database. Specify the copy.in and copy.out files as input to the sql command (see the examples). The name of each file that is created when you run copy.out consists of the name of the table whose data is being copied, truncated to eight characters if necessary, followed by an extension made up of the first three letters of the owner’s login name. If a file name created using the preceding rules is not unique, a digit replaces the last character of the table name segment to make the file name unique.
Options
Options perform functions as follows:
−uusername
Run copydb as the user specified by username. Only the user who created the database (DBA) or an ULTRIX/SQL superuser (system administrator) can specify the −u option. The fact that the copydb command creates the copy.out and copy.in files does not necessarily mean that all specified tables are copied because table access is subject to permissions that apply to username.
−dpathname
Stores the copy.in and copy.out files in the directory specified by pathname rather than the current directory. You can specify a directory using either a full or relative pathname.
−cCauses the commands in the sql command procedures to assume a data file format that is portable across VAX and RISC systems, which have different internal representation of non-ASCII data. In other words, the copy.out procedure copies out all data as ASCII characters when you specify the −c option. Note that when you run the copy.in procedure, it automatically converts data stored as ASCII characters back to the appropriate ULTRIX/SQL data type defined for each table column.
Restrictions
You cannot copy system catalogs using copydb. Use unloaddb to copy a complete database, including system catalogs.
Because the files created by copy.in and copy.out have the same names as table files that are part of the source database, the directory location of files created by the copy.out must not be the same as the directory location for dbname.
Because tables and indexes created by running the copy.in procedure are new, be sure to run the sysmod utility to create for those tables and indexes any storage structures required for optimal performance.
After you run the copy.out procedure, do not work on the database (for example, create new tables or dependent forms and applications) until you restore the database by running copy.in.
Examples
Set current directory to location of choice. Create the copy.out and copy.in procedures for database mydb, run copy.out to create files in the current directory, use tar to move those files to the default tape device /dev/rmt0h, and delete the files in the current directory:
cd /usr/mydir/backup
copydb mydb
sql mydb < copy.out
tar c .
rm *
Set current directory to location of choice. Copy files from tape to disk, and then run copy.in to restore files to the database mydb:
cd /usr/mydir/backup
tar xrpf /dev/rmt0h
sql mydb < copy.in
sysmod mydb
Files
$II_DATABASE/ingres/data/default/dbname
Default path for database files associated with dbname. The default location ii_database is mapped to this directory.
See Also
tar(1), intro(1sql), sql(1sql), unloaddb(1sql), intro(8sql), sysmod(8sql)
ULTRIX/SQL Database Administrator’s Guide