Per aggiungere un cronjob
I went to roll out a new VMware server, grabbing the fresh ESXi 5.1 build. When implementing ghettoVCB I observed that the /bin/busybox location is no longer valid, and that rc.local is no longer editable. Not only that, but because William Lam hasn’t yet updated ghettoVCB to include the 5.1 version, the script won’t even run on 5.1. Turns out the rc.local injection needs to happen in “/etc/rc.local.d/local.sh”. Also, because busybox has moved you need to change the injection script as follows:
/bin/kill $(cat /var/run/crond.pid) /bin/echo "0 6 * * 0 /vmfs/volumes/backups/ghettoVCB/ghettoVCB.sh -a > /vmfs/volumes/backups/Logs/backup.log" >> /var/spool/cron/crontabs/root /usr/lib/vmware/busybox/bin/busybox crond
Spegnimento automatico
Volendo fare lo spegnimento automatico, si sfruttano i comandi:
/sbin/powerOffVms (Stop the current’s running vms) /bin/halt (Stop the Esx host)
Si crea il file auto-shutdown.sh:
#! /bin/ash echo “shutting down VMs..please wait..” /sbin/powerOffVms echo “done.” echo “shutting down the host now..” /bin/poweroff
Gli si danno i diritti di esecuzione:
chmod +x /vmfs/volumes/datastore1/auto-shutdown.sh
Si aggiunge lo script al cron tramite l’inserimento nel file local.sh di:
/bin/echo “0 22 * * * /vmfs/volumes/datastore1/auto-shutdown.sh” >> /var/spool/cron/crontabs/root
Guida a ghettoVCB
ghettoVCB è uno script per il backup di macchine virtuali su ESXi. In allegato le guide sull’utilizzo e per fare il restore.
Per installarlo si può fare tramite il pacchetto vib, va prima scaricato il pacchetto da qui
To install the ghettoVCB VIB, you just need to download the VIB and run the following ESXCLI command and specifying the full path to the VIB:
esxcli software vib install -v /vghetto-ghettoVCB.vib -f
Once installed, you will find all ghettoVCB configuration files located in:
/etc/ghettovcb/ghettoVCB.conf /etc/ghettovcb/ghettoVCB-restore_vm_restore_configuration_template /etc/ghettovcb/ghettoVCB-vm_backup_configuration_template
Both ghettoVCB and ghettoVCB-restore scripts are located in:
/opt/ghettovcb/bin/ghettoVCB.sh /opt/ghettovcb/bin/ghettoVCB-restore.sh
One additional thing I would like to point out is that you can also quickly tell which version of ghettoVCB is running by inspecting the installed VIB by using the following ESXCLI command:
esxcli software vib list -n ghettoVCB
Aggiungere regola firewall per uscita su porta 25
Creare il file firewallRule.xml in un volume sempre accessibile con all’itnerno le regole da aggiungere (come quelle per la porta 25):
<ConfigRoot> <service id='1000'> <id>SMTP</id> <rule> <direction>outbound</direction> <protocol>tcp</protocol> <porttype>dst</porttype> <port>25</port> </rule> <enabled>true</enabled> <required>false</required> </service> </ConfigRoot>
Inserire nel file /etc/rc.local.d/local.sh le seguenti righe per la copia del file xml tra quelli di configurazione del firewall e per il refresh della configurazione:
cp /vmfs/volumes/Locale/aggiunte/firewallRule.xml /etc/vmware/firewall/ esxcli network firewall refresh