# Updating Apidog


### Pre-Update
Before initiating the update process for Apidog, it is strongly recommended to back up your application database. The Apidog application database is critical, as it houses essential data such as user accounts, teams, projects, permissions, and other application-specific configurations. While it is rare that you will need to restore to the previous version, having a backup ensures data integrity in case of unforeseen issues during the update.

For more detailed instructions on backing up your Apidog database, see [Backing up Apidog](doc-405313).

### Update Process for Apidog
Follow the steps below to update Apidog to the latest stable version:

1.  Ensure that the application database has been properly backed up as per the guidelines in the backup documentation. This provides an additional layer of protection against potential issues during the update.
2.  Terminate any running Apidog Docker containers to prepare for the update. This ensures that the current instance is stopped before deploying the new version. Execute the following command to stop the container:
    ```bash
    docker stop <container_name>
    ```
4.  Retrieve the latest version of the Apidog Docker image from the container registry. This ensures that you have the most up-to-date container image, containing bug fixes, enhancements, and security updates.
5.  *(Optional)* If you are using Docker Compose or Kubernetes, it is advisable to scale down the application to a single replica before initiating the container startup with the new image. This minimizes the risk of issues during the update and allows for more controlled database migration.

    For **Docker Compose**, use the following:
    ```bash
    docker-compose down    
    ```
    For **Kubernetes**, scale down the replicas:
    ```bash
    kubectl scale deployment apidog-deployment --replicas=1
    ```
6.  Update your deployment configuration (e.g., `docker-compose.yml` or Kubernetes deployment YAML) to reference the new Docker image tag. Be sure to replace `<tag>` with the specific version identifier you pulled
7.  Deploy the updated configuration to launch the new container with the latest version of Apidog.

    For **Docker Compose**, use the following:
    ```bash
    docker-compose up -d    
    ```
    For **Kubernetes**, scale down the replicas:
    ```bash
    kubectl apply -f apidog-deployment.yaml
    ```

:::info[Important Note on Replicas]
    During the initial startup of the updated Apidog container, any required database migrations will be executed automatically. Database migrations are crucial for synchronizing your database schema with the new version of the application. Since these migrations are not designed to run concurrently, it is critical to **limit the deployment to a single replica or container** when first applying the update. Once the migration process has successfully completed, you can scale the application back to its desired replica count.
:::


**Automatic Update Process**

Once the Apidog container starts, it will automatically trigger the update process. This includes both application code and database schema updates (if necessary). After the update completes, your Apidog environment will be running the latest version.

### Rolling Back an Update
If you encounter issues post-update and need to revert to a previous version, follow these steps:

1. Use the previously created database backup to restore your application’s data to its prior state. This ensures data consistency and integrity.

2. Roll back the Docker image to the version you were previously using. Update your deployment configuration to reference the rolled-back image tag and redeploy.


### Desktop Client Updates

For updating the Apidog Desktop Client, please refer to the [Installing the Apidog Client](https://self-hosting.apidog.com/installing-apidog-on-premises-client-700348m0.md#3-client-updates) guide.

