TandoorRecipes/docs/system/updating.md
2023-11-28 15:48:33 -06:00

2.8 KiB

The Updating process depends on your chosen method of installation

While intermediate updates can be skipped when updating please make sure to read the release notes in case some special action is required to update.

Docker

For all setups using Docker the updating process look something like this

  1. Before updating it is recommended to create a backup!
  2. Stop the container using docker-compose down
  3. Pull the latest image using docker-compose pull
  4. Start the container again using docker-compose up -d

Manual

For all setups using a manual installation updates usually involve downloading the latest source code from GitHub. After that make sure to run:

  1. pip install -r requirements.txt
  2. manage.py collectstatic
  3. manage.py migrate
  4. cd ./vue
  5. yarn install
  6. yarn build

To install latest libraries, apply all new migrations and collect new static files.

PostgreSQL

Postgres does not automatically upgrade database files when you change versions and requires manual intervention. One option is to manually backup/restore the database.

A full list of options to upgrade a database provide in the official PostgreSQL documentation.

  1. Collect information about your environment.
grep -E 'POSTGRES|DATABASE' ~/.docker/compose/.env
docker ps -a --format 'table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Status}}' | awk 'NR == 1 || /postgres/ || /recipes/'

[ ] Database Container [ ] Tandoor Container [ ] Database User

  1. Export the tandoor database
    docker exec -t {{database_container}} pg_dumpall -U {{djangouser}} > ~/tandoor.sql
    
  2. Stop the postgres container
    docker stop {{database_container}} {{tandoor_container}}
    
  3. Rename the tandoor volume
    sudo mv -R ~/.docker/compose/postgres ~/.docker/compose/postgres.old
    
  4. Update image tag on postgres container.
    db_recipes:
      restart: always
      image: postgres:16-alpine
      volumes:
        - ./postgresql:/var/lib/postgresql/data
      env_file:
        - ./.env
    
  5. Pull and rebuild container.
    docker-compose pull && docker-compose up -d
    
  6. Import the database export
    cat ~/tandoor.sql | sudo docker exec -i {{database_container}} psql postgres -U {{djangouser}}
    

If anything fails, go back to the old postgres version and data directory and try again.

There are many articles and tools online that might provide a good starting point to help you upgrade 1, 2, 3.