How to upload a file to your Nextcloud using curl


during the 2020 virtual conf two attendees asked me on how about to upload a file to Nextcloud using curl.
This can be useful to send backups from a machine to your nextcloud e.g. dump your addressbooks to vcf files and save them into your NC. Or dump your NC db and save backup in your NC.

Here are some notes for you.

First create a .netrc file containing your credentials. For help about that please see
My location for β€œ.netrc” file is the homedirecty of the user running the script.

Here is a snippet:

LOGDATE=`date +%Y-%m-%d-%H-%M`
curl --netrc -s -S -T /$BACKUP_PATH/db/$LOGDATE-db.sql.gz "<path-on-your-server>/" >> $LOGFILENAME && rm /$BACKUP_PATH/db/$LOGDATE-db.sql.gz

You need to adapt your pathes.

For curl options see the docs at


Hello @sergsqr

see my posting. Maybe you find it already.


Perhaps someone like to implement an url-to-nextcloud-download app like part of upload-function from

App OcDownloader does not work for me.

I would like to add my bash script curl string because it uses direct username:password

curl -k -u "USERNAME:P4s5word" -T "/source/file.txt" "<path-on-your-server>/file.txt"
1 Like

Sorry no real help.
But there is the new app Transfer for uploading with url if you want to upload from web interface from external url.

For your problem maye problem with quotes.
curl -u USERNAME:PASSWORD -T /path/to/file
How to upload a file via CLI to Nextcloud? (bash)

There is no problem just an example not using netrc and user:passwd in command directly.