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 https://linux.die.net/man/5/netrc
My location for “.netrc” file is the homedirecty of the user running the script.
Here is a snippet:
BACKUP_PATH="/backup/nextcloud" LOGDATE=`date +%Y-%m-%d-%H-%M` LOGFILENAME=/backup/mylog-$LOGDATE.log curl --netrc -s -S -T /$BACKUP_PATH/db/$LOGDATE-db.sql.gz "https://your.cloud/remote.php/dav/files/<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 https://linux.die.net/man/1/curl