Skip to content

Instantly share code, notes, and snippets.

@AcckiyGerman
Last active July 24, 2020 14:07
Show Gist options
  • Save AcckiyGerman/84c5b6359f565010f0ab5122b86b6f62 to your computer and use it in GitHub Desktop.
Save AcckiyGerman/84c5b6359f565010f0ab5122b86b6f62 to your computer and use it in GitHub Desktop.
SOURCE_DIR="/absolute/source/dir"
# it is a nextcloud server in the example; in your case see the docs of your webdav server
DESTINATION="https://cloud.2hv.de/remote.php/webdav/target_folder/"
USER='user_name'
PASS='user_password'
cd "${SOURCE_DIR}" || exit
while IFS= read -r -d '' file
do
if [ -d "${file}" ] && [[ $file != '.' ]]; then
echo "create folder: ${file}"
curl -X MKCOL "${DESTINATION}${file}" --user "${USER}:${PASS}"
elif [ -f "${file}" ]; then
echo "upload file: ${file}"
curl -T "${file}" "${DESTINATION}${file}" --user "${USER}:${PASS}"
fi
done < <(find . -print0)
# echo "clean the source folder.."
# rm "${SOURCE_DIR:?}"* -vrf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment