Skip to content

Instantly share code, notes, and snippets.

@roycewilliams
Last active August 5, 2023 19:31
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 roycewilliams/d6462a23cbee520848a3c7c33c5fe870 to your computer and use it in GitHub Desktop.
Save roycewilliams/d6462a23cbee520848a3c7c33c5fe870 to your computer and use it in GitHub Desktop.
a simple Mastodon filter JSON backup script
#!/bin/bash
# Ref/howto: https://infosec.exchange/@tychotithonus/110838547200953177
INSTANCE_NAME=inst.example
TOKEN=your-token-here
DATESTAMP=$(date "+%Y%m%d_%H%M%S")
OUTFILE="mastodon-filters_${INSTANCE_NAME}_${DATESTAMP}.json"
echo "- Attempting to back up filters from ${INSTANCE_NAME} ..."
curl -s -X GET \
-H "Authorization: Bearer ${TOKEN}" \
https://${INSTANCE_NAME}/api/v2/filters \
| python -m json.tool \
> "${OUTFILE}"
ls -la "${OUTFILE}"
echo ""
echo -n 'Filters: '
grep -c '"title":' "${OUTFILE}"
echo -n 'Keywords: '
grep -c '"keyword":' "${OUTFILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment