I was recently trying to restore an environment at a client site and kept getting access is denied. This baffled me because the account I was using had the proper database permissions to perform the task at hand and is a local admin on the server. The user is the account that I was used to create the web application.
It turns out the the user performing the restore needs to be a site collection administrator to restore from a backup. So in review the user account must have the proper rights (in my case they were dbo on the database) and be a site collection administrator on the site that you are trying to overwrite.