Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps - Status | Demo | Docs | Install
  1. Cloudron Forum
  2. Vaultwarden
  3. Vaultwarden fails to start after update – DB migration error (SSO)

Vaultwarden fails to start after update – DB migration error (SSO)

Scheduled Pinned Locked Moved Solved Vaultwarden
52 Posts 25 Posters 1.2k Views 25 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jdaviescoatesJ Offline
    jdaviescoatesJ Offline
    jdaviescoates
    wrote last edited by jdaviescoates
    #43

    @overholt Very likely you've hit the same thing as this thread. Solution here https://forum.cloudron.io/post/117779

    I use Cloudron with Gandi & Hetzner

    1 Reply Last reply
    1
    • marcusquinnM Offline
      marcusquinnM Offline
      marcusquinn
      wrote last edited by marcusquinn
      #44

      I used this issue to improve my aidevops cloudron subagent, and it managed to fix the issue on all instances. More info here for anyone interested to add this to your toolkit:

      • https://forum.cloudron.io/topic/14688/ai-devops

      Web Design & Development: https://www.evergreen.je
      Technology & Apps: https://www.marcusquinn.com

      1 Reply Last reply
      1
      • O Offline
        O Offline
        overholt
        wrote last edited by overholt
        #45

        Script fix works. Thank you!

        1 Reply Last reply
        3
        • ChristopherMagC ChristopherMag

          I have run the command sed -i 's/\r$//g' /app/data/fix_db.sh to fix the new line characters and then run bash /app/data/fix_db.sh again and it ran as expected. Disabled recover mode and confirmed things are back to working as expected.

          R Offline
          R Offline
          ryansebo
          wrote last edited by
          #46

          @ChristopherMag Thanks, this fixed my issue.

          1 Reply Last reply
          2
          • ChristopherMagC ChristopherMag

            I have run the command sed -i 's/\r$//g' /app/data/fix_db.sh to fix the new line characters and then run bash /app/data/fix_db.sh again and it ran as expected. Disabled recover mode and confirmed things are back to working as expected.

            C Offline
            C Offline
            composer
            wrote last edited by
            #47

            @ChristopherMag
            That worked for me, Thanks.

            1 Reply Last reply
            0
            • jamesJ james

              Hello @vaultwarden users

              Since users have voiced their concerns about manually editing the database I have created a bash script that does it for you.
              Please follow these steps if you have this issue:

              1. create an app backup of your @vaultwarden Cloudron app
              2. put the erroring @vaultwarden app in recovery mode
              3. open the File Manager of your @vaultwarden app and create a fix_db.sh file
              4. copy and paste the following script into the just created fix_db.sh file:
                #!/bin/bash
                
                echo "=> Checking if DEFAULT_CHARACTER_SET_NAME and DEFAULT_COLLATION_NAME are set to utf8mb4 and utf8mb4_unicode_ci"
                
                CURRENT_DEFAULT_CHARACTER_SET_NAME=$(mysql --silent --skip-column-names --user=${CLOUDRON_MYSQL_USERNAME} --password=${CLOUDRON_MYSQL_PASSWORD} --host=${CLOUDRON_MYSQL_HOST} ${CLOUDRON_MYSQL_DATABASE} -e "SELECT DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '${CLOUDRON_MYSQL_DATABASE}';" 2>/dev/null)
                CURRENT_DEFAULT_COLLATION_NAME=$(mysql --silent --skip-column-names --user=${CLOUDRON_MYSQL_USERNAME} --password=${CLOUDRON_MYSQL_PASSWORD} --host=${CLOUDRON_MYSQL_HOST} ${CLOUDRON_MYSQL_DATABASE} -e "SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '${CLOUDRON_MYSQL_DATABASE}';" 2>/dev/null)
                FIX_NEEDED=0
                
                if [ "${CURRENT_DEFAULT_CHARACTER_SET_NAME}" != "utf8mb4" ] || [ "${CURRENT_DEFAULT_COLLATION_NAME}" != "utf8mb4_unicode_ci" ]; then
                    echo "=> DEFAULT_CHARACTER_SET_NAME or DEFAULT_COLLATION_NAME is not set to utf8mb4 or utf8mb4_unicode_ci."
                    echo "==> Current values are: DEFAULT_CHARACTER_SET_NAME=${CURRENT_DEFAULT_CHARACTER_SET_NAME}, DEFAULT_COLLATION_NAME=${CURRENT_DEFAULT_COLLATION_NAME}"
                    FIX_NEEDED=1
                else
                    echo "=> DEFAULT_CHARACTER_SET_NAME is ${CURRENT_DEFAULT_CHARACTER_SET_NAME} and DEFAULT_COLLATION_NAME is ${CURRENT_DEFAULT_COLLATION_NAME}"
                    echo "=> Nothing to do - quitting."
                    FIX_NEEDED=0
                    exit 0
                fi
                
                if [ ${FIX_NEEDED} -eq 1 ]; then
                    read -p "Have you created a backup of your Cloudron Vaultwarden app? (y/N): " yn
                    case $yn in
                        [Yy]* )
                            echo "=> Setting database character set and collation to utf8mb4 and utf8mb4_unicode_ci."
                            mysql --user=${CLOUDRON_MYSQL_USERNAME} --password=${CLOUDRON_MYSQL_PASSWORD} --host=${CLOUDRON_MYSQL_HOST} ${CLOUDRON_MYSQL_DATABASE} -e "ALTER DATABASE \`${CLOUDRON_MYSQL_DATABASE}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" 2>/dev/null
                            echo "=> Converting all tables to character set utf8mb4 and collation utf8mb4_unicode_ci."
                            mysql --silent --skip-column-names \
                  --user="${CLOUDRON_MYSQL_USERNAME}" \
                  --password="${CLOUDRON_MYSQL_PASSWORD}" \
                  --host="${CLOUDRON_MYSQL_HOST}" \
                  "${CLOUDRON_MYSQL_DATABASE}" \
                  -e "SELECT CONCAT('ALTER TABLE \`', TABLE_NAME,'\` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;') AS CharSetConvert FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='${CLOUDRON_MYSQL_DATABASE}' AND TABLE_TYPE=\"BASE TABLE\";" 2>/dev/null | while read -r sql_command; do
                                echo "==> Executing: ${sql_command}"
                                mysql --user=${CLOUDRON_MYSQL_USERNAME} --password=${CLOUDRON_MYSQL_PASSWORD} --host=${CLOUDRON_MYSQL_HOST} ${CLOUDRON_MYSQL_DATABASE} -e "SET foreign_key_checks=0; ${sql_command} SET foreign_key_checks=1;" 2>/dev/null
                            done
                            ;;
                        [Nn]* )
                            echo "=> Please create a backup of your database before proceeding with the fix. Exiting."
                            exit 1
                            ;;
                        * )
                            echo "=> Invalid response. Please answer with y or n. Exiting."
                            exit 1
                            ;;
                    esac
                fi
                
              5. open the Web Terminal of your @vaultwarden Cloudron app
              6. execute the following command:
                bash /app/data/fix_db.sh
                
              7. Execute the following command to start @vaultwarden:
                /app/pkg/start.sh
                
              8. Validate if your @vaultwarden is now working correctly
              9. If validated working, you can delete the fix_db.sh file and disable the recovery mode of your @vaultwarden Cloudron app

              If you run into any issues, copy the output of the terminal, post it here and restore your app from the backup created.

              C Offline
              C Offline
              composer
              wrote last edited by
              #48

              @james That helped. Thanks.

              1 Reply Last reply
              0
              • ChristopherMagC ChristopherMag

                I have run the command sed -i 's/\r$//g' /app/data/fix_db.sh to fix the new line characters and then run bash /app/data/fix_db.sh again and it ran as expected. Disabled recover mode and confirmed things are back to working as expected.

                P Offline
                P Offline
                Purple8
                wrote last edited by
                #49

                @ChristopherMag Thank you ! It worked for me

                1 Reply Last reply
                0
                • jamesJ james

                  Hello @factord
                  This looks like a copy-paste issue from Windows.
                  \r in line 2 is a blank line, so a line break.
                  When you copy and pasted, it pasted the line breaks windows style.

                  Please describe how you have copy and pasted the code into the /app/data/fix_db.sh file.

                  F Offline
                  F Offline
                  factord
                  wrote last edited by
                  #50

                  @james hi James, same than @christophermag , copy/paste in Windows 11, applying his sed fix did the trick for me too.

                  PS: i didn't receive any email notification of the mentions.

                  1 Reply Last reply
                  1
                  • jamesJ Offline
                    jamesJ Offline
                    james
                    Staff
                    wrote last edited by
                    #51

                    Hello @factord
                    This is due to your forum profile settings.
                    If you visit https://forum.cloudron.io/user/factord/settings you can see under Notifications the option When someone mentions you is set to None.
                    If you wish to get notifications on mention, you will have to enable this.
                    Although, you should have got a notification that there were new posts in this topic unless you have changed the topic notification status to Not Watching or Ignoring since in your forum profile settings the following is set:
                    c03d6b0d-34c2-4f6b-8c08-8a0aad2ee534-image.png

                    Did you change the notification setting in this topic (top right bell icon)?
                    ed77f1e8-9fd3-44b8-9149-79a22d8e5753-image.png

                    1 Reply Last reply
                    1
                    • humptydumptyH Offline
                      humptydumptyH Offline
                      humptydumpty
                      wrote last edited by
                      #52

                      I just noticed TODAY that my VW was down. Thanks @james @christophermag for the fix. I also ran into the windows 11 copy/paste issue.
                      YouSavedTheDayGIF.gif

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Bookmarks
                      • Search