---
title: Database Backup and Restore Procedure
slug: kronpam-installation-guide/database-backup-and-restore-procedure
description: Learn how to easily back up and restore your database in the Single Connect system with step-by-step instructions. From switching to the enterprisedb user to exporting and importing the necessary schemas, this document covers everything you need to know. 
docTags: 
createdAt: 2022-08-19T08:16:34.000Z
---

Perform the following steps only if the database backup is required.

# Backing up Database

1. Switch user to enterprisedb.
   **\[root\@kronpam\~]#** su – enterprisedb

2. Set the password variable.
   **\[enterprisedb\@kronpam\~]$&#x20;**&#x65;xport PGPASSWORD="1qaz2wsx"

3. Export the radius schema.
   **\[enterprisedb\@kronpam\~]$&#x20;**/u01/PostgresPlus/9.5AS/bin/pg\_dump -p 5444 -w -U enterprisedb -n radius -Fp -f "backup\_schema\_radius.dmp" aioc

4. Export the aioc schema.
   **\[enterprisedb\@kronpam\~]$&#x20;**/u01/PostgresPlus/9.5AS/bin/pg\_dump -p 5444 -w -U enterprisedb -n aioc -Fp -f "backup\_schema\_aioc.dmp" aioc

# Restoring Database

To import a database, you need to install a new database and remove the default Kron PAM parameters or existing schemas.

1. Set password variable.
   **\[enterprisedb\@kronpam\~]$&#x20;**&#x65;xport PGPASSWORD="1qaz2wsx".
2. Connect to the new database and create users. Change the passwords with proper values.
   **\[enterprisedb\@kronpam\~]$&#x20;**./psql -p 5444 -d edb -U enterprisedb                                **edb=#** CREATE ROLE aioc LOGIN PASSWORD ‘aioc’ SUPERUSER INHERIT CREATEDB CREATEROLE REPLICATION;                                                                                                                             **edb=#** CREATE ROLE radius LOGIN PASSWORD ‘radius’ SUPERUSER INHERIT CREATEDB CREATEROLE  REPLICATION;                                                                                                                               **edb=#** ALTER ROLE aioc SET search\_path = "$user", public, radius;                                              **edb=#** ALTER ROLE radius SET search\_path = "$user", aioc, public;
3. Create aioc table.
   **edb=#** CREATE DATABASE aioc WITH OWNER = aioc ENCODING = 'UTF8' TABLESPACE = pg\_default LC\_COLLATE = 'en\_US.utf8' LC\_CTYPE = 'en\_US.utf8' CONNECTION LIMIT = -1;
4. Import schemas.
   **\[enterprisedb\@kronpam\~]$&#x20;**./psql -p 5444 -d aioc -U enterprisedb -f "backup\_schema\_radius.dmp"                                                                                       **\[enterprisedb\@kronpam\~]$&#x20;**./psql -p 5444 -d aioc -U enterprisedb -f "backup\_schema\_aioc.dmp"

