.. _database-restore:

Recovering from database crashes
================================

Every Genian NAC's system configures, policies, collection stored on database. If a database problem occurs by H/W or S/W error, you can recover database by using backup file.

Symptom
-------

Web Console login failure, policy assignment and policy renewal failure, setting lookup failure, etc.

Cause
-----

Crashes occur in databases due to various problems. H/W problems Internal database engine problems, setup problems, etc.


Resolution
----------

Recover the database using the database information in the backup file.

.. code:: bash

    Step 1 If the backup file is inside the equipment you want to restore, navigate to Step3.

    genian> en
    genian# @shell
    !!! WARNNING !!! - SHELL PROMPT IS JUST FOR MAINTENANCE.
    !!! WARNNING !!! - USE AT YOUR OWN RISK.
    Genians$ cd /disk/data/DBBACKUP
    Genians$ rz [Backup File]
    Genians$ ls
    drwxr-xr-x    2 root     root          4096 May 11 09:43 ./
    drwxr-xr-x   36 root     root          4096 Apr 21 13:50 ../
    -rw-r--r--    1 root     root     193863371 May 11 09:43 ALDER-93180-20210511-094236.tar.gz

    Step 2 Connect to the gnlogin CLI.

    genian$ gnlogin

    Step 3 Verify the backup files at the time you restore them.

    genian# show backup

    Backup lists
    ---------------------------------
    ALDER-93180-20210511-094236

    Step 4 Restore the database (select Database Only under Options).
    
    genian# do restore [Backup File Name]
    Are you sure to restore configuration files (y/N): n
    Are you sure to restore agent files (y/N): n
    Are you sure to restore custom files (y/N): n
    Are you sure to restore database (y/N): y
    Do you want to start service after restore? (Y/n): y

    Step 5 If the system is restarted and the database restore is successful, all systems will function normally.