0

When I run gitlab-rake gitlab:backup:create I have this issue
database locale is incompatible with operating system

How can I manually back up gitlab repositories and database?

I backed up

/opt/gitlab
/etc/gitlab
/var/opt/gitlab

so far.

Are there other directories that I should back up?

My repositories are in /var/opt/gitlab/git-data.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
unloco
  • 121
  • 1
  • 6
  • Does https://stackoverflow.com/questions/31636653/connect-to-postgresql-database-with-different-locale help you? – mwfearnley Mar 17 '18 at 19:17
  • I have a messed up VPS and nothing really works due to a broken upgrade. I can't even install anything due to broken dependencies :D and I don't have the `localedef` command installed for some reason – unloco Mar 17 '18 at 19:20

2 Answers2

3

You may find the documentation about this Rake task useful as you troubleshoot this.

If you can't overcome the database locale problem, you could try skipping the database backup with:

gitlab-rake gitlab:backup:create SKIP=db

But should try to find an alternative way to back up the database. I infer from the error message that the database is Postgres, so pg_dumpall might do what you want:

pg_dumpall > gitlab.sql

Otherwise you could try doing a File System Level Backup of the Postgres directory, and try restoring it on a new server with the same version.

mwfearnley
  • 816
  • 1
  • 11
  • 22
  • I tried the 1st command but got the same error when dumping `repositories`. I'm gonna install GitLab locally on my deb9 and see if my manual backups are enough. – unloco Mar 20 '18 at 19:44
  • 1
    You could try SKIP'ing more stages as well, but maybe they all depend on being able to read the database. You may have to do a manual Postgres backup along with your other folders - I've added a link for that. – mwfearnley Mar 21 '18 at 16:35
  • I will install the same gitlab-ce version and manually import the folders I backed up. Thank you for your response – unloco Mar 21 '18 at 16:46
  • 1
    It worked well for me by installing the same version and manually importing, i'll post a new response, maybe someone will find it useful – unloco Mar 21 '18 at 16:53
1

Manually backing up and restoring worked well for me
First I checked the current gitlab version
cd /opt/gitlab/ && cat version-manifest.txt

Then I checked the gitlab-ce version
gitlab-ctl 8.16.2

I downloaded the same version from here (replace 8.16.2 with your version or search here)

After downloading the deb file using wget, I installed it like this

dpkg -i gitlab-ce_8.16.2-ce.0_amd64.deb

After that I imported the files from my old vps using rsync

rsync -chavzP --stats root@myvps.net:/var/opt/gitlab/ /var/opt/gitlab/
rsync -chavzP --stats root@myvps.net:/etc/gitlab/ /etc/gitlab/

Then I restarted gitlab

sudo gitlab-ctl restart

And all was back in order

unloco
  • 121
  • 1
  • 6
  • I'm glad to hear you got it working. Did you have any existing user profiles, issue trackers, etc? I would have expected them to be lost in the move. – mwfearnley Mar 22 '18 at 14:56
  • 1
    Yeah all the data was inside the `/var/opt/gitlab/postgresql/data` i think. So `/etc/gitlab/` has the config and `/var/opt/gitlab/` contains the data – unloco Mar 22 '18 at 15:07
  • Ah right. I see a discussion (https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1963) about moving the folder, which confirms that. (It also suggests running `gitlab-ctl` stop first. Hopefully your instance wasn't running, but it wouldn't have hurt anyway :) .. Out of interest, can you get the rake backup task working now? – mwfearnley Mar 22 '18 at 15:51
  • That's would have been helpful too. Lucky for me the permissions were conserved thanks to the `a` flag in `-chavzP` as per https://explainshell.com/explain?cmd=rsync+-chavzP+--stats+root%40myvps.net%3A%2Fvar%2Fopt%2Fgitlab%2F+%2Fvar%2Fopt%2Fgitlab%2F . Also the backup works fine now, I guess I will accept your answer as it's more straight forward than my manual approach – unloco Mar 22 '18 at 20:01