Back to TIL
shell

Copy to a Nextcloud using Rclone

Nextcloud supports WebDAV, so uploading files using something like rclone is well-supported.

  1. Grab the WebDAV URL: log into your Nextcloud, open Files and tap File Settings. The WebDAV url should be shown at the bottom of the settings modal.

  2. If 2FA is in use, follow the link below the URL field where it talks about 2FA and create an app password. Note it down!

  3. Back on your machine, configure rclone. While they do have a wizard, I’d rather copy-paste a config. .config/rclone/rclone.conf:

    [nextcloud]
    type = webdav
    url = https://the-webdav-url-from-step-1/index.php/foobar/etc/bla
    vendor = nextcloud
    bearer_token = 1234-the-app-password-from-step-2
  4. Test it. My favorite command for that is lsd (no pun intended)

    rclone lsd nextcloud:

Now that the setup is done, here’s my favorite copy command:

rclone copy /media/youtube/footage-2025-03 nextcloud:youtube/footage-2025-03 --bwlimit 1M --fast-list --progress --transfers=1 -c --order-by=name,desc

This uploads some video footage for editing onto the Nextcloud. Here’s a breakdown of the args:

  • --bwlimit 1M: limit the upload to 1mbyte/s; I don’t want to saturate my entire upload bandwidth with this
  • --fast-list: optimization. grab existing files and directories in one transaction. details in the docs.
  • --progress: print progress
  • --transfers 1: one file at a time
  • -c: verify already uploaded files by comparing checksums, if possible (falls back to size if not).
  • --order-by=name,desc: upload files in alphabetical order