---
name: "oar-database"
section: "1"
platform: "linux"
package: "oar-server"
version: "2.5.9-1+deb12u1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/oar-database"
---

# oar-database(1)

manage OAR database.

## NAME

oar-database - manage OAR database.

## SYNOPSIS

**oar-database** *--create* \[*OPTIONS*\]

**oar-database** *--drop* \[*OPTIONS*\]

**oar-database** *--upgrade* \[*OPTIONS*\]

**oar-database** *--reset* \[*OPTIONS*\]

**oar-database** *--check* \[*OPTIONS*\]

## DESCRIPTION

OAR uses a database for it's persitent data either using the MySQL or PostgreSQL backend (see oar.conf). oar-database is provided to manage that database.

## ACTIONS

- **--create**

  Create an OAR database: inject schema and default data and create users/roles.

- **--drop**

  Drop an existing OAR database and associated users/roles.

- **--upgrade**

  Upgrade an existing OAR database.

- **--reset**

  Reset an existing OAR database to the state of the fresh new one.

- **--check**

  Check that OAR database is accessible and up to date (schema version).

## OPTIONS

### General parameters

- **--conf**=*OAR\_CONF\_FILE*

  Define the OAR configuration file to use. By default */etc/oar/oar.conf* is used. If this file doesn't exist, the default parameters for each value are used.

- **--update-conf**

  The database parameters given in the command line are written to the OAR\_CONF\_FILE

- **-f,--force-sql**

  Force to continue the execution even if a SQL command fails

- **-y,--force-yes**

  Force oar-database to continue without prompt even if it could be harmful.

### Database backend parameters

These parameters are only required by the *--create* and *--drop* actions.

- **--db-is-local**

  PostgreSQL: use local admin account to execute admin commands. MySQL: use the unix socket connection to execute admin commands.

- **--db-admin-user**=*DB\_ADMIN\_USER*

  Set database backend admin username.

- **--db-admin-pass**=*DB\_ADMIN\_PASS*

  Set database backend admin password.

### OAR database parameters

If not specified, OAR database parameters are taken from *OAR\_CONF\_FILE*. Please prefer setting the configurations in that file instead of using these options.

- **--db-type**=*DB\_TYPE*

  Database backend to use, *mysql* or *Pg* (for PostgreSQL).

- **--db-user**=*DB\_USER*

  Set OAR username to access the database. Override the one set in OAR\_CONF\_FILE.

- **--db-pass**=*DB\_PASS*

  Set OAR user password to access the database. Override the one set in OAR\_CONF\_FILE.

- **--db-host**=*DB\_HOST*

  Set the database backend hostname. Override the one set in OAR\_CONF\_FILE.

- **--db-port**=*DB\_PORT*

  Set the database backend TCP port. Override the one set in OAR\_CONF\_FILE.

- **--db-name**=*DB\_NAME*

  Set OAR database name. Override the one set in OAR\_CONF\_FILE.

- **--db-ro-user**=*DB\_RO\_USER*

  Set OAR username for read-only access the database. Override the one set in OAR\_CONF\_FILE.

- **--db-ro-pass**=*DB\_RO\_PASS*

  Set OAR user password for read-only access the database. Override the one set in OAR\_CONF\_FILE.

- **-d,--debug**

  Activate the display of debugging information.

- **-h,--help**

  Display this help.

## EXAMPLES

### MySQL

First you need to specify the database parameters in /etc/oar/oar.conf. These parameters will be used by **oar-database**.

To create a new database (assuming that the MySQL root password is **PASS**):

**oar-database --create --db-admin-user root --db-admin-pass PASS**

Or if the MySQL server is local and accessible using the unix socket:

**oar-database --create --db-is-local**

To upgrade an existing database:

**oar-database --upgrade**

### PostgreSQL

First you need to specify the database parameters in /etc/oar/oar.conf. These parameters will be used by **oar-database**. If your PostgreSQL database is on the local system, you can use the **--db-is-local** option which will use PostgreSQL unix account (needs root privileges).

To create a new database:

**oar-database --create --db-is-local**

To upgrade an existing database:

**oar-database --upgrade**

### Advanced usages

To make some tests or to administrate several databases, you can also specify the sql parameters on the command line. For example:

**oar-database --create --db-type=Pg --db-host=HOST \\**\
                **--db-user=oar --db-pass=PASS \\**\
                **--db-admin-user=ADMIN\_USER --db-admin-pass=ADMIN\_PASS**

will create the oar database and the oar user on the postgresql system hosted by **HOST**. The user **ADMIN\_USER** must have the right to create new databases and new roles on this system.

## FILES

- /usr/lib/oar/database/mysql\_structure.sql, /usr/lib/oar/database/pg\_structure.sql

  SQL instructions for creating the structure of the oar database.

- /usr/lib/oar/database/mysql\_default\_admission\_rules.sql, /usr/lib/oar/database/pg\_default\_admission\_rules.sql

  SQL instructions for inserting the default admission rules in the oar database.

- /usr/lib/oar/database/default\_data.sql

  SQL instructions for inserting the default data in the oar database.

- /usr/lib/oar/database/mysql\_reset\_structure.sql, /usr/lib/oar/database/pg\_reset\_structure.sql

  SQL instruction for emptying an existing oar database.

- /usr/lib/oar/database/mysql\_structure\_upgrade\_\*.sql, /usr/lib/oar/database/pg\_structure\_upgrade\_\*.sql

  SQL instructions for upgrading an existing database.

## COPYRIGHTS

```
 Copyright 2003-2018 Laboratoire d'Informatique de Grenoble (http://www.liglab.fr). This software is licensed under the GNU General Public License Version 2 or above. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
