If you already have let's encrypt certificate and want to use it in new ubuntu os server. These instructions include automatic renewal, you can follow these steps:
Copy let's encrypt directory to the new machine. It's normally located at /etc/letsencrypt. Don't forget to adjust ownership
sudo chown ubuntu /etc/letsencrypt
Nginx web server.
sudo apt update
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
sudo systemctl reload nginx
sudo certbot renew --dry-run
Apache web server.
sudo apt update
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
sudo service apache2 reload
sudo certbot renew --dry-run
This command will automatically modify the configuration file at /etc/nginx/sites-enabled/defualt or /etc/apache2/sites-enabled/defualt.
Congrats! You've got HTTPS working on your server.