Showing posts with label backup. Show all posts
Showing posts with label backup. Show all posts

Thursday, November 14, 2024

Update Home Assistant docker installation

In order to safely update your docker container in a Synology NAS. I assume you manage your docker containers via docker-compose

  1. List the running containers
    docker ps
  2. Go to the docker folder
    cd /volume1/docker
  3. Copy the configuration (if needed)
    cp -rp ha /volume2/backups/ha-bak.25.x
  4. Stop the container
    docker stop homeassistant
  5. Make a backup
    docker commit homeassistant homeassistant-backup:version-25.x
  6. Pull the latest image
    docker pull ghcr.io/home-assistant/home-assistant:stable

    or if you want a specific version
    docker pull ghcr.io/home-assistant/home-assistant:2024.11.3
  7. Remove the container
    docker rm homeassistant
  8. If you have a specific version to use, edit the version of the image in the docker-compose file to the downloaded one (2024.11.3, default is stable)
    vi docker-compose.yaml
  9. Start up the new container
    docker-compose --verbose up -d homeassistant

Checklist afterwards:

  • Check if configuration is loaded correctly:
    docker exec homeassistant python -m homeassistant --script check_config --config /config
  • Check for version: Settings > About
  • Check for logs: Settings > System > Logs
  • Update HACS plugins if needed
For a full recovery of a container:
  1. Stop and Remove the Current Container:
    docker stop homeassistant

    docker rm homeassistant
  2. Run a New Container from the Backup Image (or edit your docker-compose.yaml and start with docker-compose):
    docker run -d --name homeassistant \ --restart=unless-stopped \ -v /volume1/docker/ha:/config \ -e TZ=Europe/Paris \ --net=host \ homeassistant-backup:version-24.11


Saturday, February 9, 2019

Docker: update a container but take a backup first

You have ever downloaded a Docker image on your Synology and created a container out of it. Now like with the Unifi Controller, the software inside gets updated, so you also need to update the corresponding image. It's safe to take a backup of your container first before continuing.

Backup and restore of a container

  1. List the container you want to backup (the container must be running)
  2. docker ps
    Output:
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES 78727078a04b        debian:8            "/bin/bash"         13 seconds ago      Up 11 seconds                           unifi
  3. Take a snapshot of the running state
  4. docker commit -p  78727078a04b  unifi-20190209
    e09f9ac65c8b3095927c14ca0594868f73831bde0800ce66415afeb91aea93cf
  5. Verify that a snapshot has been stored with your images
  6. docker images
    REPOSITORY                      TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    unifi-20190209                  latest              e09f9ac65c8b        39 seconds ago      125.1 MB
  7. Save as a tar and archive, just in case
  8. docker save -o /volume1/docker/unifi/backups/unifi-20190209.tar unifi-20190209
    user:/volume1/docker/unifi/backups# ls -lh
    total 536M
    -rw------- 1 root root 536M Feb  9 08:59 unifi-20190209.tar
  9. If you want to restore, do a login first and then push the image
  10. docker login
    docker push unifi-20190209

Update a container on your Synology

  1. Login to your Synology DSM and go to the Docker app
  2. Go to the 'Image' repository. Check for the image that you started from and verify the tag you used (e.g. jacobalberty/unifi:stable)
  3. Go to the 'Container' part and stop the container that you want to update
  4. Go to the 'Registry' part and search for the image. When you found the corresponding image (e.g. jacobalberty/unifi), right click and choose 'Download this image'. You will start seeing the image being downloaded as the number 1 will appear next to 'Image'. Wait until the download is completed.
  5. Go back to the 'Container' part, select the container (it is still in stopped state). Click on 'Action' and click on 'Clear'. Do not click on Delete. The container will dissapear and reappear.
  6. Once it reappears, you can start it again.
More screenshots here.