Discourse インスタンスを別のサーバーに移動する

:bookmark: これは、すべての設定とデータを含め、Discourse インスタンスをあるサーバーから別のサーバーに移動するためのガイドです。このガイドは、Docker を使用しているセルフホスト型 Discourse インスタンスに適用されます。

:person_raising_hand: 必要なユーザーレベル: システム管理者

:warning: この手順にはドメインと DNS の変更が含まれます。ソースサーバーと宛先サーバーの両方にアクセスできることを確認してください。

このガイドでは、Discourse インスタンスをあるサーバーから別のサーバーに移行するプロセスを順を追って説明し、データ、設定、構成が保持されるようにします。

@pfaffman によって追加された免責事項 2025-09-12T05:00:00Z.

これらの手順は、現在 https と Let’s Encrypt を使用しているため、正常に機能しません。新しいサーバーがキーを要求できるように、DNS がそのサーバーに向けられている必要があります。私が推奨するのは、rsync を使用して Discourse サイトを別の VPS に移動するに従うことです(おそらく --exclude postgres* を使用し、その後コマンドラインからデータベースをバックアップおよび復元します)。これは、方法を知っていれば、ローカル DNS を新しいサーバーに向けるように調整でき、インターネットの他の部分が古いサイトを見ている間にテストできるため、うまい方法です。

要約

このガイドでは、次の主要な手順を実行します。

  1. 現在の Discourse インスタンス(ソースサーバー)をバックアップします。
  2. バックアップファイルを宛先 Discourse インスタンス(宛先サーバー)に転送します。
  3. 宛先サーバーでバックアップを復元します。
  4. DNS 設定を更新します(該当する場合)。

DNS 設定の調整(必要な場合)

新しいサーバーで 同じドメイン を使用している場合は、事前に DNS エントリの TTL(生存時間)を短く設定します。これにより、更新された DNS レコードの伝播中のダウンタイムを最小限に抑えることができます。新しいドメイン を使用する場合は、この手順は省略できます。

ソースサーバーへのログインと準備

  1. 管理者権限を持つアカウントで、ソースの Discourse インスタンスにログインします。
  2. ソースサーバーと宛先サーバーの両方が次を使用していることを確認します。
    • 同じ Discourse バージョン
    • 同じプラグインセット
  3. /admin/upgrade にアクセスして、両方のサーバーで Discourse バージョンをアップグレードします。

:exclamation: より新しいバックアップを古い Discourse バージョン、または互換性のない PostgreSQL バージョンに復元するとエラーが発生する可能性があるため、避けてください。

バックアップの作成とダウンロード

  1. ソースの Discourse インスタンスで /admin/backups に移動します。
  2. Backup ボタンをクリックしてバックアップを作成します。
  3. プロンプトが表示されたら、Yes をクリックして確認します。
  4. バックアップが完了したら、Backup files タブに移動し、新しく作成されたバックアップを見つけます。
  5. Download をクリックして、ダウンロードリンクを含むメールを受け取ります。メール内のリンクをクリックして、バックアップファイルをローカルに保存します。

:warning: 続行する前に、app.yml ファイルを確認し、CDN 構成、インストールされているプラグイン、HTTPS サポートなどのオプション設定がソースサーバーと宛先サーバー間で一貫していることを確認してください。

宛先サーバーでのバックアップの復元

:bulb: コマンドラインからバックアップを復元するには、関連ドキュメントを参照してください。

  1. 宛先の Discourse インスタンスに管理者としてサインインします。
  2. /admin/backups/settings に移動し、allow restore 設定を有効にします。
  3. /admin/backups に移動し、Backup files タブをクリックします。Upload ボタンをクリックして、ダウンロードしたバックアップファイルをアップロードします。
  4. アップロードが完了したら、アップロードされたバックアップの横にある ⋮(その他のオプション)メニューをクリックし、Restore をクリックします。
  5. プロンプトが表示されたら、Yes をクリックして確認します。
    復元プロセスが開始されます。これにはデータベースのサイズに応じて時間がかかる場合があります。プロセスが完了すると、自動的にログアウトされます。

最終処理とログイン

  1. 宛先の Discourse インスタンスに管理者資格情報でログインします。
  2. サイトが HTTPS を使用してバックアップされた場合、新しいサーバーで HTTPS が有効になっていることを確認します。正しく設定されていない場合は、Rails コンソールを使用して一時的に「force https」設定を無効にします。
  3. app.yml ファイルを編集してインスタンスを再構築することにより、オプションの構成を再度有効にします。これには以下が含まれる場合があります。
    • CDN サポートの有効化。
    • 追加のプラグインのインストール。
    • HTTPS 構成の設定。

一般的な問題と解決策

バックアップファイルが復元されない

  • ソースサーバーと宛先サーバー間で Discourse のバージョンと PostgreSQL のバージョンが一致していることを確認してください。

復元後にログインできない(HTTPS が有効な場合)

  • Rails コンソールを使用して、次を実行することで force https を一時的に無効にします。
    SiteSetting.force_https = false
    
「いいね!」 74
How to migrate Discourse to new server
How to migrate my Discourse instance to a fresh new install
Move Discourse to a new server without setting up the web UI first?
Transfer from bitnami to normal discourse
Can I restore backups from older Discourse versions?
How to migrate the discourse container to another machine
Update from 2.9.0 beta2 to beta4 failed (my site is down)
Images lost when migrating to self-hosting
How to downgrade a Digital Ocean Virtual
How to backup and restore a whole /var/discourse app folder?
Exporting an AWS instance
Preserving user sessions when migrating between hosts
Postgres failing to update?
Migrate from VPS to a Dedicated
Site migration and plugins
How to migrate Discourse from one server to another with the same DNS name
Migrate a NodeBB forum with MongoDB to Discourse
Migrate a Ning forum to Discourse
Migrate a Phorum forum to Discourse
Migrate a PunBB forum to Discourse
Migrate from another forum to Discourse
Migrate a Kunena 3 forum to Discourse
Preserve user sessions when migrating to a new host
How do I move the discourse installed server to another server without loss?
Can snapshots be used when upgrading the host OS?
Unknown Primary Key
How to switch Discourse servers?
" undefined method `deprecated?' for nil:NilClass" on rebuild
How to switch Discourse servers?
Some settings aren't saving
Steps involved to downgrade from 2GB to 1GB on DO?
Moving to Another VPS Provider
Getting "permission denied" on new VPS install
How Do I transfer Discourse between servers?
Multi-instance migration failed when adding a new instance
Help Needed Migrating Discourse Forum to New Shanghai Server – db:migrate Error
Plesk server migration
Seeing "welcome to nginx" after backup restore
Issues while migrating from Kunena
Moving to New Server woes
Error: Can't notify admin while restoring backup during a migration to a fresh install
How to migrate from one Digitalocean Droplet to a another Droplet in a different Digitalocean account
How might we better structure #howto?
Trouble with postgre(maybe)
Move Digital Ocean 1-Click install to Standard supported install
Can I retain my forum content if I change its original IP?
Server upgrade from ubuntu 18 to 20
How to move Discourse to a different server when using Digital Ocean's Volumes (Block Storage)
How to migrate Discourse Forum data (Topics, Chat, and Configuration) to another server
How to clone Discourse server to a new server?
Move from standalone container to separate web and data containers
How do I move the discourse installed server to another server without loss?
Migrate a phpBB3 forum to Discourse
Migrate a vBulletin 4 forum to Discourse
Migrate from GetSatisfaction to Discourse
Migrate a NodeBB forum with Redis to Discourse
Migrate a MyBB forum to Discourse