Setting up backup and image uploads to DigitalOcean Spaces

FYI remap does not work because it only affects data in the post which does not contain the url. So, back to my question of how do you remap urls from s3 to spaces? Thanks guys!

1 Like

remap should work, it performs a deep and complete substitution on every single column in the database. As long as you know what from → to is you will be fine. The rebake at the end helps cause then it re-CDNifys your cooked markdown so you can allow for a CDN change as well if needed.


I think that’s the problem though, I need to change the cooked url. I tried to change a single image using this command:

rake posts:remap["",""]

and got: 0 posts remapped!

It seems the cooked url is not stored in the database, am I correct on that assumption?

Not at all, it is definitely stored in the DB… I would try a discourse db:remap which is the more atomic version.


rake posts:remap works on raw, not cooked. I think a rake posts:rebake would have worked, but using discourse db:remap is probably the better idea.


Forgive my ignorance, I tried this and it says Could not find command "db:remap[https://n.....

Is this the correct way to run it?

cd /var/discourse 
./launcher enter app
discourse db:remap["find","replace"]
1 Like

You can see an example of db:remap here


Thanks @sam, I finally got around to this and I’m still having trouble (of course). I ran these two commands as a test:

discourse remap '' ''

discourse remap '' ''

For each command it did report success:

Remapping posts cooked
1 rows affected!

But, as you can see in this post, the first image is not displaying, which is the url I tried to remap. It’s still the same url despite the remap.

In another post I tried to rebuild the html after doing this and it changes the first part of the url to which is my old s3 bucket which is not even in my settings anymore…

I just set up DigitalOcean Spaces on my Discourse following the above instruction. I was able to upload images to Spaces but not to back up. From the backup logs it seems like the backup location has not been changed:

[2018-12-01 06:46:28] EXCEPTION: /var/www/discourse/lib/backup_restore/backuper.rb:250:in `create_archive': Failed to gzip archive.

gzip: /var/www/discourse/public/backups/default/leasehackr-forum-2018-12-01-063452-v20181129094518.tar.gz: No space left on device

My backup setup is the following:

What am I missing? Thank you!

It’s right there in the error message. Your local disk is full.


Yes my local disk is full, that’s why I wanted to move to DO Spaces, which I just created. Is it possible?

On this issue, I think that the use of environment variables of kind DISCOURSE_S3_* in order to make the rake uploads:migrate_to_s3 task work, is bringing some unwanted consequences.
They seem to take precedence and duplicating the exact same settings one can enter in the website settings page, but also changing the link of any other asset (including JS stuff) to the provided CDN URL.
All this just to be able to move uplink files from a local server to S3/DigitalOcean Spaces? Seems a bit of an overkill, or a bug. :confused:
Se the ongoing discussion here.

Are the images uploaded to the digital ocean spaces only? and is it also possible to upload video’s (mp4) files to the spaces?

Maybe a stupid question :slight_smile:

Does this support the new CDN feature of spaces as well?

Has anyone figured out how to successfully rake uploads:migrate_to_s3 from local storage to DO Spaces? I messed around with it for a while, with all the hacks listed in various places, but had no luck. It’s still asking for all of the env vars, which is fine, but it seems to all presume AWS based on the error messages.


Can i edit this file, then make rebuild app without any fear?

No. Put your changes in environment variables. You now can override all site settings this way.

1 Like

After following this guide and running ./launcher rebuild app in /var/discourse – the site is not serving the javascript / css from the DO CDN. Is there a way to have those files stored in spaces and served to users at the edge?

You might be facing this issue

1 Like

I know DigitalOcean’s CDN service doesn’t work with Discourse, but I plan on using BunnyCDN with DigitalOcean Spaces or BackBlaze.

Does this guide work without having to do the following?: