Skip to content

Instantly share code, notes, and snippets.

@luckylittle
Last active April 11, 2024 01:53
Show Gist options
  • Save luckylittle/80f343221636bdb68fc8cc2e274752c6 to your computer and use it in GitHub Desktop.
Save luckylittle/80f343221636bdb68fc8cc2e274752c6 to your computer and use it in GitHub Desktop.
Bash script to backup the main settings & filters from autobrr (until proper db backup exists)
#!/bin/zsh
export AUTOBRR_HOST="127.0.0.1"
export AUTOBRR_API_KEY="abcdefghijklmnopqrstuvwxyz"
# Backup indexers
curl -X GET "http://${AUTOBRR_HOST}:7474/api/indexer" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq > autobrr_indexers$(date +%Y%m%d).json
# Backup IRCs
curl -X GET "http://${AUTOBRR_HOST}:7474/api/irc" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq > autobrr_ircs$(date +%Y%m%d).json
# Backup RSS Feeds
curl -X GET "http://${AUTOBRR_HOST}:7474/api/feeds" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq > autobrr_feeds$(date +%Y%m%d).json
# Backup filters
ids=$(curl -X GET "http://${AUTOBRR_HOST}:7474/api/filters" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq -r '.[].id')
while read -r id; do
name=$(curl -X GET "http://${AUTOBRR_HOST}:7474/api/filters/${id}" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq -r '.name')
curl -X GET "http://${AUTOBRR_HOST}:7474/api/filters/${id}" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq > autobrr_filter_${name}$(date +%Y%m%d).json
done <<< "$ids"
@luckylittle
Copy link
Author

Example - To add except_release_groups to all filters:

ids=$(curl -X GET "http://${AUTOBRR_HOST}:7474/api/filters" -H "X-API-Token: ${AUTOBRR_API_KEY}" | jq -r '.[].id')
while read -r id; do
  curl -X PATCH "http://${AUTOBRR_HOST}:7474/api/filters/${id}" -H "X-API-Token: ${AUTOBRR_API_KEY}" -d '{"except_release_groups":"PlayWEB,FLUX,NTb,MeGusta,d3g,LAMA,T0PAZ,ELiTE,FENiX,AOC,PiRaTeS,LEGi0N,CtrlHD,FraMeSToR,OFT"}'
done <<< "$ids"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment