Assuming you have jq installed:
jq -r '.letsencrypt.Certificates[] | select(.domain.main=="db.example.com") | .certificate' /etc/dokploy/traefik/dynamic/acme.json | base64 -d > /root/certs/tls_cert.pem
jq -r '.letsencrypt.Certificates[] | select(.domain.main=="db.example.com") | .key' /etc/dokploy/traefik/dynamic/acme.json | base64 -d > /root/certs/tls_key.pem