Troubleshooting & How-Tos 📡 🔍 Servers

Adding External S3 Storage on Nextcloud Using OCC

Nextcloud can use external sources like S3 or SFTP (or other Nextcloud servers!) for additional storage, which you can mount as a folder for all users or for a specific user. These folders will work just like regular folders on your Nextcloud server, except the data is stored somewhere else, like a remote backup service or an object storage bucket. (Useful if you want to store large files or media libraries without filling up the server’s main drive.)

For all users, or for your own login, it’s easier to set it up through the GUI. To set up an external folder for a specific user, you can use the occ command-line tool.

OCC is run on the server, as the webserver account. Depending on your setup you may need to use sudo, su, runuser, etc. and you may need to point it to the right php location. (See the previous link for reference.)

Or if you’re using the Nextcloud Snap, it’ll just be this:

sudo nextcloud.occ

Anyway, I cobbled together this config from an example that had the wrong authentication method, and extrapolating from a working config I’d set up for my own login using the GUI (checked via occ files_external:list):

WRAPPER_TO_OCC files_external:create FOLDER_NAME \
  amazons3 \
  amazons3::accesskey \
  --user=USER_NAME \
  --config bucket="YOUR_BUCKET" \
  --config hostname="YOUR_HOST" \
  --config port="443" \
  --config use_ssl="true" \
  --config use_path_style="true" \
  --config key="YOUR_KEY" \
  --config secret="YOUR_SECRET"

It worked just fine on Linode’s object storage. And yes, it still has to say amazons3 even if you’re using a different S3 provider.