# Backup and Restore

## Version

* Linux Control Center = 2.10.X or higher

## Requirements

* SSH access to the LCC Host with root user

## Overview

* This guide provides information and step-by-step instructions for backing up and restoring the LCC

## Objective

* Demonstrate the complete backup and restore process of the LCC through the CLI interface.

## Default Backup Directory

{% hint style="warning" %}
We strongly recommend that the generated backups be copied to a safe location, ensuring data preservation in case any intervention is necessary in the future.

**Backup destination directory:** `/opt/lcc/bkp/`

The configuration backup files will have a name in the format `backup_config_YYYY-MM-DD_HH-MM-SS.tar.gz`, indicating the year, month, day, hour, minute and seconds in which the backup was created. These files contain the settings required for LCC to work.

The database backup file will be named in the format `lcc_db_YYYY-MM-DD_HH-MM-SS.sql`, following the same pattern. This file stores the entire database, allowing complete recovery of the stored information.
{% endhint %}

## Stopping Containers

1. Before performing the backup, it is necessary to stop the LCC Container processes separately for greater data integrity.
2. **Container lcc\_console**\
   Command: `docker stop lcc_console`
3. **Container lcc\_worker**\
   Command: `docker stop lcc_worker`
4. **Container lcc\_alert\_report**\
   Command: `docker stop lcc_alert_report`
5. See the example in the image below:

   ![](https://1620115297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZm19HsLxuDm2GumYKEz%2Fuploads%2Fgit-blob-b7be5759f135dddd85765b413756c7ae8fae865d%2Fparando_container.png?alt=media)

### Backup Configuration Files

1. This command backs up all files with the `.yml` extension that were generated during installation. These files are essential for LCC to work.

Command: `lcc-cli backup -a`

1. The backup will be compressed in the tar.gz extension

   ![](https://1620115297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZm19HsLxuDm2GumYKEz%2Fuploads%2Fgit-blob-eada7c681807b977fbcb6a998a4caa3c47e23876%2Fbackup.png?alt=media)

{% hint style="warning" %}
The LCC database is encrypted, and within this compressed backup there will be a file called `crypt.yml`, which is the key to decrypt during the restore.

Without this key, it will be impossible to restore the database.
{% endhint %}

### Database Backup

1. To back up the LCC database, run the command below;

Command: `lcc-cli database --backup`

1. The backup will have the .sql extension with the date and time the backup creation command was executed.

   ![](https://1620115297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZm19HsLxuDm2GumYKEz%2Fuploads%2Fgit-blob-17d7b3732a68f7c3ac1e0707cd1dbdd0a082c7b1%2Fbackup_database.png?alt=media)

### Restoring Backup

1. To restore the LCC, you must extract all [Configuration Files](#backup-of-configuration-files) to the system root directory `/` with the root user

Command: `tar -xzvf file_name.tar.gz -C /`

```
![](/pt-br/images/backup_and_restore/extracting_config.png)
```

1. After extracting the files, run the command to restore the LCC from the `.sql` file created in the [Database Backup](#database-backup) step.

Command: `lcc-cli database --restore file_name.sql`

1. Check if you are using the correct backup and confirm by typing **y** and pressing **enter**

   ![](https://1620115297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZm19HsLxuDm2GumYKEz%2Fuploads%2Fgit-blob-8958307ff8a0070a7e177c06a004f1af6768c332%2Frestaurando_banco.png?alt=media)

## Starting the Containers

1. After the restoration is complete, run the commands to start the Containers.
2. **Container lcc\_console**\
   Command: `docker start lcc_console`
3. **Container lcc\_worker**\
   Command: `docker start lcc_worker`
4. **Container lcc\_alert\_report**\
   Command: `docker start lcc_alert_report`
5. See the example in the image below:

   ![](https://1620115297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZm19HsLxuDm2GumYKEz%2Fuploads%2Fgit-blob-fcddc4a6df973590c5fbc5a855d7c8e7e0603755%2Finiciando_containers.png?alt=media)
6. The LCC will be ready for use normally after the Containers are initialized.

   ![](https://1620115297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtZm19HsLxuDm2GumYKEz%2Fuploads%2Fgit-blob-c6f30cd5743037573225b162b4fcea817c8c3026%2Ftela_login.png?alt=media)
