# Backup & Restore Script to go-zenon and go-hyperqube

**URL:** https://forum.hypercore.one/t/backup-restore-script-to-go-zenon-and-go-hyperqube/588
**Category:** How To
**Created:** [February 22, 2025, 12:42am UTC](https://forum.hypercore.one/t/backup-restore-script-to-go-zenon-and-go-hyperqube/588 "2025-02-22T00:42:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![0x3639](https://forum.hypercore.one/user_avatar/forum.hypercore.one/0x3639/32/33_2.png) [@0x3639](https://forum.hypercore.one/u/0x3639)
#### Post date: [February 22, 2025, 12:42am UTC](https://forum.hypercore.one/t/backup-restore-script-to-go-zenon-and-go-hyperqube/588/1 "2025-02-22T00:42:54Z")

</div>

# Go-Zenon & Go-Hyperqube Backup & Restore Script

Easily back up and restore data for `go-zenon` and `go-hyperqube` with minimal downtime. The script manages key directories (`nom`, `network`, `consensus`, `cache`) and ensures you don’t run out of disk space.

* * *

## 🔧 Requirements

✅ **Root Access:** Run with `sudo`.  
✅ **Linux:** Works on Debian/Ubuntu-based systems.  
✅ **Disk Space:** At least **10GB free** in `/backup` (configurable).  
✅ **Services:** Must have `go-zenon` or `go-hyperqube` installed via `systemctl`.

* * *

## 📥 Setup

1️⃣ **Download the Script:**  
📌 [Script Link](https://gist.github.com/0x3639/4f3cea99b06b428a326974103cdf0cbe)

Run one of the following:

```bash
wget -O backup_restore.sh https://gist.githubusercontent.com/0x3639/4f3cea99b06b428a326974103cdf0cbe/raw

```

OR

```bash
curl -o backup_restore.sh https://gist.githubusercontent.com/0x3639/4f3cea99b06b428a326974103cdf0cbe/raw

```

2️⃣ **Make it Executable:**

```bash
chmod +x backup_restore.sh

```

3️⃣ **Verify Dependencies:**  
The script will **auto-install `tar`** if missing (when run with `sudo`).

* * *

## 🚀 Usage

### **📌 Backup**

```bash
sudo ./backup_restore.sh <service> --backup

```

🔹 **Example:**

```bash
sudo ./backup_restore.sh go-zenon --backup

```

✅ **What Happens?**

- Stops the service
- Copies necessary data to `/backup/temp`
- Restarts the service
- Creates a `.tar.gz` archive in `/backup`
- Verifies integrity (hash check)
- Deletes old backups (keeps the **5 most recent** )

* * *

### **📌 Restore**

```bash
sudo ./backup_restore.sh <service> --restore

```

🔹 **Example:**

```bash
sudo ./backup_restore.sh go-hyperqube --restore

```

✅ **What Happens?**

- Prompts for backup date (format: `MM-DD-YY`)
- Finds the latest backup for that date
- Verifies integrity (hash check)
- Stops the service
- Moves existing data to `/backup/restore` (for rollback)
- Extracts the backup
- Restarts the service

* * *

## ⚙ Configuration

🛠 **Adjust settings inside the script:**

- **Disk Space:** Change `MIN_FREE_SPACE` (default **5GB** ).
- **Backup Retention:** Modify `MAX_BACKUPS` (default **5** ).
- **Storage Paths:**
  - Backups: `/backup`
  - Temporary: `/backup/temp`
  - Old Data: `/backup/restore`

* * *

## 📝 Notes

🔹 Missing folders (`cache`, etc.) are **skipped** (not an error).  
🔹 Requires **10GB free space** (2x `MIN_FREE_SPACE`) to proceed.  
🔹 Always run with **`sudo`** to manage services.

* * *

This version keeps things **concise, easy to follow, and action-oriented** while ensuring users can quickly implement the backup & restore process. 🚀
