I know there was a forum here for user created scripts and whatnot but I can no longer find it...but I wanted to share a script that a colleague and I put together to back up the contents of the /etc folder prior to any upgrades, updates, etc. I wanted to get this scripted because a while back while updating some hosts to 3.0.2...something went wonky and one of the hosts ended up with a corrupted esx.conf file that took VMware Support to help us figure out what the issue was. I did some searching today here on the forums about what to backup prior to an upgrade and I saw that most of the "gurus" here said they felt that backing up /etc was the most important. The script we came up with actually relies on 3 files total for it to work correctly.
First, in the home directory of the logged in user, create a file called .netrc. Open this file in an editor and add the following:
machine <IP address of the ftp server>
login <username for the ftp server>
password <password for the ftp server>
Save the file and chmod it to 600 to keep others from being able to access the file.
Next, a file called autoftp was created and chmod'd to be executable. It contains the following:
open x.x.x.x <opens an ftp session to the ftp server>
cd <Folder for the backups>
bin <changes to binary mode>
prompt <disables interactive prompting>
lcd <file location>
mput *.tgz <transfers the tar gzip'd archive the folder on the FTP server>
bye <ends the ftp session>
Finally, a file called esxbackup was created. The file contains the following:
#!/bin/sh
Today="`date +%y%m%d`" <sets a variable called Today that takes today's date and adds the year and month before it>
tar -czvf $HOSTNAME.$Today.tgz etc/ <creates a gzipped tar file of /etc and names it as FQDN and date.tgz>
esxcfg-firewall -allowOutgoing <Disables the firewall>
esxcfg-firewall -allowIncoming
ftp < autoftp <runs ftp using the options found in a file called autoftp>
esxcfg-firewall -BlockIncoming <Enables the firewall>
esxcfg-firewall -BlockOutgoing
If all goes properly, after the script completes, you should be able to check the ftp server and see an archive in the format of full.host.name.<Date>.tgz
I am sure there are alot more elegant scripts out there to handle this, but this works for us and I wanted to share it with you guys.
Thanks for the script, it looks great and you can find more advance scripts created by Jason Boche, Mike Laverick, Steve Beaver and Dominic Rivera on here and those are great tools to have.
If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!!!
Regards,
Stefan Nguyen
iGeek Systems Inc.
VMware, Citrix, Microsoft Consultant
Hello,
Remember that even though you backup /etc, you can not just overlay it back on top of a fresh installation and expect it to work. You will need to use your backup /etc as a framework for redoing all your modifications. There are several discussions about this on the forums. THe best backup for an ESX server is a fully configured scripted installation and very good install documentation.
Best regards,
Edward L. Haletky
VMware Communities User Moderator
====
Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education. CIO Virtualization Blog: http://www.cio.com/blog/index/topic/168354, As well as the Virtualization Wiki at http://www.astroarch.com/wiki/index.php/Virtualization
Those are good points Edward, I agree. We usually recommend to take a backup /etc and save it. Then use it as a reference later if needed like you are saying.
Where are the scripts by Jason, Mike, Steve, and Dominic located?
Dominic's script is located here
http://vmprofessional.com/index.php?content=scripted_install