H4.3. Database Commands

Top  Previous  Next

Database Initialization

warning

For initialization, the database must be absent or empty.

drwcsd [<switches>] initdb [<license_key>|- [<sql_script>|- [<ini_file>|- [<password> [<lua_script>|-]]]]]—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 Server via the interserver connection.

<sql_script>—path to the sql script for initialization of the DB physical structure.

<ini_file>—previously formed file in the drweb32.ini format, to set the initial configuration of Dr.Web software components (i.e. for the Everyone group).

<password>—original password of the Server administrator (the name is admin). Default password is root.

<lua-lua_script>—path to the lua script for the DB initialization (filling the base with defaults).

info

The "-" (minus) special value means not to use this parameter.

A minus 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 initdbex <response-file>

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

File format:

<path_to_key_file>

<path_to_initdb.sql>

<path_to_drweb32.ini>

<administrator_password>

info

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

Any strings following the necessary parameter in a particular case are optional. If a string consists of only the minus symbol "-", the default value is used (as in initdb).

Database Updating

drwcsd [<switches>] updatedb <script>—perform any action with the database (for example, update to a new version) by executing SQL or LUA script from the specified file.

Database Upgrading

drwcsd upgradedb [<folder>]—run the Server to upgrade the structure of the database to a new version from the specified folder (see the update-db folder) or using the internal scripts.

Database Export

a)drwcsd exportdb <file>—export the database to the specified file.

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=all exportdb "C:\Program Files\DrWeb Server\esbase.es"

Under UNIX system-based 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 xmlexportdb <xml_file>—export the database to the specified xml file.

If you specify the gz file extension, when 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, when 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=ALL -rotate=10,10m -log=export.log xmlexportdb 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=ALL -rotate=10,10m -log=export.log xmlexportdb database.gz

Example for UNIX system-based OS:

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

/etc/init.d/drwcsd xmlexportdb /test/database.db

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

/etc/init.d/drwcsd xmlexportdb /es/database.gz

Database Import

a)drwcsd importdb <file>—import the database from the specified file (the previous content of the database is deleted).

b)drwcsd upimportdb <file> [<folder>]—import and upgrade the database exported from the Server of previous version (the previous content of the database is deleted). Also you can specify the path to the folder with scripts to upgrade the structure of the database to a new version (same as in the upgradedb command).

c)drwcsd xmlimportdb <xml_file>—import the database from the specified xml file.

d)drwcsd xmlupimportdb <xml_file>—import and upgrade the database exported in xml from the Server of previous version. Also you can specify the path to the folder with scripts to upgrade the structure of the database to a new version (same as in the upgradedb command).

e)drwcsd xmlimportdbnh <xml_file>—import the database from the specified xml file not considering the hash. Can be used e.g., if the database xml file has been edited manually and the file hash that is written automatically during the export, is no longer valid.

warning

Before using the upimportdb and xmlupimportdb commands, you must 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 upimportdb and xmlupimportdb commands to import and upgrade the version of the database only within the same DBMS.

Database dump export

drwcsd [<switches>] dumpimportdb <DB_file> [<SQL_file> [<tables_filter>]]—write to the Server log file or to the SQL file detailed information on embedded or external database.

info

Import and export of the database is not performed during the dumpimportdb command execution.

<DB_file>—export file of the database, information on which will be written to the Server log file or to the <SQL_file>. Export file can be get via the exportdb command; also you can use the file from the backup copy of the database. XML file after the xmlexportdb command is not allowed.

<SQL_file>—file to write all SQL queries that will be executed during the database import from the file specified in the <DB_file>. If SQL file is not specified, the data will be written to the Server log file (as a list of tables and their fields). If the file is specified, only the queries to the SQL file will be written.

<tables_filter>—the list of database tables, information on which will be written into the <SQL_file>. The tables in the list must be separated with comma. The names must correspond the names of the database tables. For example: admins,groups,stations. Tables filter is applied for SQL file output only. If the tables list is not specified, all tables are written.

Database Verification

drwcsd verifydb—run the Server to check the database. After completion, the Server saves the verification results in the log file (drwcsd.log by default).

Database Speed Up

drwcsd [<switches>] speedupdb—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 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 cleandb—cleanup database of the Server by deleting all database tables.