コマンドラインからバックアップを復元する

:bookmark: このガイドでは、Discourse の Web UI を使用せずに、コマンドラインから Discourse のバックアップを復元する方法を説明します。
:person_raising_hand: 必要なユーザーレベル: 管理者
:wrench: コンソールアクセスが必要です

ここでは、Discourse の Web UI を起動することなく、コマンドラインから Discourse のバックアップを復元する方法を説明します。これは、サーバーを移行する際に便利です。

前提条件

始める前に、次の手順を完了していることを確認してください。

  1. ソースの Discourse インスタンスから最新のバックアップファイルをダウンロードします。
  2. ./discourse-setup を実行するか、既存の app.yml をコピーして、宛先の Discourse インスタンスをブートストラップします。
  3. 宛先の Discourse インスタンスが最新バージョンであることを確認します。必要に応じて更新します。

バックアップの転送

  1. 宛先サーバーに SSH 接続するか、そこにバックアップフォルダーを作成します。

mkdir -p /var/discourse/shared/standalone/backups/default

  1. バックアップファイルを宛先サーバーにアップロードします。

scp /path/to/backup/backup.tar.gz root@192.168.1.1:/var/discourse/shared/standalone/backups/default

パス、ファイル名、サーバー名を、使用しているものに置き換えてください。ただし、バックアップファイルは次の場所に配置する必要があります。

/var/discourse/shared/standalone/backups/default

:mega: Google Drive、Dropbox、OneDrive などの一般的な Web ストレージ サイトから Discourse のバックアップファイルをアップロードおよびダウンロードすることもできます。好みの Web ストレージプロバイダーに基づいて、特定のコマンドライン手順を確認する必要があります。

:warning: バックアップのファイル名を変更しないでください! Discourse はバックアップファイル名をメタデータとして扱うため、ファイル名を変更すると復元が機能しなくなります。元のファイル名を維持してください。

/path/to/backup/discourse-xyz.tar.gz をバックアップファイルのローカルパスに置き換え、\u003cserver_ip_address\u003e を宛先サーバーの IP アドレスに置き換えます。

:bulb: Nginx をリバースプロキシとして使用している 場合は、すべてのバックアップパスがコンテナによって読み取れ、Nginx が .sock ファイルを読み取れることを確認してください。

バックアップの復元

  1. 宛先サーバーにアクセスし、Discourse フォルダーに移動します。
cd /var/discourse
  1. Discourse Docker アプリコンテナに入ります。
./launcher enter app
  1. 復元機能を有効にします。
discourse enable_restore
  1. バックアップファイルを復元します。
discourse restore sitename-2019-02-03-042252-v20190130013015.tar.gz

:bulb: ヒント: ファイル名を指定せずに discourse restore を実行すると、利用可能なすべてのバックアップファイルが一覧表示されます。

:warning: サイトの backup_location 設定が S3 を使用するように構成されているが、バックアップファイルをローカルファイルシステムに手動でアップロードした場合は、--location local を指定する必要があります。

discourse restore --location local sitename-2019-02-03-042252-v20190130013015.tar.gz

同様に、ダウンロードせずに S3 バックアップから直接復元するには、--location s3 を使用します。

  1. Discourse Docker アプリコンテナを終了します。
exit

リビルド

バックアップを復元した後、すべての設定と構成が正しく適用されていることを確認するために、宛先インスタンスをリビルドすることを選択できます。

:mega: ここで、/var/discourse/containers/app.yml を完全な HTTPS、追加のプラグイン、または CDN 構成で更新する良い機会です。両方のインスタンスの app.yml 構成を比較して確認してください!

cd /var/discourse
./launcher rebuild app

Eメールの有効化

バックアップが復元されると、スタッフ以外のユーザーの送信メールが無効になります。テストサーバー、新しいサーバー、または何らかの理由でバックアップを復元したばかりのサーバーがユーザーにメールを送信し始めることは望ましくありません。disable_emails サイト設定を「no」に変更して、メールを再度有効にします。

:tada: これで完了です。Discourse サーバーは正常に復元されました。

「いいね!」 78
Move your Discourse Instance to a Different Server
Any other way to take backup and restore?
How easy is it to move to another server?
HELP! My Discourse just deleted everything?
Restore backup is broken
How to migrate Discourse from one server to another with the same DNS name
Best Practices for Backups
Problem upgrading Discourse
Upgrading v2.2.0.beta4 forum with unknown local changes
Set up file and image uploads to S3
Quick question about site backups
My install broke after updating, how can I fix it?
Is there any way to restore your site from backup in the terminal?
Migrating Discourse from one DigitalOcean droplet to another without downtime
Restore backup right away after installing Discourse
Unable to migrate to S3, therefore unable to restore from backup
Restore Failure - S3 (compatible) backup
"EXCEPTION: psql failed: DETAIL: Key (post_id)=(36946) is duplicated."
Migrate from another forum to Discourse
My install is 16,359 commits behind! Advice?
Trying to recover an installation
Migration failed: relation "user_required_fields_versions" already exists
How can I manually verify via the CLI and bypass the Congratulations, you installed Discourse! screen?
Configuring automatic backups
Migrating to a new server that has a new DB and new S3 buckets for backup and uploads
Intended path to migrate S3 to local
Problem when updating Discourse Forum
Failed to restore from the backup
Steps involved to downgrade from 2GB to 1GB on DO?
Forum offline: Restore is not working through web
Forum offline: Restore is not working through web
Testing Restore - not working
Entire site is a blank page after upgrade
"discourse: command not found" when trying to restore a backup from the command line
Stuck with 500 error after weird bugs and a rebuild
Plesk server migration
"Key is stored in legacy trusted.gpg keyring" warning
"Key is stored in legacy trusted.gpg keyring" warning
Discourse broken after moving servers
Stuck and lost updating forum, problems with PG migration
How to manually migrate s3 files to local?
Index_users_on_username_lower error during database restore: import failed
How can I get the current version information from my backup?
Backup Prod -> Snap -> Build Test -> Change Address
How to properly package discourse as an image
2FA with OTP broken after restoring from Backup
I'm trying to migrate an old discourse by creating a new discourse, but I'm having trouble
Recover from filesystem backup: can't rebuild nor start
Error: Can't notify admin while restoring backup during a migration to a fresh install
MKJ's Opinionated Discourse Deployment Configuration
Migrate from AWS to Digital Ocean with 2 containers, spaces and 2 CDNs
Cannot restore database: sql key is duplicated
Finding UI generated backup and restoring site
Backup discourse from the command line
Migration to a Self-Hosted solution from Kubernetes
How to download the backup file without SMTP function?
Redis Problems? (Forum broken after upgrade)
Can't upload backup
Can't upload backup
Can't upload backup
Rate limiter issues when uploading a backup file / can't disable rate limiter
Help restoring - system hung at midnight
Help restoring - system hung at midnight
Uploads missing after restore
My install is 16,359 commits behind! Advice?
Issues Rebuilding After Upgrade to Ubuntu 22.04