Sun Java System Calendar Server 6.3 Administration Guide

16.2 Administering Databases with the csdb Utility

This section describes how to use the D.8 csdb utility to perform the following administrative tasks:


Note –

To run the csdb utility, you must log in as a user who has administrative rights to the system where Calendar Server is running. For more information, see Appendix D, Calendar Server Command-Line Utilities Reference.


ProcedureTo List Status for a Database Group

To view the status of a database group (caldb, sessdb, statdb), use the csdb utility list command.

To list database status:

  1. Log in as a user who has administration rights to the system where Calendar Server is installed.

  2. Calendar Server can be either running or stopped; however, if possible, stop Calendar Server.

  3. Change to the /sbin directory. For example, on Solaris Operating Systems, enter:

    cd /opt/SUNWics5/cal/sbin

  4. Run the list command against one or all of the database groups. For example, to list the status and statistics for all three database groups:

    ./csdb list

    The code that follows shows sample output:


    Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002)
    
    Calendar database version: 3.0.0 [BerkeleyDB]
    Total database size in bytes: 57344
    
    Session database version: 1.0.0 [BerkeleyDB]
    Total database size in bytes: 0
    
    Counter database version: 1.0.0 [Memory Mapped Files]
    Total database size in bytes: 118792
    
                   

    Or, you can choose to use the verbose mode. For example:

    ./csdb -v list

    The following sample code shows the verbose output:


    Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002)
    
    Calendar database version: 3.0.0 [BerkeleyDB]
    Total database size in bytes: 57344
    Total number of calendars:    2
    Total number of events:       0
    Total number of tasks:        0
    Total number of alarms:       0
    Total number of gse entries:  0
    Total number of master component entries:  0
    Total number of deletelog entries:  0
    Total logfile size in bytes:  5779919
    
    Session database version: 1.0.0 [BerkeleyDB]
    Total database size in bytes: 0
    Total logfile size in bytes:  0
    
    Counter database version: 1.0.0 [Memory Mapped Files]
    Total database size in bytes: 118792
    
                   

    Or, use the -t option to specify one target database group (caldb, sessdb, or statdb). For example, to view database status and statistics for only the calendar database:

    csdb -t caldb list

ProcedureTo Check for Corruption in the Calendar Database Group

Use the check command to scan for corruptions in the calendar database, including calendar properties (calprops) and events and todos (tasks). If the check command finds an inconsistency that cannot be resolved, it reports the situation in its output.

The check command does not check for corruption in the alarm or group scheduling engine (GSE) databases.

To check for database corruption:

  1. Log in as a user who has administration rights to the system where Calendar Server is installed.

  2. Calendar Server can be either running or stopped; however, if possible, stop Calendar Server.

  3. Make a copy of your calendar database, if you haven’t already done so. Copy only the database (.db) files. You don’t need to copy any share (__db.*) or log (log.*) files.

  4. Change to the cal-svr-base/SUNWics5/cal/sbin directory. For example, on Solaris Operating Systems, enter:

    cd /opt/SUNWics5/cal/sbin

  5. Run the check command on the copy of your calendar database:

    ./csdb check dbdir \> /tmp/check.out 2\>&1

    If you don’t specify dbdir, check uses the database in the current directory.

    The check command can generate a lot of information, so consider redirecting all output, including stdout and stderr, to a file (as shown in the example).

  6. After you run the check command, review the output file.

    If your database is corrupted, you can choose to replace it with your hot backup copy. Alternately, you can choose to try to rebuild the corrupted one by running the rebuild command.

ProcedureTo Rebuild the Calendar Database Group (caldb), Without the GSE Database

To recover a damaged calendar database (caldb), use the csdb utility rebuild command. The rebuild command scans all of the calendar databases for corruption. If the rebuild command finds an inconsistency, it generates a rebuilt calendar database (.db files) in the cal-svr-base/SUNWics5/cal/sbin/rebuild_db directory.

The rebuild command can generate a lot of information, so consider redirecting all output, including stdout and stderr, to a file.

In the instructions that follow, the rebuild command does not rebuild the group scheduling engine (GSE) database.

