Running a script to backup your VMWare machine. If you are running a server as a Virtual Machine and you are using VMWare to do this, you can have this VMware Virtual Machine completely backed up in a periodic basis, and here is how

Assumptions
You are going to make your backup in another PC not on the same the Virtual Machine is running.
Tasks

    1. Make possible to log into remote machines using no password
    2. Create the script to rotate your backup files in the destination server
    3. Create the cron file

1. Make possible to log into remote machines using no password
This is needed because when we copy the files from the server running VMWare to the backup server, we will not be able to enter the password, we will scp which will copy the files over a ssh connection, so we will need openssh server installed on the backup server
You can follow this instructions to have this done, you have to able to log from the server running your Virtual Machine to the backup Server
2. Create the script to rotate your backup Files in the destination server
-- First go to the backup server and create two folders in you home directory, these folders will be for the backup files.

mkdir $HOME/backup

mkdir $HOME/vmachine

-- Now create the script $HOME/backup/archivo.sh and make it executable with:
chmod +x $HOME/backup/archivo.sh

rm /home/user/backup/backup1.tar.gz

mv /home/user/backup/backup.tar.gz /home/user/backup/backup1.tar.gz

tar -czvf /home/user/backup/backup.tar.gz /home/user/vmachine/*

3. Create the cron file
-- The cron file should be placed on the /etc/cron.d/ directory of the Server where the virtual machine is hosted and should look like this:

50 12 * * 1,3,5 root ssh root@ip.of.the.backup.server $HOME/backup/archivo.sh
28 13 * * 1,3,5 root ssh ip.of.the.virtal.machine poweroff
29 13 * * 1,3,5 root scp /var/lib/vmware/Virtual\ Machines/virtualmachine/* root@ip.of.the.backup.server:$HOME/backup/
34 13 * * 1,3,5 root vmrun start /var/lib/vmware/Virtual\ Machines/virtualmachine/virtualmachine.vmx
I will explain a little what those lines produce line number:
1. At 12:50 on monday, wednesday and Friday, execute on the backup server the rotate script
2. At 13:28 on monday, wednesday and friday, turns off the Virtual Machine
3. At 13:29 on monday, wednesday and friday, copy the Virtual machine files from the host server to the backup server
4. At 13:34 on monday, wednesday and Friday turns the Virtual machine on.

Off course you will have to adjust the scripts to your files and directories or users if you are not using "root" what i recomend you, also the file "virtualmachine.vmx" should be the name of your virtualmachine.