# Updates, update steps and going back

Publish a new version of a site, see each step as it runs, change the update steps, go back to an earlier version, and when visitors can notice an update.

An **update** puts a new version of your site live. Fuzops gets the newest code, prepares it beside the live version, then switches visitors over. Visitors keep seeing the current version until the new one is ready. Technical name: deployment.

## Publish an update

Choose **Publish update**. It is on the site's Overview, in the bar at the bottom of every other page of the site, and on each row of **Sites**. Publishing needs no confirmation: it is frequent, it can be undone, and visitors are not affected until the switch.

Fuzops takes the newest code from the site's branch (see [Update settings](#update-settings)), or the newest `.zip` you uploaded, and runs the site's update steps.

## The update page

Each update has its own page. It opens when you publish, and from any row of the site's **Updates** tab or of **Updates** in the main menu.

- The first line says how it went, for example "Update of node.real-test.test. Published on both servers."
- Under it: who started it, the branch and change, the server or servers, when it started and how long it took.
- **Steps of this update**: each step with its state, its server, the time and how long it took. Open a step to see its **Last lines**.
- **Download the full output** or **Open it in the activity log** for the complete output.

![The page of a published update with each step done, on the first of two servers](https://internal.fuzops.com/docs-img/update-published.webp "An update page: every step with its time and result.")

While it runs, **Cancel update** stops it. If the new version is not live yet, visitors keep the version they see now. If it is already live, only the remaining steps stop.

### When an update fails

The page first says what happened in one sentence, for example **The new version did not start**, and that visitors still see the version from before, then where it stopped, for example **Stopped at "Restart the app"**. Under it, the cause in plain words with **What to do**, and:

- **Send this to my developer** copies a link to the update and a short summary of what happened, ready to paste in a message.
- **See what went wrong** opens the site's logs around the time of the update; **Open the app's log** opens what the app itself printed.
- **Technical details** shows the step's technical name and exit code. The output itself is in the step, opened for you in the list of steps.

When the cause is fixed, choose **Publish again** in the bar at the bottom of the page. It runs every step once more with the newest code.

![A failed update: it stopped at Restart the app and the site was switched back to the version from before](https://internal.fuzops.com/docs-img/update-failed.webp "A failed update says where it stopped and what to do.")

See [Troubleshooting](https://internal.fuzops.com/docs/troubleshooting) and the guide [Fix "502 Bad Gateway" after an update](https://internal.fuzops.com/docs/guides/fix-502-bad-gateway).

## Update steps

The site's **Update steps** page (in the **Updates** tab) lists what happens, in order, each time you publish. Technical name: deploy script, deployment hooks.

![Update steps of a Laravel site: get the code, link shared files, install packages, build, migrations, then the switch and the steps after it](https://internal.fuzops.com/docs-img/site-update-steps.webp "Update steps. The line marks where visitors switch to the new version.")

- The first steps are marked **Always runs**: **Get the code** (into a new, separate folder; the live site is not touched) and **Link shared files** (connects files that must survive updates, such as the settings file and uploads, to the new version).
- Each kind of site starts with its own standard steps, for example **Install PHP packages**, **Build assets**, **Run database migrations** for Laravel.
- The line **Your site switches to the new version here** separates the steps that prepare the new version from the steps that run after it is live, such as **Reload PHP** and **Restart background workers**.

On each step you can turn it off or on, move it up or down, or **Change** it. **Add a step** adds your own command, before or after the switch. **Restore the standard steps** puts back the steps for that kind of site.

### Writing a step

The commands of a step go in a code editor with line numbers and colours. A new step starts with two lines of notes and a line that moves into the right folder, so you only add your own commands under them. **Find** (Ctrl+F, or Cmd+F on a Mac) finds and replaces text, **Ctrl+S** (Cmd+S) saves the step, and **Full screen** gives a long script the whole window.

![Adding an update step: the editor with its first lines filled in, and Values you can use under it](https://internal.fuzops.com/docs-img/site-update-step-editor.webp "A new update step and the values it can use.")

### Values you can use

**Values you can use**, under the editor, lists everything a step can read while it runs, each with a plain description and an example for this site: the new version's folder, the live folder, the project and shared folders, the web folder, the site's address, the server's public and private address, the code version (full and short), the branch, the repository, the change's message and who made it, this update's id and who started it, the PHP and Node.js versions, the site's server account and the version's name and time. **Insert** puts a name in the editor where your cursor is; **Copy** copies it. Typing `$` in the editor offers the names too.

The names you will use most:

| What it is | Name to type |
| --- | --- |
| The new version's folder (steps run here) | `$FUZOPS_RELEASE_PATH` |
| The live folder | `$FUZOPS_CURRENT_PATH` |
| The shared folder (settings file, uploads) | `$FUZOPS_SHARED_PATH` |
| The project folder | `$FUZOPS_SITE_ROOT` |
| The site's address | `$FUZOPS_SITE_URL` |
| Code version, short | `$FUZOPS_COMMIT_SHORT` |
| Branch | `$FUZOPS_BRANCH` |
| The change's message | `"$FUZOPS_COMMIT_MESSAGE"` |
| Who started the update | `"$FUZOPS_STARTED_BY"` |

Always write a name with `$` in front and inside double quotes, as in `cd "$FUZOPS_RELEASE_PATH"`. The message of a change is text someone else wrote: print it or store it, never run it. Steps written before these names existed keep working. Every name in your settings file is available too. **Quick commands** have the same list, with the values that apply outside an update.

### Where a step runs

When the site runs on more than one server, each of your own steps has **Where this step runs**: **Every server**, **Only the first server** or **Chosen servers**. Database changes run only on the first server by default, so they happen once. See [Several servers](https://internal.fuzops.com/docs/several-servers).

## The history and going back

The site's **Updates** tab lists every update, newest first, under one summary sentence: how many updates so far, when the last one was published, the share that went through, how long an update usually takes and how fast the site answered after recent updates. The update that is live is marked **Live now**. When the same code was published several times in a row, the list shows it once with **Same code published *N* times: show each**; opened, each earlier one reads **Published again** with its time.

![The Updates tab of a site with its summary and the list of updates](https://internal.fuzops.com/docs-img/site-updates.webp "Every update of a site, newest first.")

To go back:

- On the site's overview, the **Live now:** line under **Latest updates** has **Go back to the previous version**: one click and a confirmation.
- On the page of the update that is live, **Go back to the previous version** does the same.
- On the page of any other update whose version is still kept, **Use this version** switches the site to it. The **Versions** panel on an update page has **Use this version** beside each kept version too.
- In the history, open an update's row: **Use this version** is among its actions.

Going back deletes nothing, and you can publish a newer version again at any time. In the confirmation, **Run a one-off script after going back** (closed until you open it) lets you run a command once in the earlier version right after the switch, for example one that undoes a database change. It is not saved as a step.

You can go back to any version the server still keeps. **Number of versions to keep** (1 to 20, in **Update settings**) decides how many; more versions use more disk space.

## After-update check

The **After-update check** (in the **Updates** tab; technical name: health check) opens a page of your site after each update. If it does not answer properly, the site goes back to the version before. Choose a page that loads without signing in; Laravel 11 and newer have one ready at `/up`.

When the check is off, a new version stays live even if it broke the site.

![The After-update check page with the page to open](https://internal.fuzops.com/docs-img/site-after-update-check.webp "The page Fuzops opens after each update.")

## Update settings

**Update settings** (in the **Updates** tab) holds:

- **Branch**: the version of your code that gets published.
- **Versions and shared folders**: **Number of versions to keep** and **Extra shared folders**, folders whose files must survive updates, such as `public/uploads`. The settings file and, for Laravel, `storage` are always shared.
- **Copies of the app** (Node.js apps): see [Several servers and copies of the app](https://internal.fuzops.com/docs/several-servers#copies-of-the-app).
- **Across servers**: how an update goes when the site runs on more than one server.
- **Tell me about updates**: which updates of this site send you a message (started, published, failed, cancelled). Where messages go is set for the whole team on **Notifications**.
- **Background services** (Laravel): Horizon, Reverb, background worker and scheduled tasks.
- **Build elsewhere, publish here**: see [Builds sent from CI](https://internal.fuzops.com/docs/builds-from-ci).
- **Update automatically when the code changes**: publish each time new code reaches the branch, without pressing the button. Technical name: deploy hook. When the site's code comes from a connected code host, this is set up for you; with a pasted repository address you add the automatic-update address at your code host yourself (see **Site settings**).

![Update automatically when the code changes, turned on for the main branch](https://internal.fuzops.com/docs-img/site-auto-updates.webp "Automatic updates for one branch.")

## When visitors can notice an update

For most sites, visitors keep the current version until the new one is ready, and the switch is instant. These are the exceptions:

- **Apps that always listen on the same port.** Node.js, Python and Go apps are started beside the running copy and visitors move over only when the new copy answers. An app that ignores the port Fuzops gives it and always uses its own is restarted in place instead: a short break.
- **Restarts outside an update.** Saving the [Environment](https://internal.fuzops.com/docs/environment) with **Restart the app** ticked, running some **Quick commands**, switching the Node.js version, restoring a backup or refreshing a staging site restart the app in place: a short break.
- **Odoo.** Updating modules or changing Odoo settings restarts Odoo.
- **App on a port.** Fuzops does not start or update the program behind it.
- **Sites brought in from a server set up elsewhere**, until you choose **Keep it online during updates** for them: their files are changed where they are. See [Bring in a server](https://internal.fuzops.com/docs/bring-in-a-server).
- **Database changes.** Database migrations run before the switch, while the current version is still live. A change the current version cannot work with (for example renaming a column it reads) can cause errors until the switch. Make such changes in two updates.
- **Restarting the server** under **Maintenance** stops every site until the server is back.

## Related

- [Builds sent from CI](https://internal.fuzops.com/docs/builds-from-ci)
- [Several servers and copies of the app](https://internal.fuzops.com/docs/several-servers)
- [Guide: publish an update and go back if it breaks](https://internal.fuzops.com/docs/guides/publish-an-update-and-go-back)
