# 3.3.7 Seeding & clearing data on a server

## Seeding data on a new server

For new server deployments of OpenCRVS, you will need to seed the databases with the country specific data you created in [step 3.2](https://github.com/opencrvs/documentation/blob/release-v1.3.0/setup/3.-installation/3.2-set-up-your-own-country-configuration)

We have provided an automated Github action:[ **seed-data**](https://github.com/opencrvs/opencrvs-countryconfig/blob/develop/.github/workflows/seed-data.yml) to do this for you. Manual steps are also explained, should you not wish to use the action.

**Provision the following environment variables in Github depending on your environment.**

| Variable              | Description                                                                                |
| --------------------- | ------------------------------------------------------------------------------------------ |
| GATEWAY\_HOST         | The URL to the gateway microservice e.g.: *<https://gateway.\\><your-domain>*              |
| AUTH\_HOST            | The URL to the auth microservice e.g.: *<https://auth.\\><your-domain>*                    |
| COUNTRY\_CONFIG\_HOST | The URL to the country-config microservice e.g.: *<https://countryconfig.\\><your-domain>* |

**Option 1: Run the automated seed-data action**

As you performed in step [3.3.6 Deploy](/v1.3/setup/3.-installation/3.3-set-up-a-server-hosted-environment/3.3.6-deploy-automated-and-manual.md), navigate to **"Actions"**, in Github and click **"Seed data."**

a) You will be required to select the environment that you wish to seed.

b) You will be required to enter the OpenCRVS Core Dockerhub image tag for any tagged build on Dockerhub) to refer to the OpenCRVS Core release of choice. Usually this will be an official release if you have performed no customisations to core. E.G. **v1.3.0**

<figure><img src="/files/z3EG1i39FI6ba2JvEOR9" alt=""><figcaption></figcaption></figure>

**Option 2: Run the seed command manually**

NOTE: You can manually run the seed command from terminal by navigating to the opencrvs-core directory

```
cd opencrvs-core
```

Export all the required variables:

<pre><code>
<strong>export COUNTRY_CONFIG_HOST=&#x3C;URL-to-your-country-config-server> \
</strong>export AUTH_HOST=&#x3C;URL-to-your-auth-server> \
export GATEWAY_HOST=&#x3C;URL-to-your-gateway-server> \
export SUPER_USER_PASSWORD=&#x3C;your-superuser-password>
</code></pre>

Run the seed to server command

```
yarn seed:prod
```

{% hint style="danger" %}
After seeding, the OpenHIM password is reset to the default username: **<root@openhim.org>** and default password: **openhim-password**. In production environments, it is **very important for you to login to OpenHIM and change the password** at the following URL:  **<https://openhim.\\><your-domain>** Store the new password in your password manager software.
{% endhint %}

## Clearing data on a new server

It is also possible to clear data on a server manually. This is the equivalent to using the --clear-data=yes parameter in the Deploy script in [step 3.3.6](/v1.3/setup/3.-installation/3.3-set-up-a-server-hosted-environment/3.3.6-deploy-automated-and-manual.md)

{% hint style="danger" %}
**THESE ARE DESTRUCTIVE ACTIONS. ALL YOUR OPENCRVS DATA IS DELETED AND RESTORED TO A FACTORY BACKUP.**
{% endhint %}

#### Clearing all data on a server

1. SSH into your server and navigate to the following directory:

```
cd /opt/opencrvs/infrastructure/
```

2\. Ensure that your database [secrets](/v1.3/setup/3.-installation/3.3-set-up-a-server-hosted-environment/3.3.6-deploy-automated-and-manual.md) are available to the script as environment variables. You can do this by running:

```
export ELASTICSEARCH_ADMIN_USER=elastic \
export ELASTICSEARCH_ADMIN_PASSWORD=<your elastic password> \
export MONGODB_ADMIN_USER=<your mongo username> \
export MONGODB_ADMIN_PASSWORD=<your mongo password>
```

3\. The clear all script is run like this:

Replace and separate the \<REPLICAS> with a space when calling the script: 1, 3 or 5

```
bash ./clear-all-data.sh <REPLICAS>
```

{% hint style="warning" %}
**After clearing all data on a server, you must re-deploy to the server.  This is so that a superuser is recreated allowing you to then re-seed the databases.**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.opencrvs.org/v1.3/setup/3.-installation/3.3-set-up-a-server-hosted-environment/3.3.7-seeding-and-clearing-data-on-a-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
