Configuration -> security profile -> properties -> SSH
# chmod u+x /ghettoVCB-master/ghettoVCB.sh # chmod u+x /ghettoVCB-master/ghettoVCB-restore.sh
# cat /ghettoVCB-master/4week.conf VM_BACKUP_VOLUME=/vmfs/volumes/backup DISK_BACKUP_FORMAT=thin # VM_BACKUP_ROTATION_COUNT=4 POWER_VM_DOWN_BEFORE_BACKUP=0 ENABLE_HARD_POWER_OFF=0 ITER_TO_WAIT_SHUTDOWN=3 POWER_DOWN_TIMEOUT=5 ENABLE_COMPRESSION=0 ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP=0 ENABLE_NON_PERSISTENT_NFS=1 UNMOUNT_NFS=1 # NFS , NFS_SERVER=10.1.3.101 NFS_MOUNT=/mnt/backup/vmware NFS_LOCAL_NAME=backup # NFS ( ESXi ) NFS_VM_BACKUP_DIR=autobackup/vm01 SNAPSHOT_TIMEOUT=15 # EMAIL_LOG=1 EMAIL_SERVER=mail.core.local EMAIL_SERVER_PORT=25 EMAIL_DELAY_INTERVAL=1 EMAIL_TO=admins@mail.local EMAIL_FROM=ghettoVCB@vm01.core.local WORKDIR_DEBUG=0 VM_SHUTDOWN_ORDER= VM_STARTUP_ORDER=
Where are the key parameters:nc
utility. This may cause a failure on the part of the mail server, with the argument " Recipient address rejected: Improper use of SMTP command pipelining
". It is necessary to exclude the corresponding check for ESXi servers (for postfix, this will be reject_unauth_pipelining
).esxcli vm process list
command. Each line of the list is one machine: # cat /ghettoVCB-master/week.list win7 win10 vCenterUpdate
If you need several backup plans, with different frequency and parameters, create the necessary number of configurations. # cat /var/spool/cron/crontabs/root #min hour day mon dow command #………………………. 3 18 * * 6 /ghettoVCB-master/ghettoVCB.sh -g /ghettoVCB-master/4week.conf -f /ghettoVCB-master/week.list > /var/log/ghettoVCB-backup-week-$((($(date +\%d)-1)/7+1)).log
$((($(date +\%d)-1)/7+1))
gives the number of the week in the month, so we do not accumulate garbage. # kill $(cat /var/run/crond.pid) # crond
# cat /etc/vmware/firewall/email.xml <ConfigRoot> <service> <id>email</id> <rule id="0000"> <direction>outbound</direction> <protocol>tcp</protocol> <porttype>dst</porttype> <port>25</port> </rule> <enabled>true</enabled> <required>false</required> </service> </ConfigRoot>
# esxcli network firewall refresh # esxcli network firewall ruleset list | grep email email true # nc mail.core.local 25 220 mail.core.local SMTP Postfix quit 221 2.0.0 Bye
# /ghettoVCB-master/ghettoVCB.sh -g /ghettoVCB-master/4week.conf -d dryrun -m vCenterUpdate
# /ghettoVCB-master/ghettoVCB.sh -g /ghettoVCB-master/4week.conf -d dryrun -m vCenterUpdate Logging output to "/tmp/ghettoVCB-2015-08-18_07-15-08-23516502.log" ... 2015-08-18 07:15:09 -- info: ============================== ghettoVCB LOG START ============================== 2015-08-18 07:15:09 -- info: CONFIG - USING GLOBAL GHETTOVCB CONFIGURATION FILE = /ghettoVCB-master/4week.conf 2015-08-18 07:15:09 -- info: CONFIG - VERSION = 2015_05_06_1 2015-08-18 07:15:09 -- info: CONFIG - GHETTOVCB_PID = 23516502 2015-08-18 07:15:09 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/backup/autobackup/vm01 2015-08-18 07:15:09 -- info: CONFIG - ENABLE_NON_PERSISTENT_NFS = 1 2015-08-18 07:15:09 -- info: CONFIG - UNMOUNT_NFS = 1 2015-08-18 07:15:09 -- info: CONFIG - NFS_SERVER = 10.1.3.101 2015-08-18 07:15:09 -- info: CONFIG - NFS_VERSION = nfs 2015-08-18 07:15:09 -- info: CONFIG - NFS_MOUNT = /mnt/backup/vmware 2015-08-18 07:15:09 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 4 2015-08-18 07:15:09 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2015-08-18_07-15-08 2015-08-18 07:15:09 -- info: CONFIG - DISK_BACKUP_FORMAT = thin 2015-08-18 07:15:09 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0 2015-08-18 07:15:09 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0 2015-08-18 07:15:09 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3 2015-08-18 07:15:09 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5 2015-08-18 07:15:09 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15 2015-08-18 07:15:09 -- info: CONFIG - LOG_LEVEL = dryrun 2015-08-18 07:15:09 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB-2015-08-18_07-15-08-23516502.log 2015-08-18 07:15:09 -- info: CONFIG - ENABLE_COMPRESSION = 0 2015-08-18 07:15:09 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0 2015-08-18 07:15:09 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0 2015-08-18 07:15:09 -- info: CONFIG - ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP = 0 2015-08-18 07:15:09 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all 2015-08-18 07:15:09 -- info: CONFIG - VM_SHUTDOWN_ORDER = 2015-08-18 07:15:09 -- info: CONFIG - VM_STARTUP_ORDER = 2015-08-18 07:15:09 -- info: CONFIG - RSYNC_LINK = 0 2015-08-18 07:15:09 -- info: CONFIG - EMAIL_LOG = 1 2015-08-18 07:15:09 -- info: CONFIG - EMAIL_SERVER = mail.core.local 2015-08-18 07:15:09 -- info: CONFIG - EMAIL_SERVER_PORT = 25 2015-08-18 07:15:09 -- info: CONFIG - EMAIL_DELAY_INTERVAL = 2 2015-08-18 07:15:09 -- info: CONFIG - EMAIL_FROM = ghettoVCB@vm02.core.local 2015-08-18 07:15:09 -- info: CONFIG - EMAIL_TO = admins@mail.local 2015-08-18 07:15:09 -- info: CONFIG - WORKDIR_DEBUG = 0 2015-08-18 07:15:09 -- info: 2015-08-18 07:15:10 -- dryrun: ############################################### 2015-08-18 07:15:10 -- dryrun: Virtual Machine: vCenterUpdate 2015-08-18 07:15:10 -- dryrun: VM_ID: 588 2015-08-18 07:15:10 -- dryrun: VMX_PATH: /vmfs/volumes/ds3524_ds/vCenterUpdate/vCenterUpdate.vmx 2015-08-18 07:15:10 -- dryrun: VMX_DIR: /vmfs/volumes/ds3524_ds/vCenterUpdate 2015-08-18 07:15:10 -- dryrun: VMX_CONF: vCenterUpdate/vCenterUpdate.vmx 2015-08-18 07:15:10 -- dryrun: VMFS_VOLUME: ds3524_ds 2015-08-18 07:15:10 -- dryrun: VMDK(s): 2015-08-18 07:15:10 -- dryrun: vCenterUpdate.vmdk 40 GB 2015-08-18 07:15:10 -- dryrun: INDEPENDENT VMDK(s): 2015-08-18 07:15:10 -- dryrun: TOTAL_VM_SIZE_TO_BACKUP: 40 GB 2015-08-18 07:15:10 -- dryrun: ############################################### 2015-08-18 07:15:10 -- info: ###### Final status: OK, only a dryrun. ###### 2015-08-18 07:15:10 -- info: ============================== ghettoVCB LOG END ================================
# /ghettoVCB-master/ghettoVCB.sh -g /ghettoVCB-master/4week.conf -f /ghettoVCB-master/week.list
autobackup/vm01/VMNAME/VMNAME-FULL_DATE/
# cat /etc/rc.local.d/local.sh #................... /bin/kill $(cat /var/run/crond.pid) /bin/echo "3 18 * * 6 /ghettoVCB-master/ghettoVCB.sh -g /ghettoVCB-master/4week.conf -f /ghettoVCB-master/week.list > /var/log/ghettoVCB-backup-week-$((($(date +\%d)-1)/7+1)).log" >> /var/spool/cron/crontabs/root /bin/busybox crond
# rpm -ivh vmware-esx-vib-author-5.0.0-0.0.847598.i386.rpm error: Failed dependencies: libc.so.6()(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libc.so.6(GLIBC_2.2.5)(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libc.so.6(GLIBC_2.3)(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libc.so.6(GLIBC_2.4)(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libdl.so.2()(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libdl.so.2(GLIBC_2.2.5)(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libpthread.so.0()(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386 libpthread.so.0(GLIBC_2.2.5)(64bit) is needed by vmware-esx-vib-author-5.0.0-0.0.847598.i386
rpm --nodeps
key rpm --nodeps
will save us. # mkdir -p stage/payloads/payload1/etc/vmware/firewall/
# cat stage/descriptor.xml <vib version="5.0"> <type>bootbank</type> <name>mailFirewall</name> <version>5.0.0-0.0.1</version> <vendor>Lelik.13a</vendor> <summary>Custom VIB from Lelik.13a</summary> <description>Adds custom firewall rule for mail sender to ESXi host</description> <relationships> <depends> </depends> <conflicts/> <replaces/> <provides/> <compatibleWith/> </relationships> <software-tags> </software-tags> <system-requires> <maintenance-mode>false</maintenance-mode> </system-requires> <file-list> </file-list> <acceptance-level>community</acceptance-level> <live-install-allowed>true</live-install-allowed> <live-remove-allowed>true</live-remove-allowed> <cimom-restart>false</cimom-restart> <stateless-ready>true</stateless-ready> <overlay>false</overlay> <payloads> <payload name="payload1" type="vgz"></payload> </payloads> </vib>
Detailed instructions for the parameters can be found on the utility website.stage/payloads/payload1/etc/vmware/firewall/email.xml
, where the path after " payload1
" is the desired path on the target server. # vibauthor -C -t stage -v mailFirewall.vib
# vibauthor -i -v mailFirewall.vib **** Info for VIB: mailFirewall.vib **** VIB Format: 2.0.0 VIB ID: Lelik.13a_bootbank_mailFirewall_5.0.0-0.0.1 VIB Type: bootbank Name: mailFirewall Version: 5.0.0-0.0.1 Vendor: Lelik.13a Summary: [Fling] Custom VIB from Lelik.13a Description: Adds custom firewall rule for mail sender to ESXi host Creation Date: 2015-08-12 09:47:07.199735+00:00 Provides: mailFirewall = 5.0.0-0.0.1 Depends: Conflicts: Replaces: mailFirewall << 5.0.0-0.0.1 Software Tags: [] MaintenanceMode: remove/update: False, installation: False Signed: False AcceptanceLevel: community LiveInstallAllowed: True LiveRemoveAllowed: True CimomRestart: False StatelessReady: True Overlay: False Payloads: Name Type Boot Size Checksums payload1 vgz 0 347 sha-256 69aa821faa4ccd5a5e34e487ecf6049aa6bf55652ffffbfaae1257e40610c405 sha-1 4d77e529c8da74e82d4aa4e816bcf193e29ab8de
# esxcli software vib install -v /tmp/mailFirewall.vib -f # esxcli software vib list | grep mail # esxcli network firewall refresh
Since the package adds its files to the system, it is necessary to use the " -f
" key. # /sbin/auto-backup.sh
# cat /ghettoVCB-master/vms_to_restore #"<DIRECTORY or .TGZ>;<DATASTORE_TO_RESTORE_TO>;<DISK_FORMAT_TO_RESTORE>" # DISK_FORMATS # 1 = zeroedthick # 2 = 2gbsparse # 3 = thin # 4 = eagerzeroedthick # eg "/vmfs/volumes/restore/autobackup/vm01/vCenterUpdate/vCenterUpdate-2015-08-13_07-55-50/;/vmfs/volumes/local_vm01/;3;vCenterUpdate-restore"
Where in order through " ; ": # /ghettoVCB-master/ghettoVCB-restore.sh -c /ghettoVCB-master/vms_to_restore -d 1
# /ghettoVCB-master/ghettoVCB-restore.sh -c /ghettoVCB-master/vms_to_restore -l /var/log/vms-restore.log ################## Restoring VM: vCenterUpdate-restore ##################### Start time: Fri Aug 14 06:05:06 UTC 2015 Restoring VM from: "/vmfs/volumes/restore/autobackup/vm01/vCenterUpdate/vCenterUpdate-2015-08-13_07-55-50/" Restoring VM to Datastore: "/vmfs/volumes/local_vm01/" using Disk Format: "thin" Creating VM directory: "/vmfs/volumes/local_vm01//vCenterUpdate-restore" ... Copying "vCenterUpdate.vmx" file ... Restoring VM's VMDK(s) ... Updating VMDK entry in "vCenterUpdate-restore.vmx" file ... Destination disk format: VMFS thin-provisioned Cloning disk '/vmfs/volumes/restore/autobackup/vm01/vCenterUpdate/vCenterUpdate-2015-08-13_07-55-50//vCenterUpdate.vmdk'... Clone: 100% done. Registering vCenterUpdate-restore ... 12 End time: Fri Aug 14 06:11:19 UTC 2015
displayName = vCenterUpdate-restore extendedConfigFile = "vCenterUpdate-restore.vmxf" scsi0:0.fileName = "vCenterUpdate-restore-0.vmdk" sched.swap.derivedName = "vCenterUpdate-ff0c3749.vswp"
Paths to files can (and should) be specified relative to the machine directory. Configuration -> storage -> -> "browse datastore"
-> "Add to inventory" *.vmx
Source: https://habr.com/ru/post/265043/
All Articles