G3.3. Database Commands

Database Initialization

warning

For initialization, the database must be absent or empty.

info

Flag values must be specified in %true and %false, or 1 and 0 format.

drwcsd [<switches>] modexecdb database-init [<license_key> [<password>]]—database initialization.

<license_key>—path to Dr.Web license key file agent.key. If the license key is not specified, it must be added later from the Control Center or get from the neighbor Dr.Web Server via the interserver connection.

<password>—original password of the Dr.Web Server administrator (logged in as admin). The default password is root.

info

If you need to skip one or several parameters when writing the command, use the special value %nil instead of each skipped parameter.

%nil can be omitted, if the next parameters are not set.

Adjusting parameters of database initialization

If embedded database is used, initialization parameters can be set via an external file. The following command is used for this:

drwcsd.exe modexecdb database-init@<response-file>

<response-file>—file with initialization parameters written line-by-line in the same order same as parameters of the database-init command.

File format:

<full_license_key_filename>

<administrator_password>

info

When using a response file under Windows OS, any symbols are allowed in the administrator password.

If a string consists of only the %nil value, the default value is used (as in database-init).

Database Upgrading

drwcsd modexecdb database-upgrade [pretend] [upgrade_ver_flag]—run Dr.Web Server to upgrade the structure of the database to a new version using the internal scripts.

pretend=false—default value. Instructs to update the database. If true, only checking the relevance of the database will be performed instead of database update.

upgrade_ver_flag=true—during the update database version and data are recorded on each successful update to the next version of the database schema.

Database Export

a)drwcsd modexecdb database-export <file>[ignore_tables]—export the database to a specified file.

<file>—path to the file to which the database will be exported.

ignore_tables—allows to specify a string or a table with strings containing the names of stations which are not to be exported. The format of tables with rows is as follows: %{"table1", "table2"}. In case of specifying a row—table1.

Example for Windows OS:

"C:\Program Files\DrWeb Server\bin\drwcsd.exe" -home="C:\Program Files\DrWeb Server" -var-root="C:\Program Files\DrWeb Server\var" -verbosity=trace -log="C:\Program Files\DrWeb Server\var\exportdb.log" modexecdb database-export "C:\Program Files\DrWeb Server\esbase.es"

Under Unix-like OS, the action is performed on behalf of the drwcs:drwcs user to the $DRWCS_VAR directory (except FreeBSD OS, which by default saves the file to the directory from which the script was run; if the path is specified explicitly, then the directory should have the write access for the <user>:<group> that had been created at installation, by default it is drwcs:drwcs).

b)drwcsd modexecdb database-export-xml <xml_file> [ignore_tables]—export the database to a specified XML file.

<xml-file>—path to the XML file to which the database will be exported.

ignore_tables—allows to specify a string or a table with strings containing the names of stations which are not to be exported. The format of tables with rows is as follows: %{"table1", "table2"}. In case of specifying a row—table1.

If you specify the gz file extension, during the export, database file will be packed into the gzip archive.

If you do not specify any extension or specify an extension other than gz, export file will not be archived.

Example for Windows OS:

To export the database into the XML file with no compression:

"C:\Program Files\DrWeb Server\bin\drwcsd.exe" -home="C:\Program Files\DrWeb Server" -bin-root="C:\Program Files\DrWeb Server" -var-root="C:\Program Files\DrWeb Server\var" -verbosity=trace -rotate=10,10m -log="C:\Program Files\DrWeb Server\var\exportxmldb.log" modexecdb database-export-xml database.db

To export the database into the XML file compressed to an archive:

"C:\Program Files\DrWeb Server\bin\drwcsd.exe" -home="C:\Program Files\DrWeb Server" -bin-root="C:\Program Files\DrWeb Server" -var-root="C:\Program Files\DrWeb Server\var" -verbosity=trace -rotate=10,10m -log="C:\Program Files\DrWeb Server\var\exportxmldb.log" modexecdb database-export-xml database.gz

Example for Unix-like OS:

To export the database into the XML file with no compression:

/etc/init.d/drwcsd modexecdb database-export-xml /test/database.db

To export the database into the XML file compressed to an archive:

/etc/init.d/drwcsd modexecdb database-export-xml /es/database.gz

Database Import

a)drwcsd modexecdb database-import <file> [ignore_tables]—import the database from a specified file (in this case all records from all tables are deleted, the tables themselves are not deleted - records from the export are inserted into them).

<file>—path to the file from which the database will be imported.

ignore_tables—allows to specify a string or a table with strings containing the names of stations which are not to be imported. The format of tables with rows is as follows: %{"table1", "table2"}. In case of specifying a row—table1.

b)drwcsd modexecdb database-import-and-upgrade <file> [import_only_flag] [upgrade_ver_flag] [ignore_tables]—import and upgrade the database exported from Dr.Web Server of previous version. The tables themselves are deleted, new tables are created according to the description from the export. Records from the export are inserted into new tables, and then the update procedure is started.

<file>—path to the file from which the database will be imported.

import_only_flag—if %true, only import is performed, without database update and verification.

upgrade_ver_flag—if %true, during a database upgrade, the database version and data are committed each time it is successfully upgraded to the next version of the database schema.

ignore_tables—allows to specify a string or a table with strings containing the names of stations which are not to be imported. The format of tables with rows is as follows: %{"table1", "table2"}. In case of specifying a row—table1.

info

When specifying the parameters, previous parameters must be specified (i.e. both flags must be specified before ignore_tables).

warning

Before using the database-import-and-upgrade command, you are strongly advised to back up the database.

Any problems during execution of these commands may lead to deletion of all information from the database.

 

You can use the database-import-and-upgrade command to import and upgrade the version of the database only within the same DB.

Database Verification

drwcsd modexecdb database-verify [full=%false [ignore-version=%false]]—run Dr.Web Server to verify the database. In order to record the results into a log file, the command shall be followed by a -log key. Details on how to use the key are described in G3.8. The Description of Switches.

full=%false—defines the verification type. By default (%false) a quick check is made, if true—a full verification.

ignore-version=%false—defines whether the database schema version needs to be ignored during verification. %false by default. If %true, verification will continue even if the schema version is wrong.

Database Speed Up

drwcsd [<switches>] modexecdb database-speedup—execute the VACUUM, CLUSTER, ANALYZE commands to speed up the DB operation.

Database Restore

drwcsd repairdb—repair malformed disk image of SQLite3 embedded database or corrupted tables of MySQL external database.

SQLite3 may be also automatically recovered on the Dr.Web Server startup if in the SQLite3 database settings in the Control Center, the Restore corrupted image automatically flag is set (see Administrator Manual, p. Database Restore).

Database cleanup

drwcsd modexecdb database-clean—clean up the Dr.Web Server database by deleting all tables.

Administrator password reset

drwcsd modexecdb set-admin-password <login> <new_password>—set a new password for the specified administrator account.