Move Uploads and Backups to DigitalOcean Block Storage

So you want to move all uploads and backups to DigitalOcean Block Storage?

Before you do this, though, you might instead consider Configure an S3 compatible object storage provider for uploads. It is no more complicated to set up and provides some other advantages.

Setup a Discourse instance on DigitalOcean

Setup a Discourse instance on DigitalOcean using our official guide.

Add a Volume to your droplet

Add a block storage volume to your droplet. Note down the name of the volume. In my case the name of the volume was volume-nyc1-05.

Make sure the volume is formatted and mounted at /mnt/volume_nyc1_05.

Move /var/discourse/shared to the volume

For best performance we will keep postgres_data on our main drive and will move rest of the data to the newly attached volume.

Logged in as root, run these commands from your server:

mv /var/discourse/shared/standalone/postgres_data /var/postgres_data_discourse
mv /var/discourse/shared /mnt/volume_nyc1_05

Make sure to replace volume_nyc1_05 with the name of your volume.

Edit app.yml to reflect the changes

Open the /var/discourse/containers/app.yml file in your preferred editor and look for this block:

## 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

Replace the above block with:

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

Make sure to replace volume_nyc1_05 with the name of your volume.

Save the app.yml file and rebuild the container.

/var/discourse/launcher rebuild app

:tada: Voila!

That’s it all your uploads and backups are now moved to DigitalOcean Block Storage.


Credits

This guide is inspired from @sam’s suggestion here.

Last edited by @JammyDodger 2024-05-25T11:04:25Z

Check documentPerform check on document:
37개의 좋아요

Hetzner의 유사한 스토리지를 사용하는 이 접근 방식을 따르고 있는데, 이것이 전반적인 성능에 해가 될지 궁금합니다.

SSD 속도의 1/3만 제공된다는 글을 읽었는데, Discourse 인스턴스에서 파일 업로드 및 파일 표시 시 일상적인 사용에서 체감할 수 있는 차이가 있는지, 아니면 1/3 속도라 해도 파일 업로드에는 문제가 없는지 확신이 서지 않습니다.

물론 최종 결과는 CPU, RAM, 그리고 사용하는 파일 시스템 및 블록 크기에 따라 달라집니다.

경험을 공유해 주실 분 계신가요? :slight_smile:

가이드 감사합니다!

이 작업을 수행하기 전에 드롭레트를 껐다가 다시 켜야 하나요? 보통은 켜야 한다고 생각하지만, 업로드만 정리하는 작업이라면 굳이 그럴 필요가 없는 것 같기도 하고요?

아니요. 공간을 생성한 후 설명에 따라 마운트하기만 하면 됩니다.

가이드에 감사드립니다. 모든 단계를 완료하고 포럼을 다시 가동한 후에도 경로가 올바르지 않아 로드되지 않은 이미지들이 계속 발견됩니다.

이 문제를 진단하고 자동으로 수정할 수 있는 방법이 있을까요?

결국 문제를 해결했나요?

1개의 좋아요

아니 :frowning: 아직 해결하지 못했어.

1개의 좋아요