# How to download Discourse backup and restore local database

**URL:** https://meta.discourse.org/t/discourse/279041
**Category:** Self-hosting
**Tags:** chinese-translation
**Created:** [September 14, 2023, 6:01pm UTC](https://meta.discourse.org/t/discourse/279041 "2023-09-14T18:01:59Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![honeymoose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honeymoose/32/198718_2.png) [@honeymoose](https://meta.discourse.org/u/honeymoose)
#### Post date: [September 14, 2023, 6:01pm UTC](https://meta.discourse.org/t/discourse/279041/1 "2023-09-14T18:01:59Z")

</div>

Navigate to the website’s backup interface, and you will see the current backup status.

 ![](https://global.discourse-cdn.com/meta/original/4X/a/f/c/afc01d130e486a07255d33a12c048563348e512a.png)  
Click the download button.

It should be noted that when you download, the system will send a link to your email address.

You can use the link received in your email address to download the data.

 ![](https://global.discourse-cdn.com/meta/original/4X/9/a/4/9a4f333052c0ad22f2d14961f92c7a8a441eec63.png)

## Download Link

Click the download link address received in the email to download.

 ![](https://global.discourse-cdn.com/meta/original/4X/6/7/6/6763b5252fe099fdff5cf7049e7faa8b5e049190.png)  
The downloaded file is a tar.gz file, which you need to decompress before use.

For example, our current downloaded file is: isharkfly-2023-09-14-092024-v20230910021213.tar

After a series of complex decompression steps, you will find the dump.sql file.

This file is your entire database backup.

## Data Recovery

The psql installation path for PQadmin on Windows is: C:\Users\yhu\AppData\Local\Programs\pgAdmin 4\v7\runtime

Our command is: `psql -h nas1120 -p 5433 -U postgres -W -d discourse -f C:\\Users\\yhu\\Downloads\\isharkfly-2023-09-14-092024-v20230910021213\\isharkfly-2023-09-14-092024-v20230910021213\\dump.sql\\dump.sql`

Local databases cannot be overwritten during recovery.

If your local database already exists, you need to clear the existing local database before recovery.

The backup recovery process requires restoring all data and table structures.

The recovery program cannot restore on top of existing data structures and cannot perform incremental recovery.

## Check Table Data

Check the table data to confirm that some table data has been restored.

 ![](https://global.discourse-cdn.com/meta/original/4X/e/1/6/e161830ad8159c61e08e8c2aa4473315df58732e.png)  
Timestamps are generally a good way to verify.

> **[Discourse 如何下载备份并恢复本地数据库](https://www.isharkfly.com/t/discourse/14963)**
>
> 进入网站的备份界面，会看到当前所有的备份情况。 单击下载按钮。 需要注意的是，当你下载后，系统将会发送一个链接到你的邮箱地址中。 你可以使用邮箱地址中收到的链接进行数据下载。 下载链接 单击邮件中收到的下载链接地址进行下载。 下载的文件为一个 tar.gz 文件，你需要解压后才可以用。 例如，我们当前的下载文件为：isharkfly-2023-09-14-092024-v20230910021213.tar 经过一系列复杂的解压路径后可以看到...

---

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [September 16, 2023, 2:26pm UTC](https://meta.discourse.org/t/discourse/279041/2 "2023-09-16T14:26:03Z")

</div>

Supplement.  
If the mail service fails, admin with ssh permissions can see all backup files in `/var/discouse/{standalone | web_only}/backup/default`.

A note:  
If the mail service fails, admin with ssh permissions can see all backup files in `/var/discouse/{standalone | web_only}/backup/default`.

---

<div class="post-metadata">

### Author: ![captno78](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@captno78](https://meta.discourse.org/u/captno78)
#### Post date: [October 3, 2023, 1:52pm UTC](https://meta.discourse.org/t/discourse/279041/3 "2023-10-03T13:52:33Z")

</div>

How do I use Minio for backups? I don’t understand the error messages in the logs. The logs are as follows:

```plaintext
....
[2023-10-03 13:33:24] Removing tmp '/var/www/discourse/tmp/backups/default/2023-10-03-133319' directory...
[2023-10-03 13:33:24] Gzipping archive, this may take a while...
[2023-10-03 13:33:25] Uploading archive...
[2023-10-03 13:33:27] EXCEPTION: Aws::S3::Errors::Forbidden
[2023-10-03 13:33:27] /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-s3-1.114.0/lib/aws-sdk-s3/object.rb:445:in `rescue in exists?'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-s3-1.114.0/lib/aws-sdk-s3/object.rb:440:in `exists?'
/var/www/discourse/lib/backup_restore/s3_backup_store.rb:46:in `upload_file'
/var/www/discourse/lib/backup_restore/backuper.rb:344:in `upload_archive'
/var/www/discourse/lib/backup_restore/backuper.rb:41:in `run'
/var/www/discourse/script/spawn_backup_restore.rb:9:in `backup'
/var/www/discourse/script/spawn_backup_restore.rb:31:in `block in <main>'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `fork'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2023-10-03 13:33:27] Deleting old backups...
[2023-10-03 13:33:28] Cleaning stuff up...
[2023-10-03 13:33:28] Removing archive from local storage...
[2023-10-03 13:33:28] Removing '.tar' leftovers...
[2023-10-03 13:33:28] Marking backup as finished...
[2023-10-03 13:33:28] Notifying 'XXX' of the end of the backup...

```

---

<div class="post-metadata">

### Author: ![honeymoose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honeymoose/32/198718_2.png) [@honeymoose](https://meta.discourse.org/u/honeymoose)
#### Post date: [October 3, 2023, 3:10pm UTC](https://meta.discourse.org/t/discourse/279041/4 "2023-10-03T15:10:55Z")

</div>

> [@captno78](#):
>
> I don’t understand the error message in the log. The log is as follows:

The log above should indicate that S3 does not have permission.

Please confirm that your S3 permission settings are correct.

 ![2023-10-03_11-09-27](https://global.discourse-cdn.com/meta/original/4X/5/1/0/510674d84eecab6a88795e470258bdd7405f3b8c.jpeg)

> **[Discourse 如何备份到 S3](https://www.isharkfly.com/t/discourse-s3/56)**
>
> Discourse 与 S3 是对好基友，如果你对 S3 比较熟悉的话，那么对你来说帮助会非常大。 很多人的虚拟主机空间是有限并且资源也是有限的。 使用 S3 进行备份能够更好的利用空间。 你可以按照下面的步骤进行配置： 设置备份频率 进入 admin \> backup，然后设置 backup\_frequency 为 1。这个是参数是表示备份的频率，默认为 7 。 1 表示的是每天进行备份一次。 7 表示的是每 7 天进行备份一次。 针对一般访问网站，如果使用 S3...

---

<div class="post-metadata">

### Author: ![captno78](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@captno78](https://meta.discourse.org/u/captno78)
#### Post date: [October 4, 2023, 2:28am UTC](https://meta.discourse.org/t/discourse/279041/5 "2023-10-04T02:28:12Z")

</div>

Here are my settings, please experts take a look and see where the problem is:

1. Discourse Settings  
 ![image](https://global.discourse-cdn.com/meta/original/4X/b/6/c/b6ccc23c0f6d812b248405f0d0cf38dc738e989e.png)
2. Minio Backup Bucket Permissions Settings

```plaintext
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucketMultipartUploads"
            ],
            "Resource": [
                "arn:aws:s3:::discourse-backup"
            ]
        },
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::discourse-backup/*"
            ]
        }
    ]
}

```

1. Minio Upload Bucket Permissions are public

---

<div class="post-metadata">

### Author: ![honeymoose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honeymoose/32/198718_2.png) [@honeymoose](https://meta.discourse.org/u/honeymoose)
#### Post date: [October 4, 2023, 2:59am UTC](https://meta.discourse.org/t/discourse/279041/6 "2023-10-04T02:59:24Z")

</div>

> [@captno78](#):
>
> Here are my settings, please experts see where the settings are wrong

Refer to this article to see: [discourse-docs/minio.md at master · rishabhnambiar/discourse-docs · GitHub](https://github.com/rishabhnambiar/discourse-docs/blob/master/minio.md)

---

<div class="post-metadata">

### Author: ![captno78](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@captno78](https://meta.discourse.org/u/captno78)
#### Post date: [October 4, 2023, 6:44am UTC](https://meta.discourse.org/t/discourse/279041/7 "2023-10-04T06:44:55Z")

</div>

This article is from when path style was still supported; now only dns style is supported. I can’t find any configuration tutorials for using MinIO anywhere online.

---

<div class="post-metadata">

### Author: ![honeymoose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honeymoose/32/198718_2.png) [@honeymoose](https://meta.discourse.org/u/honeymoose)
#### Post date: [October 4, 2023, 11:56am UTC](https://meta.discourse.org/t/discourse/279041/8 "2023-10-04T11:56:11Z")

</div>

Let’s see if it might be in the Minio settings.

Try using other tools, for example, tools that can directly access the bucket, to see if you can upload directly.

If you can upload directly here, then it’s likely a Discourse configuration issue. If you cannot upload directly here, then it’s likely a permissions issue.
