by Ken Task.
In addition to what Howard has suggested ...
When you put the config.php file back into the apache root (/var/www/html/), did file permissions/ownerships get changed?
What are permissions on config.php ... it must have at least 'read' for the owner of the file ... which in Ubuntu is www-data (I think).
-r--------. 1 www-data www-data 1087 Sep 1 15:45 config.php
If moodle cannot find nor read config.php it assumes new installation, me thinks, rather than recognizing new code and sending you to upgrade.
BTW, since you have linux, in admin/cli/ of code there are cli scripts only that will do the upgrade ... takes apache out of the loop then.
'spirit of sharing', Ken