Instantly share code, notes, and snippets.

@gtwy /vmware_backup.txt Secret
Last active Nov 18, 2018

Embed
What would you like to do?
VMware ESXi Backup Configuration
=============================== BACKUP SERVER ===============================
[root@backup cron.d]# pwd
/etc/cron.d
[root@backup cron.d]# ls -al
total 20
drwxr-xr-x. 2 root root 35 Apr 29 20:41 .
drwxr-xr-x. 78 root root 8192 Apr 29 20:59 ..
-rw-r--r--. 1 root root 128 Jul 27 2015 0hourly
-rw-r--r--. 1 root root 133 Apr 29 20:41 1SQL_BAK
[root@backup cron.d]# cat 1SQL_BAK
0 10 * * * root rsync -aXs /sync/sqlsync/. /sync/sqlretain/.
0 15 * * * root find /sync/sqlretain/Backups/* -mtime +120 -exec rm {} \;
[root@backup cron.d]# cat /etc/fstab
/dev/mapper/rootvg-rootlv / xfs defaults 0 0
UUID=6d0e3242-5350-4791-8b7a-f076fb339a1e /boot xfs defaults 0 0
/dev/mapper/rootvg-homelv /home xfs defaults 0 0
/dev/mapper/rootvg-swaplv swap swap defaults 0 0
/dev/sdb1 /sync/sqlsync ext4 defaults 1 2
/dev/sdc1 /sync/sqlretain ext4 defaults 1 2
/dev/sdd1 /backup ext4 defaults 1 2
[root@backup cron.d]# cd /sync
[root@backup sync]# ls -al
total 12
drwxrwxrwx. 4 root root 36 Dec 29 2015 .
dr-xr-xr-x. 21 root root 4096 Apr 25 16:10 ..
drwxrwxrwx. 4 root root 4096 Apr 29 20:35 sqlretain
drwxrwxrwx. 4 root root 4096 Apr 29 20:35 sqlsync
[root@backup sqlretain]# pwd
/sync/sqlretain
[root@backup sqlretain]# ls -al
total 28
drwxrwxrwx. 4 root root 4096 Apr 29 20:35 .
drwxrwxrwx. 4 root root 36 Dec 29 2015 ..
drwxrwxrwx. 4 nobody nobody 4096 Apr 29 20:33 Backups
-rwxrwxrwx. 1 root root 236 Apr 29 20:35 DO_NOT_PLACE_ANYTHING_IN_THIS_FOLDER.TXT
drwxrwxrwx. 2 root root 16384 Apr 29 17:16 lost+found
[root@backup sqlsync]# pwd
/sync/sqlsync
[root@backup sqlsync]# ls -al
total 28
drwxrwxrwx. 4 root root 4096 Apr 29 20:35 .
drwxrwxrwx. 4 root root 36 Dec 29 2015 ..
drwxrwxrwx. 3 nobody nobody 4096 Apr 29 20:33 Backups
-rwxrwxrwx. 1 root root 236 Apr 29 20:35 DO_NOT_PLACE_ANYTHING_IN_THIS_FOLDER.TXT
drwxrwxrwx. 2 root root 16384 Apr 29 17:16 lost+found
[root@backup /]# cd /backup
[root@backup backup]# ls -al
total 96
drwxr-xr-x. 9 root root 4096 Apr 29 15:42 .
dr-xr-xr-x. 21 root root 4096 Apr 25 16:10 ..
drwxrwxrwx. 3 root root 4096 Aug 4 2017 bin
-rw-r--r--. 1 root root 46109 Apr 3 2016 bin.tar.gz
drwx------. 2 root root 16384 Dec 29 2015 lost+found
drwxr-xr-x. 3 nfsnobody nfsnobody 4096 Sep 24 2017 SightlineDC
drwxr-xr-x. 12 nfsnobody nfsnobody 4096 Apr 23 17:16 SightlineDC16
drwxr-xr-x. 8 nfsnobody nfsnobody 4096 Apr 23 00:08 SightlineRDP
drwxr-xr-x. 8 nfsnobody nfsnobody 4096 Apr 23 01:54 SightlineSQL
drwxr-xr-x. 4 root root 4096 Apr 29 20:41 sqlretain
[root@backup etc]# cat exports
/backup 10.77.1.20(rw,async,no_subtree_check,root_squash)
[root@backup samba]# pwd
/etc/samba
[root@backup samba]# ls -al
total 20
drwxr-xr-x. 2 root root 35 May 7 09:42 .
drwxr-xr-x. 78 root root 8192 May 31 22:16 ..
-rw-r--r--. 1 root root 20 Nov 21 2015 lmhosts
-rw-r--r--. 1 root root 594 Dec 20 2015 smb.conf
[root@backup samba]# cat smb.conf
[global]
workgroup = sl.local
guest account = nobody
map to guest = bad user
server string = Samba Server Version %v
; netbios name = MYSERVER
; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
hosts allow = 127. 10.77.1.22
; max protocol = SMB2
# log files split per-machine:
log file = /var/log/samba/log.%m
# maximum size of 50KB per log file, then rotate:
max log size = 50
security = user
passdb backend = tdbsam
load printers = no
[sqlsync]
comment = Fileshare for mssql exports
path = /sync/sqlsync
browseable = yes
guest ok = yes
writable = yes
read only = no
[root@backup samba]# cat lmhosts
127.0.0.1 localhost
================================ ESXi SERVER ================================
[root@backup backup]# ssh 10.77.1.20
ESXi Server is in UTC time. So, convert desired EST time to UTC time.
9:00pm = 02:00 (the day after)
written in cron as "0 2" (m h)
[root@SightlineESXi:/etc/rc.local.d] cat local.sh
#!/bin/sh
/bin/kill $(cat /var/run/crond.pid)
/bin/echo "0 2 * * * /vmfs/volumes/backup/bin/backup.sh -g /vmfs/volumes/backup/bin/daily.conf -f /vmfs/volumes/backup/bin/daily_list > /vmfs/volumes/backup/bin/log/backup-daily-\$(date +\\%m-\\%d-\\%y).log" >> /var/spool/cron/crontabs/root
/bin/echo "33 8 * * 0 /vmfs/volumes/backup/bin/backup.sh -g /vmfs/volumes/backup/bin/weekly.conf -f /vmfs/volumes/backup/bin/weekly_list > /vmfs/volumes/backup/bin/log/backup-weekly-\$(date +\\%m-\\%d-\\%y).log" >> /var/spool/cron/crontabs/root
/bin/crond
exit 0
[root@SightlineESXi:/var/spool/cron/crontabs] cat root
#min hour day mon dow command
1 1 * * * /sbin/tmpwatch.py
1 * * * * /sbin/auto-backup.sh
0 * * * * /usr/lib/vmware/vmksummary/log-heartbeat.py
*/5 * * * * /bin/hostd-probe.sh ++group=host/vim/vmvisor/hostd-probe/stats/sh
00 1 * * * localcli storage core device purge
0 2 * * * /vmfs/volumes/backup/bin/backup.sh -g /vmfs/volumes/backup/bin/daily.conf -f /vmfs/volumes/backup/bin/daily_list > /vmfs/volumes/backup/bin/log/backup-daily-$(date +\%m-\%d-\%y).log
33 8 * * 0 /vmfs/volumes/backup/bin/backup.sh -g /vmfs/volumes/backup/bin/weekly.conf -f /vmfs/volumes/backup/bin/weekly_list > /vmfs/volumes/backup/bin/log/backup-weekly-\$(date +\\%m-\\%d-\\%y).log
================================ SQL SERVER =================================
Execute these three separately on the MS SQL instance
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
---
EXEC sp_configure 'xp_cmdshell',1
GO
RECONFIGURE
GO
--- (will give an error)
EXEC XP_CMDSHELL 'net use Z: \\10.77.1.5\sqlsync'
--- (makes sure the volume is there.)
EXEC XP_CMDSHELL 'Dir Z:'
Now setup a maintenance schedule to backup to Z:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment