- Pretty permalinks for this post:
- https://fireburn.ru/posts/1570536527
<p>I’ve just exported my Micropub posts to CouchDB using just curl and jq. Here’s the command:</p> <pre><code> curl --silent -H "Authorization: Bearer $MICROPUBACCESSTOKEN" "${MICROPUB_ENDPOINT}?q=source&limit=$LIMIT" | jq ’{ "docs": .items | map(. + {
"_id": .properties.published[] | strptime("%Y-%m-%dT%H:%M:%S%Z") | mktime | tostring
}) | map(
if .properties | has("visibility") then
.
else (
. * {"properties": {"visibility": ["public"]}}
) end
) }’ | curl -u $COUCHDBAUTH localhost:5984/posts/bulk_docs -X POST -d@- -H "Content-Type: application/json" </code></pre>
<p>The variables <code>$LIMIT</code> (count of posts to be exported), <code>$MICROPUBACCESSTOKEN</code>, <code>$MICROPUBTOKEN</code> and <code>$COUCHDBAUTH</code> are set by user.</p>