Move your Discourse Instance to a Different Server


(Arpit Jalan) #1

In this guide we’ll move an existing Discourse instance on Linode to a new Discourse instance on Digital Ocean, but of course these steps will work on any other cloud providers that support Docker.

:bell: If you are using the same domain name and moving servers, you should set the TTL (time to live) on your DNS entry to a very low value in advance of the change. If you are using different domain names, this won’t matter.

Log In and Update

Only admins can perform backups, so sign in as an account with admin access on your existing Discourse instance on Linode.

Ideally, both the new and old Discourses SHOULD BE ON THE EXACT SAME VERSION to ensure proper backup/export. So the first thing we’ll do is update our existing Discourse instance on Linode to the absolute latest version.

:warning: What you definitely want to avoid is restoring a newer backup on an older version. That won’t work.

Visit /admin/upgrade to upgrade both instances. After successfully upgrading, you should see You’re up to date!

Create and Download Your Backup

Visit /admin/backups and click Backup button.

You will be prompted for confirmation, press Yes. You will see the log of backup processing. Once processing is finished, switch back to Backups tab.

Now you will see the newly created backup file. Click Download button and save the file, we will need it later for restoration on the new server.

:bell: Before you switch over to the new server, review your app.yml for any optional settings such as CDN, installed plugins, and HTTPS support between the two Discourse instances (if any of that is configured). It is OK to configure this later after the migration as well.

Log In and Restore Backup

Sign up and login on your new Discourse instance at Digital Ocean.

Under site settings search for restore:

Enable the allow_restore setting.

Browse to /admin/backups and click Upload button, select the backup file you downloaded previously from your existing Discourse instance (file name ends with .tar.gz):

Once the file gets uploaded it will be listed as shown below, click Restore button:

Press Yes when prompted for confirmation. You will see restore process log, it may take some time but it’s automagically importing all your existing Discourse instance (Linode server) data.

Once the Restore process finishes, you will be logged out.

Log In and You’re Done

:warning: If you are logging in to a backup that was taken with HTTPS, the site setting “force https” will be enabled. You either need to turn that off via the Rails console, or ensure that your restore is also properly running under HTTPS.

Once the restore process finishes, all the data from your previous Discourse instance on Linode server will be imported in your new Discourse instance on Digital Ocean, sign in with your Admin account and you are good to go!

:bell: Don’t forget to enable any optional configuration settings that require editing the app.yml and rebuilding, such as CDN, plugins, and HTTPS support.


Can I pack the server and move it to another server?
How to migrate Discourse to new server
Configure automatic backups for Discourse
HOWTO: Import MBOX (mailing list) files
Migrating from Ning to Discourse
Migrating to Discourse from another Forum software
Importing from phpBB3
Migrating from GetSatisfaction to Discourse
Restoring backups for development
Restoring backups for development
Unicorn using 100% cpu, can't kill -9
Starting Over with Old Database
Discourse vs. mailing lists (Majordomo or otherwise)
Missing avatars since restore
[PAYING GIG] migrating servers, tweaking rate limits and implementing signup captcha
Upgrade error on AWS free tier t2.micro
Importing from Kunena 3
Transfer from bitnami to normal discourse
Moving your data to a new install of discourse forum
Website Migration
What is the correct procedure for moving discourse to a new server?
Best way to re-do the discourse docker install (with backup)?
Exporting an AWS instance
Advanced Troubleshooting with Docker
Upgrading from Discourse 0.9.9.5
Images lost when migrating to self-hosting
Images inside the post is not visible with Bitnami install
Beginners Guide to Install Discourse on Ubuntu for Development
Move docker container to new host but can't upload backup
Importing from vBulletin 4
Can I restore backups from older Discourse versions?
How to move from standalone container to separate web and data containers
Restoring from backup
Connect my local discourse to my discourse on vps via git
Restore Error, i dont understand that error
(Tuan Anh Tran) #2

Thanks for the tutorials.

Let’s say if the backup file is huge (GB++), how would i upload it? Is there any folder so i can just wget it from the old server and it will appear there in the backup section of the new server?


(Jens Maier) #3

Don’t use wget. The file shouldn’t be accessible via the webserver. Use rsync over ssh:

rsync --partial --progress --rsh=ssh user@host:remote_source local_destination

Just move the backup file to /shared inside the container, then you can grab it from /var/docker/shared via rsync. Also, source and destination are flexible, e.g. source can be local and destination can be remote.


(Régis Hanol) #4

Note that the backup upload is resumable :wink:


(Adam Capriola) #6

After about 10 minutes I received an email from system that my restore was successful but my screen is still showing this:

