|
| 1 | +--- |
| 2 | +title: Enterprise Server Upgrade Automation |
| 3 | +intro: You can use the ghes-manage API or `es` plugin to automate upgrade operations in Enterprise Server environments. |
| 4 | +versions: |
| 5 | + ghes: '>= 3.21' |
| 6 | +shortTitle: Upgrade Enterprise Server |
| 7 | +contentType: how-tos |
| 8 | +--- |
| 9 | + |
| 10 | +You can upgrade a GitHub Enterprise Server instance using the Manage {% data variables.product.prodname_ghe_server %} API or the `gh es` CLI extension. These tools automate the process of downloading the upgrade package, running pre-upgrade checks, and applying the new version. |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- Back up your data with [GitHub Enterprise Server Backup Utilities](https://github.com/github/backup-utils#readme). |
| 15 | +- Schedule a maintenance window for end users. |
| 16 | +- Ensure you have authentication credentials for the Manage {% data variables.product.prodname_ghe_server %} API. For more information, see [AUTOTITLE](/rest/enterprise-admin#authentication). |
| 17 | + |
| 18 | +## Step 1: Download the upgrade package |
| 19 | + |
| 20 | +Download the upgrade package to the instance. |
| 21 | + |
| 22 | +### Using the CLI |
| 23 | + |
| 24 | +```shell |
| 25 | +# Download a specific version |
| 26 | +gh es upgrade download --version VERSION |
| 27 | + |
| 28 | +# Or download the latest available version |
| 29 | +gh es upgrade download |
| 30 | +``` |
| 31 | + |
| 32 | +### Using the API |
| 33 | + |
| 34 | +```shell |
| 35 | +curl -L \ |
| 36 | + -X POST \ |
| 37 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 38 | + -H "Content-Type: application/json" \ |
| 39 | + https://HOSTNAME:8443/manage/v1/upgrade/download \ |
| 40 | + -d '{"version":"VERSION"}' |
| 41 | +``` |
| 42 | + |
| 43 | +## Step 2: Monitor download progress |
| 44 | + |
| 45 | +Confirm the download has completed before proceeding. |
| 46 | + |
| 47 | +### Using the CLI |
| 48 | + |
| 49 | +```shell |
| 50 | +gh es upgrade download status |
| 51 | +``` |
| 52 | + |
| 53 | +### Using the API |
| 54 | + |
| 55 | +```shell |
| 56 | +curl -L \ |
| 57 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 58 | + -H "Content-Type: application/json" \ |
| 59 | + https://HOSTNAME:8443/manage/v1/upgrade/download/status |
| 60 | +``` |
| 61 | + |
| 62 | +Wait until `status` shows `COMPLETED`. |
| 63 | + |
| 64 | +## Step 3: Apply the upgrade's pre-upgrade phase |
| 65 | + |
| 66 | +Apply the upgrade. This runs both the pre-upgrade and upgrade phases sequentially. |
| 67 | + |
| 68 | +### Using the CLI |
| 69 | + |
| 70 | +```shell |
| 71 | +gh es upgrade apply --version VERSION --phase pre-upgrade |
| 72 | +``` |
| 73 | + |
| 74 | +### Using the API |
| 75 | + |
| 76 | +```shell |
| 77 | +curl -L \ |
| 78 | + -X POST \ |
| 79 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 80 | + -H "Content-Type: application/json" \ |
| 81 | + https://HOSTNAME:8443/manage/v1/upgrade/apply \ |
| 82 | + -d '{"version":"VERSION", "phase":"pre-upgrade}' |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +## Step 4: Monitor pre-upgrade progress |
| 87 | + |
| 88 | +Monitor the upgrade until it completes. The instance will reboot once the upgrade finishes. |
| 89 | + |
| 90 | +### Using the CLI |
| 91 | + |
| 92 | +```shell |
| 93 | +gh es upgrade status --verbose |
| 94 | +``` |
| 95 | + |
| 96 | +### Using the API |
| 97 | + |
| 98 | +```shell |
| 99 | +curl -L \ |
| 100 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 101 | + -H "Content-Type: application/json" \ |
| 102 | + "https://HOSTNAME:8443/manage/v1/upgrade/status?verbose=true" |
| 103 | +``` |
| 104 | + |
| 105 | +Wait until `status` shows `completed` and `is_running` shows `false`. |
| 106 | + |
| 107 | +## Step 5: Enable maintenance mode |
| 108 | + |
| 109 | +Enable maintenance mode. |
| 110 | + |
| 111 | +### Using the CLI |
| 112 | + |
| 113 | + ```shell |
| 114 | + gh es maintenance set --enabled true |
| 115 | + ``` |
| 116 | + |
| 117 | +### Using the API |
| 118 | + |
| 119 | + ```shell |
| 120 | + curl -L \ |
| 121 | + -X POST \ |
| 122 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 123 | + -H "Content-Type: application/json" \ |
| 124 | + https://HOSTNAME:8443/manage/v1/maintenance \ |
| 125 | + -d '{"enabled":true}' |
| 126 | + ``` |
| 127 | + |
| 128 | +## Step 6: Apply the upgrade's upgrade phase |
| 129 | + |
| 130 | +Apply the upgrade. This runs both the pre-upgrade and upgrade phases sequentially. |
| 131 | + |
| 132 | +### Using the CLI |
| 133 | + |
| 134 | +```shell |
| 135 | +gh es upgrade apply --version VERSION --phase pre-upgrade |
| 136 | +``` |
| 137 | + |
| 138 | +### Using the API |
| 139 | + |
| 140 | +```shell |
| 141 | +curl -L \ |
| 142 | + -X POST \ |
| 143 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 144 | + -H "Content-Type: application/json" \ |
| 145 | + https://HOSTNAME:8443/manage/v1/upgrade/apply \ |
| 146 | + -d '{"version":"VERSION", "phase":"pre-upgrade}' |
| 147 | +``` |
| 148 | + |
| 149 | +## Step 7: Verify and disable maintenance mode |
| 150 | + |
| 151 | +After the upgrade completes: |
| 152 | + |
| 153 | +First, confirm the release version has been updated. |
| 154 | + |
| 155 | +### Using the CLI |
| 156 | + |
| 157 | + ```shell |
| 158 | + gh es release version |
| 159 | + ``` |
| 160 | + |
| 161 | +### Using the API |
| 162 | + |
| 163 | + ```shell |
| 164 | + curl -L \ |
| 165 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 166 | + -H "Content-Type: application/json" \ |
| 167 | + https://HOSTNAME:8443/manage/v1/version |
| 168 | + ``` |
| 169 | + |
| 170 | +Then, disable maintenance mode. |
| 171 | + |
| 172 | +### Using the CLI |
| 173 | + |
| 174 | + ```shell |
| 175 | + gh es maintenance set --enabled false |
| 176 | + ``` |
| 177 | + |
| 178 | +### Using the API |
| 179 | + |
| 180 | + ```shell |
| 181 | + curl -L \ |
| 182 | + -X POST \ |
| 183 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 184 | + -H "Content-Type: application/json" \ |
| 185 | + https://HOSTNAME:8443/manage/v1/maintenance \ |
| 186 | + -d '{"enabled":false}' |
| 187 | + ``` |
| 188 | + |
| 189 | +## Upgrading a high availability deployment |
| 190 | + |
| 191 | +For instances with a high availability (HA) replica, the download and pre-upgrade phases are non-disruptive and can run across all nodes at once. UUID targeting is only needed for the upgrade phase itself, which triggers the reboot. This lets you control the order nodes reboot in: upgrade the replica first, then the primary. |
| 192 | + |
| 193 | +To retrieve node UUIDs, run `gh es config get-metadata` or query `GET /manage/v1/config/nodes`. |
| 194 | + |
| 195 | +### Using the CLI |
| 196 | + |
| 197 | +```shell |
| 198 | +# Download the package to all nodes |
| 199 | +gh es upgrade download --version VERSION |
| 200 | + |
| 201 | +# Wait for download to complete on all nodes |
| 202 | +gh es upgrade download status |
| 203 | + |
| 204 | +# Run pre-upgrade on all nodes at once (non-disruptive) |
| 205 | +gh es upgrade apply --version VERSION --phase pre-upgrade |
| 206 | + |
| 207 | +# Wait for pre-upgrade to complete |
| 208 | +gh es upgrade status --verbose |
| 209 | + |
| 210 | +# Enable maintenance mode |
| 211 | +gh es maintenance set --enabled true |
| 212 | + |
| 213 | +# Upgrade the replica first (triggers reboot) |
| 214 | +gh es upgrade apply --version VERSION --phase upgrade --uuid REPLICA-UUID |
| 215 | +gh es upgrade status --uuid REPLICA-UUID --verbose |
| 216 | + |
| 217 | +# After the replica finishes, upgrade the primary |
| 218 | +gh es upgrade apply --version VERSION --phase upgrade --uuid PRIMARY-UUID |
| 219 | +gh es upgrade status --uuid PRIMARY-UUID --verbose |
| 220 | + |
| 221 | +# Verify replication health and version, then disable maintenance mode |
| 222 | +gh es replication status |
| 223 | +gh es release version |
| 224 | +gh es maintenance set --enabled false |
| 225 | +``` |
| 226 | + |
| 227 | +### Using the API |
| 228 | + |
| 229 | +```shell |
| 230 | +# Download the package to all nodes |
| 231 | +curl -L -X POST \ |
| 232 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 233 | + -H "Content-Type: application/json" \ |
| 234 | + https://HOSTNAME:8443/manage/v1/upgrade/download \ |
| 235 | + -d '{"version":"VERSION"}' |
| 236 | + |
| 237 | +# Wait for download to complete on all nodes |
| 238 | +curl -L \ |
| 239 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 240 | + -H "Content-Type: application/json" \ |
| 241 | + https://HOSTNAME:8443/manage/v1/upgrade/download/status |
| 242 | + |
| 243 | +# Run pre-upgrade on all nodes at once (non-disruptive) |
| 244 | +curl -L -X POST \ |
| 245 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 246 | + -H "Content-Type: application/json" \ |
| 247 | + https://HOSTNAME:8443/manage/v1/upgrade/apply \ |
| 248 | + -d '{"version":"VERSION","phase":"pre-upgrade"}' |
| 249 | + |
| 250 | +# Wait for pre-upgrade to complete |
| 251 | +curl -L \ |
| 252 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 253 | + -H "Content-Type: application/json" \ |
| 254 | + "https://HOSTNAME:8443/manage/v1/upgrade/status?verbose=true" |
| 255 | + |
| 256 | +# Enable maintenance mode |
| 257 | +curl -L -X POST \ |
| 258 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 259 | + -H "Content-Type: application/json" \ |
| 260 | + https://HOSTNAME:8443/manage/v1/maintenance \ |
| 261 | + -d '{"enabled":true}' |
| 262 | + |
| 263 | +# Upgrade the replica first (triggers reboot) |
| 264 | +curl -L -X POST \ |
| 265 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 266 | + -H "Content-Type: application/json" \ |
| 267 | + https://HOSTNAME:8443/manage/v1/upgrade/apply \ |
| 268 | + -d '{"version":"VERSION","phase":"upgrade","uuid":"REPLICA-UUID"}' |
| 269 | + |
| 270 | +# Monitor replica upgrade |
| 271 | +curl -L \ |
| 272 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 273 | + -H "Content-Type: application/json" \ |
| 274 | + "https://HOSTNAME:8443/manage/v1/upgrade/status?uuid=REPLICA-UUID&verbose=true" |
| 275 | + |
| 276 | +# After the replica finishes, upgrade the primary |
| 277 | +curl -L -X POST \ |
| 278 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 279 | + -H "Content-Type: application/json" \ |
| 280 | + https://HOSTNAME:8443/manage/v1/upgrade/apply \ |
| 281 | + -d '{"version":"VERSION","phase":"upgrade","uuid":"PRIMARY-UUID"}' |
| 282 | + |
| 283 | +# Monitor primary upgrade |
| 284 | +curl -L \ |
| 285 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 286 | + -H "Content-Type: application/json" \ |
| 287 | + "https://HOSTNAME:8443/manage/v1/upgrade/status?uuid=PRIMARY-UUID&verbose=true" |
| 288 | + |
| 289 | +# Verify replication health and version, then disable maintenance mode |
| 290 | +curl -L \ |
| 291 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 292 | + -H "Content-Type: application/json" \ |
| 293 | + https://HOSTNAME:8443/manage/v1/replication/status |
| 294 | + |
| 295 | +curl -L \ |
| 296 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 297 | + -H "Content-Type: application/json" \ |
| 298 | + https://HOSTNAME:8443/manage/v1/version |
| 299 | + |
| 300 | +curl -L -X POST \ |
| 301 | + -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \ |
| 302 | + -H "Content-Type: application/json" \ |
| 303 | + https://HOSTNAME:8443/manage/v1/maintenance \ |
| 304 | + -d '{"enabled":false}' |
| 305 | +``` |
0 commit comments