Change Discourse install storage location


(Joshua Rosenfeld) #1

Need to move your Discourse install to another (local) directory? Let’s get started!

Configure new directory

Ensure the new directory is properly mounted/connected as needed. Then create the folder where Discourse will live.

cd /new/discourse/location
mkdir -p shared/standalone

Copy existing files to new location

:warning: From this point forward your site will be down.

Stop the container to ensure no changes to the files are made during the transfer.

cd /var/discourse
./launcher stop app

Copy files to new location

rsync -avzh /var/discourse/shared/standalone/ /new/discourse/location/shared/standalone

Update app.yml and rebuild

Modify your app.yml so Discourse runs from the new location.

Current configuration:

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

Updated configuration:

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /new/discourse/location/shared/standalone
      guest: /shared
  - volume:
      host: /new/discourse/location/shared/standalone/log/var-log
      guest: /var/log

Rebuild Discourse

cd /var/discourse
sudo ./launcher rebuild app

:white_check_mark: Your site will now be back up.

Test changes

Open your site and confirm everything still looks OK. Ensure that all content (including uploads) is still displaying properly.

Delete files from old location

Once you’re happy everything is working, delete the old Discourse files to regain space.

cd /var/discourse
sudo rm -r shared/standalone

Change Storage Location