|
| 1 | +--- |
| 2 | +sidebar_position: 9 |
| 3 | +--- |
| 4 | + |
| 5 | + |
| 6 | +## System Upgrade Guide (1Panel) |
| 7 | + |
| 8 | +Compare with the latest mirror version of the ThingsPanel community edition (mainly refer to the `docker-compose.yml` file in the [ThingsPanel Quick Start Guide](/docs/quick_start)) |
| 9 | + |
| 10 | +### Version Compatibility Note |
| 11 | +**Main Reference:** [ThingsPanel System Upgrade Guide](/docs/installation/system_upgrade) |
| 12 | + |
| 13 | +:::caution IMPORTANT |
| 14 | +Direct upgrade from **0.5.4** to **1.0.0** is NOT supported. You need to **re-deploy**. |
| 15 | +::: |
| 16 | + |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 2. Log in to the 1Panel Dashboard |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 3. Docker Deployment Upgrade Guide |
| 25 | + |
| 26 | +:::caution IMPORTANT |
| 27 | +You can also choose to use cloud service snapshots for backup. |
| 28 | +::: |
| 29 | + |
| 30 | +### 3.1 Pre-upgrade Preparation (Data Backup) |
| 31 | + |
| 32 | +#### 3.1.1 Backup Database and Storage Volumes |
| 33 | + |
| 34 | +Log in to the server terminal and execute the following backup commands: |
| 35 | + |
| 36 | +```bash |
| 37 | +# 1. Create backup directory |
| 38 | +BACKUP_DIR="/data/backups/thingspanel/20260305" |
| 39 | +mkdir -p "$BACKUP_DIR" |
| 40 | + |
| 41 | +# 2. Backup database (Note: replace with absolute container name if different) |
| 42 | +docker exec thingspanel-docker-postgres-1 \ |
| 43 | + pg_dump -U postgres -d ThingsPanel \ |
| 44 | + -F c -Z 6 \ |
| 45 | + --no-tablespaces \ |
| 46 | + > "$BACKUP_DIR/ThingsPanel.dump" |
| 47 | + |
| 48 | +# Verify backup result: ls -lh "$BACKUP_DIR/ThingsPanel.dump" Ensure file size is not zero |
| 49 | + |
| 50 | +# 3. Backup backend volumes (configs and files) |
| 51 | +# If the frontend configuration file has been modified, it also needs to be backed up |
| 52 | +docker cp thingspanel-docker-backend-1:/go/src/app/configs "$BACKUP_DIR/configs" |
| 53 | +docker cp thingspanel-docker-backend-1:/go/src/app/files "$BACKUP_DIR/files" |
| 54 | +``` |
| 55 | + |
| 56 | +#### 3.1.2 Backup docker-compose.yml |
| 57 | + |
| 58 | +1. Go to the 1Panel dashboard -> **Containers** -> **Compose** -> Edit **thingspanel-docker** and copy the current configuration. |
| 59 | + |
| 60 | + |
| 61 | +2. Save a backup of this file from the terminal: |
| 62 | + ```bash |
| 63 | + cd "$BACKUP_DIR" |
| 64 | + vi docker-compose.yml.bak |
| 65 | + # Paste the copied content, save and exit |
| 66 | + ``` |
| 67 | + |
| 68 | +### 3.2 Choose Upgrade Method |
| 69 | + |
| 70 | +You can choose one of the following two upgrade methods: |
| 71 | +- **Partial Container Upgrade** (Update specific services only) |
| 72 | +- **Full System Upgrade** (Update all components) |
| 73 | + |
| 74 | +### 3.3 Partial Container Upgrade Process |
| 75 | + |
| 76 | +#### Container and Service Mapping |
| 77 | + |
| 78 | +- **Frontend Service:** `thingspanel-vue:nginx` |
| 79 | +- **MQTT Service:** `thingspanel-gmqtt:gmqtt` |
| 80 | +- **Backend Service:** `thingspanel-go:go` |
| 81 | + |
| 82 | +#### Modify Configuration and Version |
| 83 | + |
| 84 | +1. Log in to the 1Panel dashboard. |
| 85 | +2. Navigate to **Containers** -> **Compose** -> Edit **thingspanel-docker**. |
| 86 | +3. Change to the corresponding image versions. |
| 87 | +4. Click **Save** and wait for the container update and deployment to complete. |
| 88 | + |
| 89 | +:::tip Tip |
| 90 | +If the new version uses the same image tag, please make sure to **delete the old image and pull again** in local image management to get the latest layers. |
| 91 | +::: |
| 92 | + |
| 93 | +### 3.4 Update Configuration Files |
| 94 | + |
| 95 | +Go to the official repository `thingspanel-backend-community/configs/` directory and check if there are any changes in the following files: |
| 96 | +- `configs/conf.yml` |
| 97 | +- `messages_str.yaml` |
| 98 | +- `messages.yaml` |
| 99 | + |
| 100 | +If there are new additions or changes to the official version configuration, please compare the changes and synchronize them to the target server's `thingspanel-docker_go_configs` volume (edit in 1Panel dashboard **Containers** -> **Volumes**). |
| 101 | + |
| 102 | +### 3.5 Restart Service |
| 103 | + |
| 104 | +After any manual configuration updates, please restart the corresponding container service to apply the configuration. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 4. Anomaly Recovery and Rollback |
| 109 | + |
| 110 | +If an exception occurs or the upgrade fails, you can refer to the following steps to recover data. |
| 111 | + |
| 112 | +### 4.1 Database Recovery Process |
| 113 | + |
| 114 | +```bash |
| 115 | +# Step 1: Stop services connecting to the database (postgres must be kept running for subsequent queries) |
| 116 | +docker stop thingspanel-docker-backend-1 tp-images-test-gmqtt-1 tp-images-test-frontend-1 |
| 117 | + |
| 118 | +# Step 2: Rebuild database and initialize TimescaleDB extension |
| 119 | +docker exec -i thingspanel-docker-postgres-1 psql -U postgres << 'EOF' |
| 120 | +DROP DATABASE IF EXISTS "ThingsPanel"; |
| 121 | +CREATE DATABASE "ThingsPanel"; |
| 122 | +\c ThingsPanel |
| 123 | +CREATE EXTENSION IF NOT EXISTS timescaledb; |
| 124 | +EOF |
| 125 | + |
| 126 | +# Step 3: Import recovery data (use --disable-triggers to avoid circular foreign key errors) |
| 127 | +docker exec -i thingspanel-docker-postgres-1 \ |
| 128 | + pg_restore -U postgres -d ThingsPanel \ |
| 129 | + --no-owner \ |
| 130 | + --disable-triggers \ |
| 131 | + -F c \ |
| 132 | + < "$BACKUP_DIR/ThingsPanel.dump" |
| 133 | +``` |
| 134 | + |
| 135 | +### 4.2 Recover Backend Volume Data (As Needed) |
| 136 | + |
| 137 | +If configuration is lost, you can use previous backups to recover it: |
| 138 | + |
| 139 | +```bash |
| 140 | +# Copy backup configuration and files back to the container |
| 141 | +docker cp "$BACKUP_DIR/configs" thingspanel-docker-backend-1:/go/src/app/ |
| 142 | +docker cp "$BACKUP_DIR/files" thingspanel-docker-backend-1:/go/src/app/ |
| 143 | +``` |
| 144 | + |
| 145 | +### 4.3 Restart Services |
| 146 | + |
| 147 | +After completing data recovery, restart the previously stopped services: |
| 148 | + |
| 149 | +```bash |
| 150 | +# Start the related services stopped in the above process |
| 151 | +docker start thingspanel-docker-backend-1 tp-images-test-gmqtt-1 tp-images-test-frontend-1 |
| 152 | +``` |
0 commit comments