Introduction#
We have a compute instance that is running Owncloud, which we use to backup our files and whatnot. While we were configuring the instance and uploading our files, we quickly realized that our instance’s storage is very limited and did not have enough space to actually house all of our potential future backups.
But then we had an idea: what if we could hook up Cloudflare’s R2 service to Owncloud?
Stick with us as we show you how to do exactly that in this article.
Table of contents#
- Preamble
- Creating a bucket
- Installing the S3 extension for Owncloud
- Setting up R2 for your Owncloud instance
- Conclusion
Preamble#
💡 This guide assumes you’re running an instance of Owncloud on a Docker container using docker-compose.
If you don’t have an instance of Owncloud running on Docker, follow these steps:
You’ll need to install Docker first. The official Docker Docs page provides a guide on how to install Docker on just about every system.
Then, head over to Owncloud’s documentation page and install Owncloud on a Docker container.
Creating a bucket#
Go to your Cloudflare dashboard and navigate to the R2 page. Then click on the Create bucket button.
💡 When creating a bucket, make sure you give this bucket a unique name because you won’t be able to change it afterwards!
For the purposes of this guide, we’ll stick with the bucket name owncloud-instance
.
Once you’re done with that, head back to the R2 page, click on the Manage R2 API Tokens link and click on the Create API token button.
Bucket creation options#
Let’s go through each of the options on the page:
Token name: This is not that important, but if you want to be able to easily identify the R2 token on this page in the future, you can set a unique name here.
Permissions: Make sure you set this to Edit! Otherwise you may run into permission issues when uploading files.
TTL: If you just want to create this token and forget about it, set this to Infinity. Otherwise, this option is up to you.
When you’re done, click on the Create API Token button.
You’ll be able to see your Access Key ID and Secret Access Key values here. Keep them somewhere safe, as you will not be able to see them again!
Installing the S3 extension for Owncloud#
Once you’re done creating an R2 bucket, head over to your Owncloud admin dashboard.
Click on the menu bar located in the upper left corner, and select the Market tab.
Scroll down until you find the S3 Primary Object Storage extension, and install it.
💡 Note, you’ll want this extension and not the extension called “External Storage: S3”!
Setting up R2 for your Owncloud instance#
⚠️ Before proceeding any further, make sure you back up all your data! Proceeding with the steps below will wipe any data you had on your Owncloud instance.
You’re done with all that? Great. It’s time to configure R2 to work on your Owncloud instance.
Run the following command to access the filesystem of your Owncloud Docker instance:
Head over to the config folder. The config folder should have the following files:
We’re looking to edit the config.php file. Add the following to the configuration file:
S3 configuration options#
You’ll want to replace the following options:
bucket: This is your unique R2 bucket name that you created earlier. (I used
owncloud-instance
for this guide)key: This is the Access Key ID that you obtained when creating the R2 bucket.
secret: This is the Secret Access Key that you obtained when creating the R2 bucket.
hostname: You can find the bucket hostname on the bucket page itself. Make sure to only include the URL name! (the
/owncloud-instance
bit from the URL can be removed)
Then, run docker restart owncloud_server
to apply the changes.
And that’s it! Log back in to your Owncloud admin dashboard, and your instance should utilize your Cloudflare R2 bucket as its primary storage.
Conclusion#
Overall, it’s pretty painless for your Owncloud instance to utilize Cloudflare’s R2 service.
We will warn you though, Cloudflare’s base plan for R2 only includes 10 GB of storage per month.
But it all depends if you’re fine with that. :)
Hey! If you’re still here…
This is the first time we’re writing a blog post of this sort. Let us know if we did well, or if there’s anything we can improve with future blog posts. Thank you! ❤️