Cron task to sync local backups to DigitalOcean Spaces

AI-generated summary

The user varun21 is experiencing issues with syncing local backups to DigitalOcean Spaces using Discourse. Despite having the DigitalOcean Spaces bucket mounted on the host machine with the same credentials, the backup process fails with a Forbidden error and SignatureDoesNotMatch exception.

varun21 found a temporary solution by using a bash script to manually copy local backups to the host machine and then move them to DigitalOcean Spaces. However, pfaffman suggested configuring S3 backups directly instead of using s3fs, which is not supported by Discourse.

After some troubleshooting, pfaffman pointed out that the issue might be due to incorrect credentials or bucket name, and suggested setting the FORCE_S3_UPLOADS environment variable in the app.yml file.

Finally, varun21 was able to successfully configure backups to upload to DigitalOcean Spaces without uploading file uploads to Object Storage. The solution involved setting the correct endpoint and configuring the S3 backups.

It doesn’t seem I can get backups to DigitalOcean Spaces to work. However the server has the bucket mounted over s3fs with the same credentials. I only need the backups to be stored on Spaces, not uploads etc. Logs say EXCEPTION: Aws::S3::Errors::Forbidden Production log says Failed to list backups from S3: Aws::S3::Errors::SignatureDoesNotMatch

Is there a way to cron task a move of the local backup to the bucket via a bash script? Thanks.

For anyone else running into this and wants to keep rolling, you can issue this command at the bash terminal. The user needs to be part of the docker group
docker cp app:"/var/www/discourse/public/backups/default" /whatever-host-path/

Do you mean discourse backups? If so, why is this in WordPress?

If you want them to go to spaces why not just configure S3 backups?

The main site is WordPress. Discourse is in subdirectory.
Main site: main.com
Discourse: main.com/forums
But configuring S3 credentials for DigitalOcean Spaces gives me the above errors. I have a deadline to meet so just got around this by the commands I mentioned earlier. But it would be handy to see someone’s working settings and / or troubleshooting steps to make this work.

Above you mention s3fs. You don’t need that. The errors above are coming from s3fs, which is not something that Discourse supports. You want to follow something like Setting up file and image uploads to S3 or Using Object Storage for Uploads (S3 & Clones), but configure just the backup bucket.

To make it more explicit, the “host” has the DigitalOcean Spaces bucket mounted, not the container. The two issues are unrelated. Backups throw the errors if Discouse is configured for S3. Backups work if I manually copy the local backups to the host machine and then move them to DigitalOcean Spaces.

If the Forbidden logs are from Discourse and not s3fs, trying to save to the Spaces bucket then it’s something like you have the wrong credentials or wrong bucket name.

Ah!

   Failed to list backups from S3:

Ah. I think that’s the problem. It’s trying to get a bucket list and can’t. I’m not quite sure how to fix it, but that’s the problem that you want to solve, so you might edit the subject. If you want to fix your S3 backups, you can get help here; if you want to configure s3fs you’ll llkely need to seek help elsewhere.

Try this ENV variable in your app.yml

  FORCE_S3_UPLOADS: 1

IS your endpoint correct? Have a look at the Digital Ocean section in Using Object Storage for Uploads (S3 & Clones).

Finally this worked for DigitalOcean Spaces a) Uploading backups to Object Storage b) Not uploading file uploads to Object Storage. Kindly mark this as resolved. Thanks everyone!