# Error when backup Gitlab self host

**URL:** <https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526>\
**Category:** Self-managed\
**Tags:** backup\
**Created:** [May 4, 2021, 7:27am UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526 "2021-05-04T07:27:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adt0383](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@adt0383](https://forum.gitlab.com/u/adt0383)\
**Post date:** [May 4, 2021, 7:27am UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526/1 "2021-05-04T07:27:04Z")

</div>

Hi all,

I have problem when backup my gitlab server, the error is:

> 2021-05-04 01:00:19 +0700 – Dumping database …  
> Dumping PostgreSQL database gitlabhq\_production … pg\_dump: error: Dumping the contents of table “raw\_usage\_data” failed: PQgetResult() failed.  
> pg\_dump: error: Error message from server: ERROR: missing chunk number 0 for toast value 1424382 in pg\_toast\_958562  
> pg\_dump: error: The command was: COPY public.raw\_usage\_data (id, created\_at, updated\_at, recorded\_at, sent\_at, payload, version\_usage\_data\_id\_value) TO stdout;  
> [FAILED]  
> rake aborted!  
> Backup::Error: Backup failed  
> /opt/gitlab/embedded/service/gitlab-rails/lib/backup/database.rb:62:in `dump' /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:134:in `block (4 levels) in \<top (required)\>’  
> /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:12:in `block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in `load’  
> /opt/gitlab/embedded/bin/bundle:23:in `’  
> Tasks: TOP =\> gitlab:backup:db:create  
> (See full trace by running task with --trace)

May be the table raw\_usage\_data is corrupt at row 42:

> ## gitlabhq\_production=\> select count(\*) from raw\_usage\_data; count
> 
> ```
> 48
> 
> ```
> 
> (1 row)  
> gitlabhq\_production=\> select \* from raw\_usage\_data order by id limit 1 offset 42;  
> ERROR: missing chunk number 0 for toast value 1424382 in pg\_toast\_958562

Please help to advice.  
Thanks alot for your help,  
ADT.

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/gitlab/user_avatar/forum.gitlab.com/iwalker/32/28805_2.png) [@iwalker](https://forum.gitlab.com/u/iwalker)\
**Post date:** [May 4, 2021, 7:35am UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526/2 "2021-05-04T07:35:02Z")

</div>

From a quick google, there are a few things you can try. Reindex the table, assuming raw\_usage\_data is the table then in postgresql:

```auto
REINDEX table pg_toast.pg_toast_958562;
REINDEX table raw_usage_data;

```

you can also try:

```auto
VACUUM ANALYZE raw_usage_data;

```

and see if that helps.

---

<div class="post-metadata">

**Author:** ![adt0383](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@adt0383](https://forum.gitlab.com/u/adt0383)\
**Post date:** [May 4, 2021, 7:39am UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526/3 "2021-05-04T07:39:13Z")

</div>

Thanks for your reply, I have googled and tried, but failed:

> gitlabhq\_production=\> REINDEX table pg\_toast.pg\_toast\_958562;  
> ERROR: permission denied for schema pg\_toast

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/gitlab/user_avatar/forum.gitlab.com/iwalker/32/28805_2.png) [@iwalker](https://forum.gitlab.com/u/iwalker)\
**Post date:** [May 4, 2021, 7:42am UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526/4 "2021-05-04T07:42:00Z")

</div>

Try using:

```auto
sudo gitlab-psql

```

you need to run psql as a user with higher privileges that has access to all tables.

---

<div class="post-metadata">

**Author:** ![adt0383](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@adt0383](https://forum.gitlab.com/u/adt0383)\
**Post date:** [May 4, 2021, 7:47am UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526/5 "2021-05-04T07:47:14Z")

</div>

That’s it, thanks alot. The backup is ok now.  
Thanks again and have a nice day.

---

<div class="post-metadata">

**Author:** ![tilc](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@tilc](https://forum.gitlab.com/u/tilc)\
**Post date:** [October 25, 2024, 5:22pm UTC](https://forum.gitlab.com/t/error-when-backup-gitlab-self-host/52526/6 "2024-10-25T17:22:01Z")

</div>

How would that work on k8s helm deployment?
