# Importing a Discourse backup into a PostGreSQL DB

**URL:** https://meta.discourse.org/t/importing-a-discourse-backup-into-a-postgresql-db/110861
**Category:** Self-hosting
**Created:** [March 6, 2019, 1:45pm UTC](https://meta.discourse.org/t/importing-a-discourse-backup-into-a-postgresql-db/110861 "2019-03-06T13:45:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Alexandra\_Diehl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexandra_diehl/32/133158_2.png) [@Alexandra\_Diehl](https://meta.discourse.org/u/Alexandra_Diehl)
#### Post date: [March 6, 2019, 1:45pm UTC](https://meta.discourse.org/t/importing-a-discourse-backup-into-a-postgresql-db/110861/1 "2019-03-06T13:45:59Z")

</div>

Dear Discourse team,

Please could you advise me how can I import a backup into PostGreSQL DB.

I am using

```
psql --username=xx--password=xx mydb < C:\...\backup.tar

```

but I get a weird message:

```
orden \Y¾³s'ìfu7}Ø$M²ÏñT?ýï>/ no válida
ERROR: secuencia de bytes no vÃ¡lida para codificaciÃ³n Â«UTF8Â»: 0x8b

```

Thanks so much for your help!

Best regards,

Alexandra.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 6, 2019, 2:09pm UTC](https://meta.discourse.org/t/importing-a-discourse-backup-into-a-postgresql-db/110861/2 "2019-03-06T14:09:54Z")

</div>

First extract the tar file

`tar xf backup.tar`

Then  
`zcat dump.sql.gz | psql -u username mydb`

On Windows, you might have to use a tool like Winrar multiple times to go from `backup.tar.gz` to `backup.tar` to `dump.sql.gz` to `dump.sql` and then

`psql -u username mydb < dump.sql`

---

<div class="post-metadata">

### Author: ![Alexandra\_Diehl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexandra_diehl/32/133158_2.png) [@Alexandra\_Diehl](https://meta.discourse.org/u/Alexandra_Diehl)
#### Post date: [March 19, 2019, 6:45pm UTC](https://meta.discourse.org/t/importing-a-discourse-backup-into-a-postgresql-db/110861/3 "2019-03-19T18:45:28Z")

</div>

Thanks so much Richard!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 11, 2022, 4:09am UTC](https://meta.discourse.org/t/importing-a-discourse-backup-into-a-postgresql-db/110861/5 "2022-06-11T04:09:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
