Backstory: I had a debian 11 VPS. I installed the postgresql program from the debian 11 apt repo, back a few months ago. Back then, it was postgres 13 on the debian stable repos.

Fast forward couple months: debian 12 comes out. I do a “apt dist-upgrade” and in-place upgrade my VPS from debian 11 to debian 12. Along with this upgrade, comes postgresql 15 installed.

Now, fast forward couple more months: lemmy 0.18.3 comes out. I do not upgrade (I am on lemmy 0.18.2—afaik).

Fast forward some time, too: lemmy 0.18.4 comes out. I decide to upgrade to 0.18.4 from my existing 0.18.2.

I pull the git repo. Compile it locally. It goes well, no errors in the compilation process. I stop the lemmy systemd service, then I “mv” the compiled “lemmy_server” to /usr/bin dir.

I try to restart the now-upgraded lemmy systemd service. However, the systemd service fails.

I check the sudo journalctl -fu lemmy and I see the following error message:

lemmy_server[17631]: thread 'main' panicked at 'Couldn't run DB Migrations: Failed to run 2023-07-08-101154_fix_soft_delete_aggregates with: syntax error at or near "trigger"', crates/db_schema/src/utils.rs:221:25 

I report this issue here: https://github.com/LemmyNet/lemmy/issues/3756#issuecomment-1686439103

However, after a few back and forths and internet search, I conclude that somewhere between lemmy 0.18.3 and 0.18.4, lemmy stops supporting psql <15. So, my existing DB is not compatible.

Upon my investigation on my VPS setup, I concluded that psql 15 is running, however, lemmy is using the psql 13 tables (I do not know if this is the correct term).

Now my question: is there a way to import the lemmy data I had in the psql 13 tables to a new psql 15 table (or database, I don’t know the term).

To make things hairier: I also run a dendrite server on the same VPS, and the dendrite server is using the psql 15 with psql 13 tables on the same database as the lemmy one.

The dendrite database is controlled by a psql user named “dendrite” and the lemmy database is controlled by a psql user named “lemmy” . I hope this makes differentiation between two databases possible. And so I do not harm my existing dendrite database.

Any recommendations about my options here?

  • Anark KarabeyOP
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    So, the command I do is the following?

    sudo -iu postgres /usr/lib/postgresql/15/bin/pg_dump --port=5433 lemmy > /someplace_with_space/lemmy_databackup_2.sql
    

    Observe that I have modified the --port to 5433 (which is the psql 15) and I have appended a “_2” to the exported sql filename.

      • Anark KarabeyOP
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago
        user@server:~$ ls -lh
        total 54M
        -rw-r--r-- 1 user user 5.8K Jul 18 18:08 cargo_build_output.txt
        drwxr-xr-x 3 user user 4.0K May 12 14:09 go
        -rw-r--r-- 1 user user  54M Aug 23 00:59 lemmy_databackup.sql
        -rw-r--r-- 1 user user 1.3K Jul 20 09:59 lemmy_matrix_Caddyfile_example.txt
        -rw-r--r-- 1 user user  547 Jul 18 16:46 yarn-error.log
        user@server:~$ sudo -iu postgres /usr/lib/postgresql/15/bin/pg_dumpall --port=5433 > /home/user/lemmy_databackup_2.sql
        [sudo] password for user:
        user@server:~$ ls -lh
        total 109M
        -rw-r--r-- 1 user user 5.8K Jul 18 18:08 cargo_build_output.txt
        drwxr-xr-x 3 user user 4.0K May 12 14:09 go
        -rw-r--r-- 1 user user  55M Aug 25 00:55 lemmy_databackup_2.sql
        -rw-r--r-- 1 user user  54M Aug 23 00:59 lemmy_databackup.sql
        -rw-r--r-- 1 user user 1.3K Jul 20 09:59 lemmy_matrix_Caddyfile_example.txt
        -rw-r--r-- 1 user user  547 Jul 18 16:46 yarn-error.log
        user@server:~$
        
        • RoundSparrow @ BT@bulletintree.comM
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          well the size is about the same, 55M vs 54M, so the restore worked.

          We need to study what is in this file and try to make sense of how there are two Lemmy databases in there. What you are looking for is sections like this:

          --
          -- Database "lemmy" dump
          --
          
          --
          -- PostgreSQL database dump
          --
          
          

          We are looking for different names or something, because somehow you have one with only a few communities and messages, another with far more.

          • Anark KarabeyOP
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            So, I am cat -ing this file into less pager and inspect by my eye and do keyword searches?

              • Anark KarabeyOP
                link
                fedilink
                arrow-up
                2
                ·
                1 year ago

                OK. I am examining the file. I see the sections you mention. What else should I be looking for?

                • RoundSparrow @ BT@bulletintree.comM
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  1 year ago

                  ok, this grep might be of use:

                  grep --after-context=6 "Data for Name: local_site; Type: TABLE DATA;" lemmy_databackup_2.sql

                  I’m not sure if there is anything sensitive in that output… but I think it will be revealing how many matches you get.

                  • Anark KarabeyOP
                    link
                    fedilink
                    arrow-up
                    2
                    ·
                    1 year ago

                    grep --after-context=6 “Data for Name: local_site; Type: TABLE DATA;” lemmy_databackup_2.sql

                    I think I got two matches on that.