What .dmg file? Mavericks installer does not come from the App Store as a .dmg file where did you get it?
You need to distinguish between the OS and the installer they are not the same thing.
You can run Mavericks off a thumb drive (would be a bit slow) but you can't install it from that.
You have two options, buy the installer on a thumb drive from e.g. ebay (not legal) and may cause problems later on.
Or upgrade to Yosemite. If you can run Mavericks you can run Yosemite. Just be aware there may be some apps you have that may not be compatible with Yosemite. You can check that on each app's web site.
Either way you need a BackUp as pm-r suggests or risk losing everything.
Pm-r I agree the jury still seems to be out on the subject of legality and there are people with a better grasp of the EULA than I but I do know that when you download an OS from the App Store it is attached to your purchase history and your account is identified. So buying it from another source means that it is possible for Apple to identify that this app came from another account. Could they apply a penalty for this? Good question. Either way if the OP downloaded it from the App Store it will be in his purchases and can be downloaded again. He may have to "show hidden" but it will be there.