How to create a backup / migrate away from Heroku?

Hello,

I've simply followed the easy deploy for testing:

and it worked just fine.

Now, I'd like to backup / migrate away from Heroku to my own Docker instance, but that seems to be much more difficult.

I found this one:

and installed the CLI.

But how do I continue from there to get my application data out?
I don't want to migrate to the metabase cloud.

Hi @Chris34532
Just connect to the Heroku Postgres database and do a dump (pg_dump) and then restore (pg_restore) on your local Postgres.
https://devcenter.heroku.com/articles/heroku-postgres-import-export

I've managed to create a backup and restore it inside a docker container.
But I've got quite a few errors on the restore which look partly like this:

pg_restore: from TOC entry 4642; 2606 2255798 CONSTRAINT report_card report_card_pkey uujjexpweazvbl
pg_restore: error: could not execute query: ERROR:  multiple primary keys for table "report_card" are not allowed
Command was: ALTER TABLE ONLY "public"."report_card"
    ADD CONSTRAINT "report_card_pkey" PRIMARY KEY ("id");
pg_restore: creating INDEX "public.idx_user_id"
pg_restore: creating FK CONSTRAINT "public.native_query_snippet fk_snippet_creator_id"
pg_restore: creating FK CONSTRAINT "public.metabase_table fk_table_ref_database_id"
pg_restore: from TOC entry 4892; 2606 2258969 FK CONSTRAINT metabase_table fk_table_ref_database_id uujjexpweazvbl
pg_restore: error: could not execute query: ERROR:  insert or update on table "metabase_table" violates foreign key constraint "fk_table_ref_database_id"
DETAIL:  Key (db_id)=(2) is not present in table "metabase_database".
Command was: ALTER TABLE ONLY "public"."metabase_table"
    ADD CONSTRAINT "fk_table_ref_database_id" FOREIGN KEY ("db_id") REFERENCES "public"."metabase_database"("id") ON DELETE CASCADE;
pg_restore: creating FK CONSTRAINT "public.timeline fk_timeline_collection_id"
pg_restore: creating FK CONSTRAINT "public.timeline fk_timeline_creator_id"
pg_restore: creating FK CONSTRAINT "public.view_log fk_view_log_ref_user_id"
pg_restore: warning: errors ignored on restore: 19

@flamber do you think it's save to ignore them? Or will my Metabase have fundamental issues from now on?

@Chris34532 It's critical to maintain constraints to avoid corruption.
Not having report_card.id is a no-go. How you ended up with that or were able to run with this I cannot tell you.
As for metabase_table.db_id, it seems like you have some old table information referencing a database that doesn't exists anymore, so it should be safe to completely get rid of those columns referencing ID 2.

Basically, I just did an export like in the link you suggested:

(which is a binary file) and then imported it again into my Docker PostgreSQL

Do I have to start from scratch now with my reports etc. or is it possible to fix sth?

@Chris34532 You'll need to manually go through the dump and resolve conflicts, so the restore doesn't throw any errors. I don't know how you ended up with these problems.