I have a virtual machine (centos) running some file service for small files. What is the recommended way for backup? Should I backup the virtual machine disk/file (from outeside the virtual machine) or should run a backup agent inside the virtual machine, so i'll backup up the content and not the whole virutal disk?
TLDR: Install a backup agent within the VM.
Backing up the disk image from outside the VM certainly looks tempting, doesn't it? Especially if you have several VMs, then you can just tell the host machine to back up all the disk images and you're done, without needing to individually configure each VM to back itself up.
The problem with that approach, though, is that the host machine isn't aware of what the VM's operating system is doing internally. It doesn't know if there are any disk writes pending or in progress. It doesn't know about any write caches or output buffers internal to the VM process. And, therefore, it can't guarantee that the disk image it backs up will be a consistent image at the time of backup. The backed-up image file will almost certainly still be usable, but there's a strong chance that you'll need to run a filesystem repair on it first to clean things up.
The other major drawback to doing full-disk-image backups from the outside is that such backups are primarily useful for full-system restores. I you just need to get back last Thursday's version of one lost file, they're not so good for that - you need to restore the whole image from Thursday's backup, then use other tools to extract that one file from the second copy of the image, which will take a lot more time and space than if you had done a backup from within the VM and been able to restore only the one file of interest.
Also related to this is that full-image backups are more difficult (at best) to perform incrementally, meaning that you need to make a complete copy of the entire image every time you run a backup. With a content-based backup from within the VM, you can take periodic full backups and only back up changed files in between, allowing much more frequent backups with the same amount of storage space.
If you're making an image of the entire VM for disaster recovery purposes, or to use it as a master to clone for creating other VMs, then shutting the VM down and copying the full disk image is a good way to go about it. But it's not a good approach to doing routine backups of a running system.