# Backup (https://docs-fpm2731fy-ton-core-docs.vercel.app/llms/ecosystem/nodes/cpp/mytonctrl/backups/content.md)



<Callout type="caution">
  Exporting and restoring backups exposes private keys and validator configuration. Keep backups securely.
</Callout>

## Operational notes [#operational-notes]

* Backups capture MyTonCtrl data, validator config, and keyring files. Always store backup archives securely (they contain private keys).
* Restoration overwrites existing configuration. Ensure the donor node is offline before restoring its backup to avoid data divergence.
* Both scripts expect `sudo` or equivalent privileges when manipulating system files. Use the `-u` flag to match the original install user if necessary.

## Validator automated backups [#validator-automated-backups]

To enable automated backups (only in `validator` mode), call `set auto_backup true` on the MyTonCtrl console. These backups will be performed immediately after the node participates in the elections, ensuring that all data needed for the upcoming validation cycle is preserved. By default, automated backups are saved to `/tmp/mytoncore/auto_backups/`. Call `set auto_backup_path <path>` to change this path.

Automated backups older than 7 days are deleted automatically.

## Standby node [#standby-node]

It is recommended to maintain at least one standby node that can take over validation duties if the main machine fails.

The standby machine should be hosted at a different physical location/ISP. It should have MyTonCtrl installed in full node mode and be synchronized with the TON Blockchain network. Hardware sizing should match main validator configuration.

Use `create_backup` and `restore_backup` commands described below to transfer validator config to the standby machine.

Before transferring the validator configuration to the standby machine, make sure to stop or disable the TON node on the donor machine for approximately 20 minutes. Failure to follow this step may lead to connectivity issues and crashes on both the donor and target machines.

Create and retain a backup of standby node's original configuration before applying or restoring a backup package from another machine. This backup is needed to revert the standby node back to standby mode.

## create\_backup [#create_backup]

**Purpose:** Generate a compressed archive containing MyTonCtrl configuration, keyring, and validator data.

**Syntax**

```mytonctrl
create_backup [filename] [-u <user>]
```

**Behavior**

* Creates a snapshot of the following data:

  * Node configuration file located at (`/var/ton-work/db/config.json`)

  * Node keyring found in (`/var/ton-work/db/keyring`)

  * Node liteserver and console keys stored in (`/var/ton-work/keys`)

  * MyTonCtrl configuration database and related files located at (`~/.local/share/mytoncore`)

  * Wallet and pool data

* Validates the snapshot (ensures the config and database files deserialize) before compressing it into a `.tar.gz`; defaults to `mytonctrl_backup_<hostname>_<timestamp>.tar.gz` unless `filename` specified.

* Sets archive ownership back to the requested user (`-u`) and removes the temporary snapshot when done, printing `create_backup - OK` or `... - Error` based on the helper script exit code.

**Examples**

```mytonctrl
create_backup
create_backup mynode-backup-2024-05-01.tar -u validator
```

## restore\_backup [#restore_backup]

**Purpose:** Restore a previously created backup archive into the current node environment.

**Syntax**

```mytonctrl
restore_backup <filename> [-y] [--skip-create-backup] [-u <user>]
```

**Behavior**

* Requires the backup archive filename. Optional flags:
  * `-y` skips the interactive confirmation prompt.
  * `--skip-create-backup` prevents MyTonCtrl from making a safety backup of the current state before restoring.
  * `-u <user>` runs the restore operations as the specified system user (defaults to the current user).
* Unless `--skip-create-backup` passed, first runs `create_backup` so the state can be rolled back if the restore fails.
* Stops `validator` and `mytoncore` services, and restores data from the backup, except for IP address, which will be updated accordingly.
* On success, reloads MyTonCtrl’s local database, reinstalls BTC Teleport if validator mode is active, prints `restore_backup - OK`, and exits so MyTonCtrl can be restarted with the restored state.

**Examples**

```mytonctrl
restore_backup mynode-backup-2024-05-01.tar
restore_backup mynode-backup-2024-05-01.tar -y --skip-create-backup -u validator
```
