> For the complete documentation index, see [llms.txt](https://docs.editran.onesait.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.editran.onesait.com/documentacion-editran/connect-v2.1-en/administradores/backups.md).

# Backups

Performing regular backups is essential to ensure data recovery in case of failures, configuration errors, loss of integrity, or scheduled maintenance.

Editran Connect is composed of multiple elements that must be backed up together to ensure a complete recovery of the environment.

***

## Components to back up

These are the different components recommended to back up; depending on the component and your system's needs the strategy may differ.

| Component             | Description                                                                       |
| --------------------- | --------------------------------------------------------------------------------- |
| Database (PostgreSQL) | Contains all configuration information, users, channels and usage.                |
| Configuration files   | The core modules of Editran have two configuration files that must be safeguarded |
| Temporary files       | Folder of jobs in progress or pending.                                            |
| Logs                  | Log files useful for auditing and diagnostics.                                    |
| Binary repository     | Folder with the system's own JAR/WAR files.                                       |
| License file          | license file required for Editran to function                                     |

> ℹ️ *Note:* Paths may vary depending on the installation. Use the environment variables configured during installation or consult technical support.

***

## General recommendations

* Perform backups **automated** outside of operating hours. Especially when you do not have exchanges with other Editran nodes.
* Use backup tools compatible with PostgreSQL (`pg_dump`, `pg_basebackup`).
* Verify backups with periodic restore tests.
* Protect access to backup files with restrictive permissions.
* Store at least one external copy (for example, network/NAS/s3).

***

## Example of manual backup

### 2. Configuration files

The core modules of Editran have several configuration files that must be safeguarded, they are **ALL** the files that are in the directory `<core_install_path>/cfg`. The backup of these files should be performed when we make the backup in the following section, otherwise we may encounter differences that compromise the backup.

### 1. PostgreSQL database

Editran includes a PostgreSQL database engine that is configured and deployed during the installation process. For security reasons the base configuration of this server only accepts requests from the database server itself; this means that if you want to perform backups from an external agent you must take this into account.

The database connection data are in the user variables created during the installation process:

| VARIABLE          | DESCRIPTION                         |
| ----------------- | ----------------------------------- |
| EDITRAN\_DB\_HOST | database server (default localhost) |
| EDITRAN\_DB\_PORT | database port (default 5432)        |
| EDITRAN\_DB\_PWD  | database connection password        |
| EDITRAN\_DB\_USER | database connection user            |

Along with the database engine, its administration tools are installed, and you have them available in `<connect_installation_path>/bin/pgsql/bin` (we recommend including it in the PATH variable of the OS users who will run your backup routines).

At this point you can implement different strategies with the installed tools; we will describe one method but there are others.

To back up the data we will use the PostgreSQL tools included in the Connect installation; if you do it manually you would need to follow these steps:

1. The **DATA** of **Editran Connect** service must be running
2. we open a Windows cmd on the server.
3. we go to the path \<connect\_installation\_directory>\bin\pgsql\bin
4. we run the command pg\_dumpall -U postgres > backup.sql
5. this will take a few seconds and we will have the file backup.sql inside the directory \<connect\_installation\_directory>\bin\pgsql\bin

**Here you have an example .bat process to perform the backup**:

```cmd
@echo off
setlocal

:: Define date in YYYYMMDD format
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd"') do set "DATESTR=%%i"

:: Path to pg_dumpall
set "PG_BIN=C:\EditranConnect\bin\pgsql\bin"
set "BACKUP_DIR=C:\backup"
set "FILENAME=backup_editran_%DATESTR%.sql"
set "FULLPATH=%BACKUP_DIR%\%FILENAME%"

:: Verify that the backup directory exists
if not exist "%BACKUP_DIR%" (
    echo The backup directory does not exist: %BACKUP_DIR%
    exit /b 1
)

:: Verify that the necessary environment variables are defined
if "%EDITRAN_DB_USER%"=="" (
    echo ERROR: The environment variable EDITRAN_DB_USER is not defined.
    exit /b 1
)

if "%EDITRAN_DB_PWD%"=="" (
    echo ERROR: The environment variable EDITRAN_DB_PWD is not defined.
    exit /b 1
)

:: Set the PGPASSWORD environment variable only in the script environment
set "PGPASSWORD=%EDITRAN_DB_PWD%"

:: Execute the backup
"%PG_BIN%\pg_dumpall.exe" -U %EDITRAN_DB_USER% > "%FULLPATH%"
if errorlevel 1 (
    echo ERROR: The pg_dumpall command failed.
    exit /b 1
)

echo Backup completed successfully: %FULLPATH%

:: Clear sensitive variables
set "PGPASSWORD="
endlocal
```

## Example PostgreSQL restore backup

here you have an example of how to perform a restore. We strongly recommend that you perform restore tests before putting the server into production.

```cmd
@echo off
setlocal

:: Backup file to restore (you can change it to another name or pass it as a parameter)
set "BACKUP_FILE=C:\backup\backup_editran_YYYYMMDD.sql"

:: Path to the psql binary
set "PG_BIN=C:\EditranConnect\bin\pgsql\bin"

:: Verify that the file exists
if not exist "%BACKUP_FILE%" (
    echo ERROR: Backup file not found: %BACKUP_FILE%
    exit /b 1
)

:: Verify necessary environment variables
if "%EDITRAN_DB_USER%"=="" (
    echo ERROR: The environment variable EDITRAN_DB_USER is not defined.
    exit /b 1
)

if "%EDITRAN_DB_PWD%"=="" (
    echo ERROR: The environment variable EDITRAN_DB_PWD is not defined.
    exit /b 1
)

:: Set the password in the PGPASSWORD environment variable
set "PGPASSWORD=%EDITRAN_DB_PWD%"

:: Execute the restoration
type "%BACKUP_FILE%" | "%PG_BIN%\psql.exe" -U %EDITRAN_DB_USER% -h localhost -p 5432 -d postgres
if errorlevel 1 (
    echo ERROR: The restore failed.
    exit /b 1
)

echo Restoration completed successfully from: %BACKUP_FILE%

:: Clean up
set "PGPASSWORD="
endlocal
```

remember that you must also restore the .cfg files described above and that they must be from the same point in time.

## Other files

### License file

The Editran license file (licencia.dat), which during the installation process was left in `<core_path>\bin\SL` is necessary for your Editran to operate; although the Editran team can provide you with a new one we recommend that you make a backup.

### logs

Editran Connect generates two large collections of logs

* core logs, which are in the directory `<core_path>\log`
* connect logs, which are in the directory `<connect_path>\logs`

if in case of disaster you want to be able to do a subsequent analysis, we recommend saving the latest logs from both paths.

## Backup security

* Encrypt your backups
* Limit read access to the administrators group.
* Perform backup rotation and secure deletion of old copies.
* Perform periodic restore tests

## Warning

> ⚠️ **Warning** The Editran development team provides this guide and the scripts detailed here as guidance and examples so that system administrators know the necessary data to perform backups. It is the responsibility of the administrators of each installation to perform the backups and the appropriate restore tests to be able to recover their system in case of disaster.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.editran.onesait.com/documentacion-editran/connect-v2.1-en/administradores/backups.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