If I try to visit the home page in another tab I am logged out but the restore page still shows me as logged in. Is this normal? Just want to make sure I can exit the restore page safely.


(Arpit Jalan) #7

Yes, that is normal. It’s safe to exit restore page.


(AstonJ) #9

Is it possible to restore the backup via command line?

Having to wait for the DNS to propagate means that some people will see an empty(/default) discourse install when going to the site.

If we could restore via command line the change-over would go smoother.


(Fábio Machado De Oliveira) #12

How does that work? I am trying to upload my backup, and the progress bar always hangs between 11% and 14%, its just a 20MB file. I am using a multi container with a nginx proxy, is there a chance that my OS nginx to mess with my upload?

edit: Solved increasing the “client_max_body_size” configuration in my external OS nginx. The upload continued by itself, as I didn’t close the window. My browser console was showing a lot of “413 (Request Entity Too Large)” before I changed this configuration.


#13

Hello guys,

There is something I am missing.
I am currently hosting a discourse forum on Digital Ocean for my company, but IT people want to take ownership of the forum and install/migrate it on internal servers. What is the best way to do this?

  1. create a new discourse instance from scratch on the internal server (different address, emails settings and developers, i.e. different app.yml file) and get it working
  2. update the old forum to latest version, to ensure same version as the brand new instance
  3. install the required plugins on the new forum
  4. perform a backup on the old forum
  5. load the backup on the new instance?

What will happen with my profile, for example? Will I remain an administrator?
The configuration file app.yml must be the same for old and new forum?


(Dave Shaw) #14

I’ve followed those 5 steps above to move my discourse between 2 Ubuntu VM’s without any problems.

Yes, you will still be an administrator.

No, they don’t have to be the same (I initially moved mine without SSL until I could re-point the DNS).


(blaumeer) #16

Using the official backup/restore method exposed here, are uploads backed up as well? E.g. files, images and documents that are attached to the posts.


(Dean Taylor) #17

Depends which option you select when you start a manual backup:

Files are included in automated / scheduled backups as default.


(Erlend Sogge Heggen) #18

This is a very valid feature request.

Loosely related: It’d be great if instead of having to first locally download and then upload a backup file, you could just give Discourse a URL of the backup file. Files on Amazon S3 can be set to have a complete URL. This would make migrations of large backups significantly easier.


(Michael - DiscourseHosting.com) #19

This is already possible.

cd /var/www/discourse
RAILS_DB=default  RAILS_ENV=production bundle exec rails c

then

opts = {
  filename: "whateveryourforumiscalled-2016-04-12-153600.tar.gz",
  publish_to_message_bus: true
}

SiteSetting.allow_restore = true
BackupRestore.restore!(Discourse.system_user.id, opts)

(Dean Taylor) #20

This was also answered yesterday by @zogstrip in this thread:


(Paul Padier) #21

I’ve been told you don’t need the same versions - on the new server install the latest version then simply import your older backup

Is this confirmed?

I have a very old version of Discourse running on an old Heroku stack. Upgrading to the latest version is not an option (not able to push code changes to this Heroku app to its stack being EOL’d), so I need to generate the backup from this old version.


(Matt Palmer) #22

You can restore a backup from an older version of Discourse into a newer version, and it should, in general, work fine – part of the restore process is to run the database migrations to bring the schema in line with the current structure, after the database dump itself is loaded. This may, of course, significantly increase the time required to perform the restore, especially on a large, very out-of-date DB.

There is, however, a certain amount of “caveat restorer” involved here, because restoring from arbitrary old versions of Discourse to current master isn’t something that is exhaustively tested. So, you would be well served by doing a test restore onto a scratch site first, and make sure it’s doing the right things, before betting your live site.


(Paul Padier) #23

Sounds good, thanks!

The DB in question is relatively small, but the Discourse version is ~18 months old. Only one way to find out!


(Michael - DiscourseHosting.com) #24

In our experience this works pretty well, we haven’t seen any major issues with any version > 1.1 or so.


(Christoph) #29

What is not clear to in this how-to is how I configure the new discourse instance (to which I am moving). Maybe I am being over cautious, but my intention was to run the new instance under a different subdomain first (test.mydomain.com) and once I see that it’s working, I would point the DNS to the new instance using forum.mydomain.com. What does this imply for the setup of the new instance? In particular, what DISCOURSE_HOSTNAME do I set in the app.yml? Or differently put: what happens if I set DISCOURSE_HOSTNAME: 'forum.mydomain.com' even though the container is (also) receiving requests for forum.mydomain.com?