Migrate from sqlite to Postgres

I installed Gogs on my Red Hat 7 server (32GB RAM, 48 cores). I tried to use MariaDB as my db, but I was getting weird errors that I couldn’t figure out so I punted and decided to use sqlite. It installed and I was able to start using Gogs. I created several user accounts and started creating test repos.

All was great until I started to migrate my cvs repos to the new Gogs server. After importing just one repo (12 years of history with 69 branches and 157 tags) I started noticing performance issues when using the web interface. I need to eventually import almost 200 repos from cvs with a similar amount of branches and tags, and can only assume the situation will get much worse. I’m thinking of migrating from sqlite to Postgres, but when I try to backup my database using the following command:
./gogs backup --database-only -archive-name “gogs_db.bk” --config “custom/conf/app.ini”
I get an error that this must be done as the git user, but when I try to switch to the git user (su - git) I get the message failed to execute /bin/nologin" no such file or directory. not sure how to proceed.

Gogs version 0.11.86.0130, RHEL 7, sqlite

You can set $USER=git to bypass the check.

BTW, loading huge repositories slow mainly because Gogs does not have a cache layer, migrate to PostgreSQL is a good move, but might not be able to help your situation.

@tankmr
Btw obviously the git user in your case has no login permissions, meaning no login shell is assigned. /bin/nologin is a dump shell, however I guess the binary is actually located at /usr/sbin/nologin (default on Debian at least), which then shows some “nice” message about login being not possible for this user, instead of an error messge, however the result is the same.

That is the reason why su and sudo -i will not work. But you can run the command without creating an interactive subshell:

sudo -u git ./gogs backup --database-only -archive-name 'gogs_db.bk' --config 'custom/conf/app.ini'

About performance:

  • That SQLite does not work well is no surprise in your case of very large repo. SQLite should only be used for testing or when the repos stay small. The way a whole single database file is rewritten on changes is simply not nice performance-wise, nor for the drive I/O-wise.
  • AFAIK there are only minor differences between PostgreSQL and MariaDB, when configured well (cache matching database size etc), so I agree @Unknwon that you most likely will not have much benefit, however if it finally works, at least worth to give it a try.
  • If you face errors with MariaDB, I suggest to report some details about them, perhaps we can help with some config fixes/enhancements?
1 Like