Last active
August 5, 2023 19:31
-
-
Save roycewilliams/d6462a23cbee520848a3c7c33c5fe870 to your computer and use it in GitHub Desktop.
a simple Mastodon filter JSON backup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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