linux – How to export the GPG key without user interaction?

I use GPG keys to encrypt backup copies with duplication, so I would like to export the key after it is generated, so I can move it to a backup location in case the server catches fire.

Is there any way to export the secret key without user interaction? I can generate keys with this piece of documentation, but every time I try to export the key, it asks for a password. I tried passing an environment variable like PASAFASE or adding - pass phrase, but keep asking for the password.

Is this possible or should I just copy the .gnupg directory and backup it instead? Each server only has a GPG key.

Trying this on Ubuntu Server 18.04 with GPG 2.2.8, by the way.