# Deploying a module backup

While updating the module to a newer version, the user is suggested an option to make a backup of the previous version. It may be necessary sometimes to roll back to the previous version using these backups.

First, you need to stop the module's service:

```
service itgrix_bx stop 
```

By default, backups are created in the `/opt/itgrix_bx_backups/` directory as a subdirectory named with the module name, date, time and version, e.g. `/opt/itgrix_bx_backups/itgrix_bx-20220829-173241-3.9.3/`.

Inside, there are two folders: `/opt/` and `/etc/`. To restore the module from the backup, you need to replace the current contents of the module directories `/opt/itgrix_bx/` and `/etc/itgrix_bx/` with those from the backup directories.

After replacing the files, set the owner and group (asterisk by default) just in case:

```bash
chown -R asterisk. . /opt/itgrix_bx/

chown -R asterisk. . /etc/itgrix_bx/
```

Next, you need to clear the `/opt/itgrix_bx/state.json` file to prevent the module from re-reading all the calls since the time of the backup:

```bash
>/opt/itgrix_bx/state.json
```

Start the module service. You may need to re-authenticate the module in the portal through the admin panel after that.

```bash
service itgrix_bx start
```
