How to backup and restore a whole /var/discourse app folder?

You cannot simply “tar up” the /var/discourse directory and move it to another machine, untar it, and start the discourse app.

One of the main reasons is that when you build / bootstrap Discourse, it (launcher as I recall off the top of my head) will check if a base Discourse container (image) exists and pull down the base discourse Docker image (if not) and start up that base docker image into a container.

After that base git pull, the build process will build another docker image (the app)

Both of these docker images (the base image and the app image) do not exist inside /var/discourse, so tarring up /var/discourse is only a partial “solution” (using this term loosely).

These Discourse docker images are built as docker images and as a part of Docker; they don’t “live” in /var/discourse but are built there and then moved to docker as docker images.

It might be possible to edit your container yml file and rebuild from scratch, but the more conventional way is to just save your:

  • container yml file(s)
  • your full backup with uploads

and then edit your container yammy, clone the discourse-docker repo and rebuild.

Then, restore your full backup, including uploads (from the command line in the container).

Using github as the repo is a cleaner solution that the older unix'y way of “tarring the whole darn thing up” and “moving the whole darn thing” over to another server. However, even with the “older unix way” this method often does not provide a complete solution because there are often shared libs in system, shared lib user directories, and more which are not a part of the distribution directory, and there are etc files which are not in the distro root directory, etc.

So, even on most modern linux systems, we use apt (on Ubuntu, for example) to pull the repo. In the case of Discourse docker, you are pulling (and building) discourse-docker to set up the base container and another discourse repo to build the app. So, /var/discourse is a “place to build” (the images) and a “place to share” (the data, the backups, the public static files,etc).

Hope this summary was useful in some small way.

2 Likes