# Backup/Restore a P12 KeyStore

| Table of Contents                               |
| ----------------------------------------------- |
| [Backup Procedure](#backup-p12-keystore-file)   |
| [Restore Procedure](#restore-p12-keystore-file) |

## 🔐Backup P12 Keystore File

Maintaining an up-to-date and secure backup of your `.p12` file is essential for protecting access to your Validator node and wallet. This guide will walk you through securely backing up and restoring your `.p12` file using a macOS or Windows system.

***

{% stepper %}
{% step %}

### Determine Cold Storage Medium

#### What and Why Cold Storage?

Cold storage refers to keeping your `.p12` file **offline**, minimizing exposure to unauthorized access or system vulnerabilities. Acceptable storage methods include:

* Encrypted USB drives
* Hardware wallets with secure storage
* Air-gapped systems
* Secured Encrypted Software Vaults
  {% endstep %}

{% step %}

### Open Terminal Application

{% tabs %}
{% tab title="Macintosh" %}
Macintosh MacOS Terminal   ![](https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2F7WQ1XbKT3oWTYOW33ZdR%2Fapple_terminal_icon.png?alt=media\&token=d276689b-b2a0-4bf0-a624-36ed14ab8b15)
{% endtab %}

{% tab title="Windows" %}
&#x20;Windows 11 Terminal App ![](https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2FXSVAwJPepanHpjeVWNTZ%2Fterminal_icon_img.png?alt=media\&token=8e0e351e-77f2-46c8-a392-19d862cf3fe5)  and make sure the terminal session opens a PowerShell prompt.

![](https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2FtxWKc5dImmjUUJ67h5PK%2Fimage.png?alt=media\&token=8705c453-f1ea-448a-9e6a-4726bfb6b27f)
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Create Temporary Backup Directory

```bash
cd ~
mkdir constellation-backup
cd ~/constellation-backup
```

{% endstep %}

{% step %}

### **Start SFTP Session to Your Validator Node**

Replace values with your actual SSH key and node IP address:

```bash
sftp -i ~/.ssh/my-node-ssh-keyname nodeadmin@123.123.123.123
```

You'll be prompted to enter your SSH key passphrase.
{% endstep %}

{% step %}

### Locate your p12 KeyStore

```bash
cd /home/nodeadmin/tessellation
ls -l
```

Example output:

```
-rw-r--r-- 1 nodeadmin nodeadmin 31 Jun 11 14:28 my-p12file.p12
```

{% endstep %}

{% step %}

### Download your p12 KeyStore

Use the `get` command to download the file to your temporary directory:

```bash
get my-p12file.p12
```

You should see:

```
100% 31 0.3KB/s 00:00
```

{% endstep %}

{% step %}

### End the SFTP Session

```bash
exit
```

{% endstep %}

{% step %}

### Confirm p12 Keystore on Local System

{% tabs %}
{% tab title="Macintosh" %}

```bash
cd ~/constellation-backups
ls -l
```

{% endtab %}

{% tab title="Windows" %}

```bash
cd ~/constellation-backup
dir
```

{% endtab %}
{% endtabs %}

Confirm your p12 keystore is locally found on your system.
{% endstep %}

{% step %}

### **Transfer to Cold Storage**

Move your `.p12` file to a secure offline storage device.
{% endstep %}

{% step %}

### Remove p12 KeyStore from Local System

<mark style="color:orange;">**Once complete**</mark>, delete the p12 keystore file from your local system to maintain proper security practices.
{% endstep %}

{% step %}
{% tabs %}
{% tab title="Macintosh" %}

```bash
cd ~/constellation-backups
rm -f my-p12file.p12
```

{% endtab %}

{% tab title="Windows" %}

```bash
cd ~/constellation-backup
rm my-p12file.p12
```

{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

***

## 🔄 Restore P12 Keystore File

{% stepper %}
{% step %}

### Obtain p12 keystore backup from cold storage

* Access your backup device
* Locate your backup p12 key store file
  {% endstep %}

{% step %}

### Transfer p12 keystore to local system

Copy your backed-up p12 keystore file to your local Macintosh or Windows system.

{% tabs %}
{% tab title="Macintosh" %}

```bash
mkdir ~/constellation-backup
cp /Volumes/ColdStorage/my-p12file.p12 ~/constellation-backup/
cd ~/constellation-backup
ls -l
```

{% endtab %}

{% tab title="Windows" %}

* Connect your backup device or connect to your backup medium to your Windows 11 system.
* Use File Explorer to copy the file into your constellation backup directory under your local user's home directory.

```
constellation-backup
```

<div align="left"><figure><img src="https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2F0lL2RSEse51YbDiRGh7s%2Fimage.png?alt=media&#x26;token=c6c3217e-5cc3-4919-b2b2-047ab2b4692b" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2FtSzpUGFpUVWdMsgVL4GG%2Fimage.png?alt=media&#x26;token=db975812-e61e-4b68-9e51-f760d3e69be4" alt=""><figcaption></figcaption></figure></div>
{% endtab %}
{% endtabs %}

Verify that you see your p12 file listed.
{% endstep %}

{% step %}

### Open Terminal Application

{% tabs %}
{% tab title="Macintosh" %}
Macintosh MacOS Terminal   ![](https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2F7WQ1XbKT3oWTYOW33ZdR%2Fapple_terminal_icon.png?alt=media\&token=d276689b-b2a0-4bf0-a624-36ed14ab8b15)
{% endtab %}

{% tab title="Windows" %}
&#x20;Windows 11 Terminal App ![](https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2FXSVAwJPepanHpjeVWNTZ%2Fterminal_icon_img.png?alt=media\&token=8e0e351e-77f2-46c8-a392-19d862cf3fe5)  and make sure the terminal session opens a PowerShell prompt.

&#x20; ![](https://1221231704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZrtHSqcmP0ydsdSnYXRM%2Fuploads%2FtxWKc5dImmjUUJ67h5PK%2Fimage.png?alt=media\&token=8705c453-f1ea-448a-9e6a-4726bfb6b27f)
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Connect to Your Node via SFTP

```bash
sftp -i ~/.ssh/my-node-ssh-keyname nodeadmin@123.123.123.123
```

{% endstep %}

{% step %}

### Navigate to Restore Location

We need to change directories to the location where we would like to place our p12 keystore file.

Change directories in your SFTP session:

```bash
cd /home/nodeadmin/tessellation
```

{% endstep %}

{% step %}

### Upload our P12 KeyStore

We will use the SFTP `put` command.

```bash
put my-p12file.p12
```

Expected output:

```
Uploading my-p12file.p12 to /home/nodeadmin/tessellation/my-p12file.p12
100% 31 0.6KB/s 00:00
```

{% endstep %}

{% step %}

### Exit SFTP Session

```bash
exit
```

{% endstep %}
{% endstepper %}
