Skip to content

Instantly share code, notes, and snippets.

@gquittet
Last active October 21, 2025 14:02
Show Gist options
  • Select an option

  • Save gquittet/7f2cb57b42b79ea5581bd37bf7eff323 to your computer and use it in GitHub Desktop.

Select an option

Save gquittet/7f2cb57b42b79ea5581bd37bf7eff323 to your computer and use it in GitHub Desktop.

Sum size of binlog for a specific day

ls -lha binlog* | grep "Oct 20" | awk '{print $5}' | numfmt --from=iec | awk '{ sum += $1; } END { print sum; }' | numfmt --to=iec

Convert it to readable text file

mysqlbinlog -vv --base64-output=decode-rows binlog.190611 > binlog.190611.txt

Count occurences of database modifications

New approach (better performances)

rg -i --no-line-number '^[^*].*(update|insert|delete|replace|alter)' to_analyze.txt > statements_index.txt
cat statements_index.txt | tr '[A-Z]' '[a-z]' | sort | uniq -c | sort -rn > excel.txt

Slow approach

cat binlog.190611.txt |grep -i  'update\|insert\|delete\|replace\|alter' | tr ‘[A-Z]’ ‘[a-z]’|sed -e '/*/d' | sort | uniq -c | sort -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment