Clone and backup virtual and physical servers…. complete backup….

This article explains how to clone and duplicate a Linux OS without any downtime……
I have a CentOS running on ESX 3i (data-store 2)
I borrowed a 40 GB space via NFS and named it data-store 1 which i will be using as a backup for my Linux OS

This is what i did…..

Download VMware vCenter Converter Standalone for linux…
Unzip the downloaded package
# tar xvzf VMware-converter-4.0.1-161434.tar.gz
Run the VMware Vcenter Converter from your shell as:
# /usr/bin/vmware-converter-client
(remember that it is a GUI based utility and you need to be on runlevel 5)
Once the application loads,
click on > convert machine
select a source type > chose your option… ( mine was a powered on machine )
specify the machine details
click > next
On specify destination >
it will ask for Vmware infrastructure server details,
enter the server ip (the one that was running ESX 3i) , user and pass
click next>
Select data-store>
I selected data-store 1 as my destination so i will have a clone of my centos on a NFS drive
Click > next
The process will start and its pretty straight forward.

Once it is finished, you can see a clone linux os through the vmware infrastructure client… but standing on a NFS shared storage.



1.# yum install dhcp
2.y for accept and install

3.# vi /etc/sysconfig/network-scripts/ifcfg-eth0

4.#vi /etc/sysconfig/network

5.# service network restart
6.#ifconfig eth0
7.# service iptables stop

9.# vi /etc/dhcpd.conf
(see /usr/share/doc/dhcp*/ dhcpd.conf.sample)
10.# cp /etc/dhcpd.conf /etc/dhcpdori.conf
11.# cp /usr/share/doc/dhcp*/ dhcpd.conf.sample /etc/dhcpd.conf (replace * with version number)
Overwrite ?:y
12.# vi /etc/dhcpd.conf
subnet netmask
# … option router;
# option domain-name
option domain-name-servers;
range dynamic-bootp;
13.# service dhcpd start

1.# ping
2.#ifconfig (check Default Gateway: It should take ip in between

Again, try the following:
Change range in server # service dhcpd restart and do the following in client:
# ipconfig eth0 down
Ipconfig eth0 up
Take cable out and plug in again.
It should now serve a new IP from the defined pool.

Networking In vmware guest Linux… best practice

At times when you need to assign a fixed static ip for your guest Linux on Vmware,

Open VMware and the guest OS
Point to the bottom right corner and click on Network Adapter (NAT)
Choose settings> and follow as in the pic below:
click on the picture to enlarge it.
vmware networking

Now goto linux command prompt and configure your network to be static.
Restart your linux network.
You should be all set now. There were some instances when you needed to restart your VMware in case it does not work.
For info on setting up a network in linux with a static Ip, look for my other post.

Samba on Centos

To install samba on CentOS
At the command shell enter
#yum -y install samba

Configuring Samba:
# cd /etc/samba
# mv smb.conf smb.conf.backup
# vi smb.conf
Make the following changes:
workgroup = wrkgrp
netbios name = smbserver
security = SHARE
load printers = No
default service = global
path = /home
available = No
encrypt passwords = yes
writeable = yes
admin users = smbuser
path = /home/share (the path to what you will be sharing)
force user = root
valid users = user1
public = yes
available = yes
:qw (save and exit)
# adduser user1 (add account)
# passwd user1 (set account password)
# smbpasswd -a user1 (create same user account on samba)

/etc/init.d/smb restart

Now let us setup drive letter on our Windows so we can easily access these files.
Start -> run (windowkey + r)
you can then enter \\ip_of_server at the run prompt > and click run
then login with the username – user1 and the password you specified earlier.

Send email from command line using gmail and ssmtp

This is a very good tool i use to email me of any notifications on my centos box. Plus i use it to send emails when i am working on command line.

If you havent already installed the EPEL i386 Repo, then do
# rpm -Uvh

# yum remove sendmail (optional)
# yum install ssmtp

Now, configure the ssmtp.conf file:
# vi /etc/ssmtp/ssmtp.conf
AuthPass=(your – password)

# service sendmail stop ( if not removed above)
# chkconfig sendmail off (if not removed above)
# mkdir /root/.backup
# mv /usr/sbin/sendmail /root/.backup/
# whereis ssmtp
ssmtp: /usr/sbin/ssmtp /etc/ssmtp /usr/share/man/man8/ssmtp.8.gz
# ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
# echo “This is a test email” | mail -s “Test”
This will send an email to …..
You can use this on a script,cron and any log messages now to make the centos box email you the issues…. comment on any help needed.