To rebuild the calendar databases without the GSE database:

  1. Log in as a user who has administration rights to the system where Calendar Server is installed.

  2. Stop Calendar Server.

  3. Make a copy of your calendar database, if you haven’t already done so. Copy the database (.db) files and the log (log.*) files. You don’t need to copy any share (__db.*) files.

  4. Change to the cal-svr-base/SUNWics5/cal/sbin directory. For example, on Solaris Operating Systems, enter:

    cd /opt/SUNWics5/cal/sbin

    If disk space is a problem for the sbin directory, run the rebuild command in a different directory.

  5. Run the rebuild command on the copy you made of your calendar database:

    ./csdb rebuild /tmp/db /tmp/

    If you don’t specify a database directory, the rebuild command uses the database

    in the current directory. In the preceding example, the /tmp/ parameter specifies the destination directory for the rebuilt database.


    Note –

    Always rebuild your calendar database using the latest backup copy.

    However, if you have experienced a significant loss of data and you have periodically backed up your database and have more than one copy available, rebuild from the latest copy to the oldest one. (The only drawback is that calendar components that were deleted will reappear in the rebuilt database.)

    For example, if you have three sets of backup calendar database files in directories db_0601, db_0615, and db_0629, run the rebuild command in the following sequence:

    1. ./csdb rebuild db_0629

      Then check for corruption. If this backup copy is also corrupt, then run rebuild on the next backup copy.

    2. ./csdb rebuild db_0615

      Then check for corruption. If this backup copy is also corrupt, then run rebuild on the next backup copy.

    3. ./csdb rebuild db_0601

      ... etc.

    The rebuild command writes the rebuilt database to the cal-svr-base/SUNWics5/cal/sbin/rebuild_db directory.


  6. When rebuild has finished, review the output in the rebuild.out file. If the rebuild was successful, the last line in the rebuild.out file should be:


    Calendar database has been rebuilt
  7. After you have verified that rebuild was successful, copy the rebuilt database (.db) files and the transaction log (log.*) file(s) from the rebuild_db directory to your production database.

  8. If you have any share (__db.*) files from the corrupted database, move them to another directory.

  9. Restart Calendar Server.

ProcedureTo Rebuild the Calendar Database Group, Including the GSE Database

If you have implemented group scheduling at your site, then you should include the GSE database in the rebuild.

To rebuild both the calendar databases and the GSE database:

  1. Determine if the GSE database has any entries by running the csschedule -v list command and then let the GSE finish processing the entries.

  2. Log in as a user who has administration rights to the system where Calendar Server is installed.

  3. Stop Calendar Server.

  4. Make a copy of your calendar database, if you haven’t already done so.

    Copy the database (.db) files and the log (log.*) files. You don’t need to copy any share (__db.*) files.

  5. Change to the cal-svr-base/SUNWics5/cal/sbin directory.

    For example, on Solaris Operating Systems, enter:

    cd /opt/SUNWics5/cal/sbin

    If disk space is a problem for the sbin directory, run the rebuild command in a different directory.

  6. Run the rebuild command on the copy of your calendar database:

    ./csdb -g rebuild /tmp/db /tmp/

    If you don’t specify a database directory, rebuild uses the database in the current directory. In the preceding example, the /tmp/ parameter specifies the destination directory for the rebuilt database.


    Note –

    Always rebuild your calendar database using the latest backup copy.

    However, if you have experienced a significant loss of data and you have periodically backed up your database and have more than one copy available, rebuild from the latest copy to the oldest one. (The only drawback is that calendar components that were deleted will reappear in the rebuilt database.)

    For example, if you have three sets of backup calendar database files in directories db_0601, db_0615, and db_0629, run the rebuild command in the following sequence:

    ./csdb rebuild db_0629 ./csdb rebuild db_0615 ./csdb rebuild db_0601

    The rebuild command then writes the rebuilt database to the cal-svr-base/SUNWics5/cal/sbin/rebuild_db directory.


  7. When rebuild has finished, review the output in the rebuild.out file.

    If the rebuild was successful, the last line in the rebuild.out file should be:


    Calendar database has been rebuilt
  8. After you have verified that rebuild was successful, copy the rebuilt database (.db) files from the rebuild_db directory to your production database.

  9. If you have any share (__db.*) files from the corrupted database, move them to another directory.

  10. Restart Calendar Server.


Example 16–1 Sample Rebuild Output

The sample output shows the events and the todos databases scanned twice each. This is not an error. It scans the first time to verify the information in the calprops database and then scans again to make sure calprops is accessible from the calendar database.

The following example shows the command and the output that it generated:


# ./csdb -g rebuild
Building calprops based on component information.
Please be patient, this may take a while...
Scanning events database...
512 events scanned
Scanning todos database...
34 todos scanned
Scanning events database...
512 events scanned
Scanning todos database...
34 todos scanned
Scanning deletelog database...
15 deletelog entries scanned
Scanning gse database...
21 gse entries scanned
Scanning recurring database...
12 recurring entries scanned
Successful components db scan
Calendar database has been rebuilt
Building components based on calprops information.
Please be patient, this may take a while...
Scanning calprops database to uncover events...
25 calendars scanned
Scanning calprops database to uncover todos...
25 calendars scanned
Successful calprops db scan
Calendar database has been rebuilt

16.2.1 To Delete a Database Group

To delete a calendar database, use the csdb utility delete command. Calendar Server must be stopped.

Use the -t option to specify the target database (caldb, sessdb, or statdb); otherwise, csdb deletes all three databases.

For example, to delete the calendar database:

csdb -t caldb delete

The csdb utility issues a warning before deleting the database.