Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > B

BACKUP (Short name: BAC)

Scroll Prev Top Next More

Use the BACKUP command to copy the data and/or structure of a database to floppy disks or another directory on your hard disk. The BACKUP command is very much like the UNLOAD command, only it supports the ability to span multiple diskettes when backing up databases to a floppy drive. With the many various backup software packages, or by simply performing file copies, the BACKUP command has become antiquated.

 

BACKUP

 

Options

 

ALL

Backs up the entire structure and data of the current database.

 

DATA

Backs up just the data of the current database.

 

FOR tblname

Specifies a single table to backup. If this clause is not used, all tables in the database are backed up.

 

FOR tblview

Specifies a table or view to backup. If this clause is not used, all tables and views in the database are backed up.

 

ORDER BY clause

Sorts rows of data. For more information, see ORDER BY.

 

STRUCTURE

Backs up just the structure of the current database.

 

USING collist

Specifies the columns to backup and in what order to back them up. USING ALL backs up all columns in the order they are defined in the table.

 

WHERE clause

Limits rows of data. For more information, see WHERE.

 

About the BACKUP Command

 

The BACKUP command backs up data and/or structure to a backup file in the ASCII delimited format, which you can edit with a text editor. For example, you can restore the structure or data from one database to a new database, then edit the backup file with a text editor to change the database name to a new one.

 

BACKUP does not backup computed-column values; the values will be computed when the database is restored.

 

BACKUP does not change the data or the structure in the original database. Use the RESTORE command to restore your data.

 

If a BACKUP command is included in a transaction when transaction processing is on, the backup cannot be rolled back.

 

The BACKUP command creates a file with a .LOB extension for binary large objects, and a file for the data and/or structure.

 

SET Special Characters and Operating Conditions

 

To properly restore a database, BACKUP places the settings for the SET special characters and operating conditions used in the database at the beginning of the ASCII backup file. Within the backup file, object names, such as table names, will be enclosed within the IDQUOTES character. The current setting for DELIMIT is used to separate values. Text strings are enclosed in the current setting of QUOTES. And, the current value of WIDTH affects the width of data lines in the backup file. To view your database character and display settings, select "Settings" > "Configuration Settings" from the main menu bar.

 

The following are three tips that will ensure your database is restored from a backup properly:

 

Set the null symbol to -0- (the R:BASE default) before backing up.

Do not set a special character to the same setting as another special character.

For best results backing up, keep all the default settings.

 

Backing Up to Disks

 

When you backup data to floppy disks, use blank formatted disks. The backup file can span multiple floppy disks. If BACKUP fills a disk, it prompts you to enter a new disk before continuing.

 

Note: So that you don't mix up the disks, label and number them as you remove them.

 

If you are backing up to a hard disk and the disk becomes full, press [Esc] to stop the backup. You can either free up hard disk space before backing up again, or backup to floppy disks.

 

It is worth noting that even when using R:BASE for Windows you will need to issue this command at the R> Prompt or via a command file.

 

Note: Backing Up to Floppy Disks is not recommended when using any 6.x, or higher, versions of R:BASE.

 

Using the BACKUP Command

 

When you backup your data, use the OUTPUT command to specify the filename of the backup. The BACKUP command does not erase files on a floppy disk, but overwrites a file if the filename you specify already exists on the disk. For examples of how to use the OUTPUT command, see the OUTPUT reference.

 

You can backup a database in one of the following ways:

 

Backup both the structure and data.

Backup only the structure.

Backup only the data.

 

The following is information about each method.

 

Backing Up the Structure and Data

 

Use the BACKUP ALL command to backup the structure and data in the current database, or the structure and data for a specific table. You can backup a database structure and data to separate files if you prefer two smaller files to one large file. BACKUP writes all the commands necessary to define the database or table, starting with the CREATE SCHEMA AUTHORIZATION dbname command near the beginning of the file.

 

BACKUP uses the LOAD command to load the data.

 

If the database is protected by the database owner's user identifier, BACKUP ALL requires the owner's user identifier, which R:BASE places in the backup file to ensure that the restored database file continues to be protected. Keep the backup file from unauthorized users to ensure the database file remains protected.

 

Backing Up the Structure Only

 

Use the BACKUP STRUCTURE command to backup just the structure of the current database, or the structure of a specific table. BACKUP writes all the commands necessary to define the database or table, starting with the CREATE SCHEMA AUTHORIZATION dbname command near the beginning of the file. Any collating or case-folding table defined by the database owner is automatically preserved.

 

Keep the backup file from unauthorized users to ensure the database file remains protected. If the database is protected by an owner's user identifier, BACKUP STRUCTURE requires the owner's user identifier, which R:BASE places in the backup file to ensure that the restored database file continues to be protected.

 

Backing Up Data Only

 

Use the BACKUP DATA option to backup the data in the current database or the data in a specific table. BACKUP uses the LOAD command to load the data. Also, use the BACKUP DATA option to backup any custom information stored in R:BASE system tables such as forms, reports, labels and stored procedures.

 

Examples

 

The following command lines backup the structure and data for every table in the open database to the MYDB.BUP file on drive A:, redirect the output to the screen, and close the file.

 

OUTPUT a:mydb.bup

BACKUP ALL

OUTPUT SCREEN

 

The command lines below backup the data and structure of the customer table to the CUSTOMER.BUP file, limit the rows to those that are dated after 10/1/89, and order the rows by custid.

 

OUTPUT customer.bup

BACKUP ALL FOR customer WHERE datecol > 10/1/89 ORDER BY custid

OUTPUT SCREEN

 

The following command lines backup the structure of the customer table to the CUSTSTRC.BUP file, redirect the output to the screen, and close the file.

 

OUTPUT custstrc.bup

BACKUP STRUCTURE FOR customer

OUTPUT SCREEN

 

The following command lines backup the data from the producttable to the PRODUCT.BUP file, redirect the output to the screen, and close the file.

 

OUTPUT product.bup

BACKUP DATA FOR product

OUTPUT SCREEN

 

The following command lines show how to transfer a form to a new database. The first five command lines open the olddb database, set the null value to -0-, create the TEMPFORM.DAT file on drive D:, backup the data from the sys_forms2 table that contains the definition of the oldform form, and redirect the output to the screen. Command lines six through eight open the newdb database in order to transfer the oldform form definition (the database you open must not have a form named oldform), set the null value to -0-, and load the form definition from the backup file into the sys_forms2table.

 

CONNECT olddb

SET NULL -0-

OUTPUT d:tempform.dat

BACKUP DATA FOR SYS_FORMS3 WHERE SYS_FORM_NAME = 'oldform'

OUTPUT SCREEN

CONNECT newdb

SET NULL -0-

RUN d:tempform.dat