Skip to content

Instantly share code, notes, and snippets.

@amane-katagiri
Last active September 1, 2021 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amane-katagiri/f26578e694ca1efca778c837351d8e85 to your computer and use it in GitHub Desktop.
Save amane-katagiri/f26578e694ca1efca778c837351d8e85 to your computer and use it in GitHub Desktop.
#!/bin/bash -Cue
if [ $# -ge 2 ]; then
SRC="$1"
DST="$2"
else
echo "usage: $0 SRC DST" >&2
exit 1
fi
if [ -f "${HOME}/.nextcloud_token" ]; then
CRED="$(cat "${HOME}/.nextcloud_token")"
elif [ -z "${CRED+UNDEF}" ];then
echo "Set env or credential file:" >&2
echo "- \`CRED=user:token $0 $@\`" >&2
echo "- \`echo 'user:token' > '${HOME}/.nextcloud_token'\` and \`$0 $@\`" >&2
exit 1
fi
if command -v nextcloudcmd >/dev/null; then
CLOUDCMD=nextcloudcmd
elif command -v owncloudcmd >/dev/null; then
CLOUDCMD=owncloudcmd
else
echo 'no (next|own)cloudcmd found.' >&2
fi
EXCLUDE_LIST=$(mktemp)
curl -Sso "$EXCLUDE_LIST" https://github.com/owncloud/client/raw/master/sync-exclude.lst
"$CLOUDCMD" --exclude "$EXCLUDE_LIST" "$SRC" "https://${CRED}@nc.ama.ne.jp/remote.php/webdav${DST}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment