Looks like sub.mydomain.com wasn't created yet. Make sure you first create sub.mydomain.com website first, then remove it content (both files and database). Then you can copy files from the other domain and import the database. I usually do it like this.
- Go into your site directory and dump WordPress database with WP-CLI
cd /var/www/mydomain.com/htdocs
sudo wp db export --allow-root
- Create wordpress site with sub domain name
wo site create sub.mydomain.com --wp
- Cleanup default WP database and remove files
cd /var/www/sub.mydomain.com/htdocs
sudo -u www-data -H wp db clean --yes --path=/var/www/sub.mydomain.com/htdocs
sudo rm -rf /var/www/sub.mydomain.com/htdocs/*
- Transfer files from OLD SITE to NEW SITE
sudo cp -r /var/www/mydomain.com/htdocs/* .
sudo chown -R www-data:www-data *
- Restore the database on NEW SITE
cd /var/www/sub.mydomain.com/htdocs
sudo wp db import /var/www/mydomain.com/htdocs/mydomain_com.sql --allow-root
- OPTIONAL. If you need to enable SSL.
wo site update sub.mydomain.com --letsencrypt