# Pangolin Stack Management Script Guide for Update and Restore the Stack

**URL:** <https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457>\
**Category:** Networking\
**Tags:** scripts, management-system, pangolin\
**Created:** [February 5, 2025, 10:12am UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457 "2025-02-05T10:12:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [February 5, 2025, 10:12am UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/1 "2025-02-05T10:12:46Z")

</div>

[https://asciinema.org/a/QnoybaFPNxmZsIhu1LsY7kbsT](https://asciinema.org/a/QnoybaFPNxmZsIhu1LsY7kbsT)

# Watch the above Video before deploying the script.

## Introduction

Welcome to the guide for using the Pangolin Stack Management Script. This tool helps you manage your Pangolin deployment by providing robust backup, update, and restore capabilities. Whether you’re updating to the latest versions or need to roll back to a previous state, this script makes the process straightforward and safe.

## System Requirements

Before you begin using the script, ensure your system meets these requirements:

- Docker Engine (version 20.10.0 or higher)
- Docker Compose V2
- Bash shell environment
- Standard Unix utilities (grep, sed, awk)
- At least 1GB of free disk space for backups
- Read/write permissions in the script’s directory

## Installation

Setting up the script is straightforward:

1. Save the script to your Pangolin project directory:

```bash
wget https://gist.githubusercontent.com/hhftechnology/96bc511034a20ae081139bd2306906bf/raw/5bddbbf349920e7df456c5b6b0bdf952d8fe0e11/update-stack.sh -O update-stack.sh

```

1. Make it executable:

```bash
chmod +x update-stack.sh

```

## Core Features

The script provides two main functions:

1. **Update Mode** : Safely updates your services to new versions while creating backups
2. **Restore Mode** : Returns your stack to a previous working state

Each operation includes built-in safety checks and comprehensive logging.

## Updating Your Stack

To update your Pangolin stack, follow these steps:

1. Start the update process:

```bash
./update-stack.sh update

```

1. You’ll see your current versions displayed:

```auto
Current versions:
------------------------
Current Pangolin tag: 1.0.0-beta.9
Current Gerbil tag: 1.0.0-beta.3
Current Traefik tag: v3.1

```

1. For each service, you can:

2. Review the summary of changes:

```auto
Summary of changes:
------------------------
Pangolin: 1.0.0-beta.9 -> 1.0.0-beta.10
Gerbil: 1.0.0-beta.3 -> 1.0.0-beta.3
Traefik: v3.1 -> v3.2
------------------------

```

1. Confirm the changes by typing ‘y’ when prompted

During the update, the script will:

- Create a timestamped backup
- Safely stop all services
- Update the specified versions
- Restart the stack
- Verify all services are running properly

## Restoring Your Stack

You have two options for restoration:

1. Restore to the most recent backup:

```bash
./update-stack.sh restore

```

1. Restore to a specific backup:

```bash
./update-stack.sh restore ./backups/20250205_062549

```

The restoration process:

1. Validates the backup’s integrity
2. Gracefully stops current services
3. Restores configuration files
4. Restarts the stack with the backup’s settings
5. Verifies service health

## Understanding Backups

Each backup is stored in the `./backups` directory with a timestamp format (e.g., `20250205_062549`). A backup contains:

- `docker-compose.yml`: The complete stack configuration
- `config/`: All configuration files
- `update.log`: Detailed operation logs
- `old_tags.txt`: Record of service versions

## Best Practices

To get the most out of the script, follow these guidelines:

### Before Updates

1. Review release notes for the new versions
2. Test updates in a non-production environment first
3. Ensure you have enough disk space for backups
4. Document any custom configurations

### During Operations

1. Never interrupt the script during execution
2. Monitor the logs for any warnings or errors
3. Wait for the final verification step to complete

### Backup Management

1. Keep at least three recent backups
2. Regularly test restore operations
3. Clean up old backups periodically
4. Store critical backups in a separate location

## Troubleshooting Guide

If you encounter issues, follow these steps:

### Update Failed

1. Check the logs in `./backups/[timestamp]/update.log`
2. Verify Docker has enough resources
3. Ensure all image versions exist in the registry
4. Try restoring to the previous state

### Restore Failed

1. Verify the backup directory exists and is complete
2. Check file permissions
3. Ensure enough disk space is available
4. Review service logs: `docker compose logs`

Common Error Solutions:

```bash
# If services won't start
docker compose logs

# If permission errors occur
sudo chown -R $(id -u):$(id -g) ./backups

# If cleanup is needed
docker system prune

```

## Maintenance Tasks

Regular maintenance helps keep your system healthy:

### Clean Old Backups

```bash
# Remove backups older than 30 days
find ./backups -type d -mtime +30 -exec rm -rf {} +

```

### Remove Unused Images

```bash
# Clean up old Docker images
docker image prune -a --filter "until=168h"

```

### Verify Backup Integrity

```bash
# List and check recent backups
ls -ltr ./backups/
./update-stack.sh restore ./backups/[timestamp] # Test restore

```

## Logging and Monitoring

The script maintains detailed logs of all operations:

- **Update Logs** : `./backups/[timestamp]/update.log`
- **Restore Logs** : `/tmp/restore_[pid].log`

Monitor these logs for:

- Service state changes
- Error messages
- Version changes
- Operation timing

## Security Considerations

The script includes several security features:

1. Validates input parameters
2. Uses secure file permissions
3. Implements graceful shutdowns
4. Maintains operation logs
5. Verifies service health

## Conclusion

This script simplifies managing your Pangolin stack while maintaining system reliability and safety. Regular backups and careful version management will help ensure your deployment remains stable and secure.

For additional help or to report issues, please refer to the project’s documentation or contact support.

Remember: Always test updates in a safe environment first, and maintain good backup practices for peace of mind.

---

<div class="post-metadata">

**Author:** ![player684](https://forum.hhf.technology/user_avatar/forum.hhf.technology/player684/32/677_2.png) [@player684](https://forum.hhf.technology/u/player684)\
**Post date:** [February 5, 2025, 11:39am UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/2 "2025-02-05T11:39:29Z")

</div>

Can I try this or you are still working on it? I’m asking because it’s a very new post. Thanks for the detailed write up and script. @hhf.technoloy

---

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [February 5, 2025, 11:46am UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/3 "2025-02-05T11:46:41Z")

</div>

i am still working on it. if you want to test is its all yours

---

<div class="post-metadata">

**Author:** ![player684](https://forum.hhf.technology/user_avatar/forum.hhf.technology/player684/32/677_2.png) [@player684](https://forum.hhf.technology/u/player684)\
**Post date:** [February 5, 2025, 12:50pm UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/4 "2025-02-05T12:50:31Z")

</div>

I’ll wait till you are happy with it 🙂

---

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [February 5, 2025, 1:33pm UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/5 "2025-02-05T13:33:31Z")

</div>

i have tested it multiple times. Works well for me. I have submitted to the developers to have a look.

---

<div class="post-metadata">

**Author:** ![gyrene2083](https://forum.hhf.technology/user_avatar/forum.hhf.technology/gyrene2083/32/67_2.png) [@gyrene2083](https://forum.hhf.technology/u/gyrene2083)\
**Post date:** [February 5, 2025, 5:08pm UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/6 "2025-02-05T17:08:55Z")

</div>

I can attest to testing the script to do the update and it worked flawlessly. I haven’t tested the restore as of yet, but the updating was flawless.

---

<div class="post-metadata">

**Author:** ![joshcrosby](https://forum.hhf.technology/user_avatar/forum.hhf.technology/joshcrosby/32/865_2.png) [@joshcrosby](https://forum.hhf.technology/u/joshcrosby)\
**Post date:** [March 18, 2025, 3:23am UTC](https://forum.hhf.technology/t/pangolin-stack-management-script-guide-for-update-and-restore-the-stack/457/9 "2025-03-18T03:23:25Z")

</div>

Getting this error when running this script:

```auto
./update-stack.sh: line 37: LOG_FILE: unbound variable
```
