I can do it like this: move all files, change dns, add certificate. But this means there will be some time between moving websites and getting certificate, so my website will not have https during this time.
I would like to have ssl on the new server, so that when all files are moved and dns is changed, it would work immediately with https.
I can't do it right now with usual "-d example.com", it shows:
Challenge failed for domain example.com
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
Is there an option to add domain certificate that has different DNS IP right now?
You may want to copy all the file tree of /etc/letsencrypt. It contains configuration files too. When the new system is in production (the domain name is pointing there), you may want to generate a test certificate, to make sure that everything is working as expected.
Verify the content of the crontab file, and copy it if needed. Just to be sure that the certificate renewal is properly scheduled.