Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, 27 August 2014

How to clear eximstats db

If the your size of eximstats database is getting large, you can do the following steps to clear it.

Login to mysql

#mysql
mysql> use eximstats
mysql> delete from sends;
mysql> delete from smtp;
mysql> delete from failures;
mysql> delete from defers;

You can also use the following steps.
mysqladmin drop eximstats

mysqladmin create eximstats

mysql eximstats < /usr/local/cpanel/etc/eximstats_db.sql

Monday, 28 July 2014

Update Nagios Plugins- ERROR "NRPE: Unable to read output"

Update the nagios plugins if you're getting the ERROR "NRPE: Unable to read output"

Do the below steps by login to the server by root.
# cd /usr/local/src/
# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
# tar -zxvf nagios-plugins-2.0.3.tar.gz
# cd nagios-plugins-2.0.3
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
# chown nagios:nagios /usr/local/nagios
# chown -R nagios:nagios /usr/local/nagios/libexec
# service xinetd restart
Use the below command to check the result from your nagios server.

# /usr/local/nagios/libexec/check_nrpe -H <server_IP> -c check_serviceName

Thats all.

Tuesday, 8 July 2014

Install cPanel on a Virtual Server Running Centos 6

cPanel
cPanel is a convenient application that allows users to administer servers through a GUI interface instead of the traditional command line. Although the installation for cPanel is relatively simple, the script does take several hours to run.


Note:
Once cPanel is installed, it cannot be removed from the server without a complete server restore. cPanel does not offer an uninstaller and cPanel is subject to a licensing fee

Setup

Before installing cPanel on our droplet, we need to take two additional steps.
  • First we need to make sure that Perl is installed on the server
# yum install perl
After installing perl we need to take one more preliminary step. cPanel is very picky about making sure that server that it is installed on has a Fully Qualified Domain Name. To that effect, we need to provide it with a valid hostname.
#hostname  host.example.com
Install cPanel

The cPanel installation only has several steps and the installation will take a long time. Although using program "screen" is not necessary in order to install cPanel, it can be a very helpful addition to the installation process. It can be especially useful if you know that you may have issues with intermittent internet or that you will need to pause the lengthy install process.

To start off, go ahead and install screen:

# yum install screen
Once screen is installed, start a new session running:

#screen -S cPanel
After opening screen, you can proceed to install cPanel with WHM or a DNS only version of cPanel.
 # cd /usr/local/src
  •  Use this this command to install cPanel with WHM:
#wget -N http://httpupdate.cPanel.net/latest
  • Use this command to install the DNS only version of cPanel:
#wget -N http://httpupdate.cPanel.net/latest-dnsonly
With the requested package downloaded, we can go ahead and start the script running:
#sh latest
Detach screen type by "Ctrl+a+d" combination key. The script, which may take one to two hours to complete will continue running while in the background,even if you close out the of server.

To reattach to your screen you can use the command:
#screen -r <Screen_ID
Once cPanel has finally installed, you can access the login by going to your https://ip_address:2087 or domain (https://example.com:2087)

From there, you can create your cpanel user and finally login in at ipaddress/cpanel or domain/cpanel.

Thats it. :-)


Tuesday, 1 July 2014

[FIX] A DNS entry for “Domain.com” already exists. You must remove this DNS entry from all servers in the DNS cluster to proceed.

If you getting the following ERROR while try to create a parked domain in your cPanel account.

"A DNS entry for “Domain.com” already exists. You must remove this DNS entry from all servers in the DNS cluster to proceed"
 Solution:

 Login to server through ssh and execute the following command.

# /scripts/killdns domain.com

After that try again to add. Hope you can add the domain as parked successfully :-)

You can check it through.

# grep -R domain.com /var/cpanel/userdata/*

You can see the list of subdomains and addon/parked domains from this file of the user.

# cat /var/cpanel/userdata/user_name/main

 Thats it.

Wednesday, 25 June 2014

[FIX] 403 forbidden error - pcfg_openfile: unable to check htaccess file, ensure it is readable

If you're getting the "403  forbidden error" while accessing your website.  This issue is generally due to permissions.

Step 1:

  • Check error log,

# tailf /usr/local/apache/logs/error_log | grep <Your IP/website name>
 You'll get below error,

 [Wed Jun 25 15:39:08 2014] [crit] [client XX.XX.XX.XX] (13)Permission denied: /home/user_name/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable


Step 2:

  • Most often, setting folder permissions back to 755 should resolve this issue.
The default permissions for folders should be 755. When reviewing your account,I recommend setting these folders back to 755 and then testing again. If you have sub folders within those that are not 755, you'll want to adjust those as well.
  •  # chmod 755 /home/user_name
That's it.



Friday, 13 June 2014

cPanel logs for access, Apache, email, error, ftp, mysql, and WHM

cPanel logs
  • Access logs and user actions    /usr/local/cpanel/logs/access_log
  • Account transfers and misc. logs    /var/cpanel/logs
  • Auditing log (account creations, deletions, etc)    /var/cpanel/accounting.log
  • Backup logs    /usr/local/cpanel/logs/cpbackup
  • Brute force protection (cphulkd) log    /usr/local/cpanel/logs/cphulkd.log
  • Cpanel dnsadmin dns clustering daemon    /usr/local/cpanel/logs/dnsadmin_log
  • Cpanel taskqueue processing daemon    /usr/local/cpanel/logs/queueprocd.log
  • DBmapping    /usr/local/cpanel/logs/setupdbmap_log
  • EasyApache build logs    /usr/local/cpanel/logs/easy/apache/
  • Error log    /usr/local/cpanel/logs/error_log
  • Installation log    /var/log/cpanel
  • License updates and errors    /usr/local/cpanel/logs/license_log
  • Locale database modifications    /usr/local/cpanel/logs/build_locale_database_log
  • Login errors (CPSRVD)    /usr/local/cpanel/logs/login_log
  • Horde    /var/cpanel/horde/log/
  • RoundCube    /var/cpanel/roundcube/log/
  • SquirrelMail    /var/cpanel/squirrelmail/
  • Panic log    /usr/local/cpanel/logs/panic_log
  • Per account bandwidth history (Cached)    /var/cpanel/bandwidth.cache/{USERNAME}
  • Per account bandwidth history (Human Readable)    /var/cpanel/bandwidth/{USERNAME}
  • Service status logs    /var/log/chkservd.log
  • Tailwatch driver tailwatchd log    /usr/local/cpanel/logs/tailwatch_log
  • Update analysis reporting    /usr/local/cpanel/logs/updated_analysis/{TIMESTAMP}.log
  • Update (UPCP) log    /var/cpanel/updatelogs/updated.{TIMESTAMP}.log
  • WebDisk (CPDAVD)    /usr/local/cpanel/logs/cpdavd_error_log
  • Website statistics log    /usr/local/cpanel/logs/stats_log
cPanel access log
  • Access logs and user actions    /usr/local/cpanel/logs/access_log
cPanel apache log
  • Apache restarts done through cPanel and WHM    /usr/local/cpanel/logs/safeapcherestart_log
  • Domain access logs    /usr/local/apache/domlogs/{DOMAIN}
  • Processing of log splitting    /usr/local/cpanel/logs/splitlogs_log
  • suPHP audit log    /usr/local/apache/logs/suphp_log
  • Web server and CGI application error log    /usr/local/apache/logs/error_log

cPanel email log
  • Delivery and receipt log    /var/log/exim_mainlog
  • Incoming mail queue    /var/spool/exim/input/
  • Log of messages rejected based on ACLS or other policies    /var/log/exim_rejectlog
  • Unexpected/Fatal error log    /var/log/exim_paniclog
  • IMAP, POP login attempts, transactions, fatal errors and spam scoring    /var/log/maillog    /var/log/messages
  • Mailman    /usr/local/cpanel/3rdparty/mailmain/logs

MySQL log
  • MySQL error log    /var/lib/mysql/{SERVER_NAME}.err
  • MySQL slow query log (if enabled in my.cnf)    /var/log/slowqueries

[FIX] Reset Bandwidth Limit Exceeded user/domain

If domain is giving the error of “Bandwidth Limit Exceeded” you can Reset/Increase it from WHM or terminal as well.

From WHM :

To bring the website back online and reset the bandwidth exceeded, use the option.
  • WHM >> Account Functions >> Reset  Account Bandwidth Limit
This will reset the bandwidth usage to zero for the account. To increase the bandwidth limit for the account, use the option
  • WHM >> Account Information >> “View Bandwidth Usage”
From Terminal :
  • # vi /var/cpanel/users/USERNAME
change BWLIMIT (Increase the value)
  • # /scripts/updateuserdomains
  • # cd /var/cpanel/bandwidth.cache/
  • # vi domainname.com
Delete the numbers in that file and retype 0 instead of the number 
Save and quit and show bandwidth usage in WHM you will find its 0.

If the above steps doesn’t work well, use the below steps.
  • # cd /var/cpanel/bwlimited/
remove the files related to that user or domain
(or)
rename the fies with suffix _bk/.bak etc.
Example:
user_bk
domainname.com_bk
www.domainname.com_bk

 This will bring the website back online. :-)

Thursday, 12 June 2014

View Pidgin Chat Logs On Your Linux Terminal

If you want to look on your pidgin chat history/conversations in linux, you can easily find the logs in the below location.

# cd ~/.purple/logs/
 Pidgin’s chat logs (chat histories) are saved in HTML files. In the above path, you find more directories to what you actually need.

For example: A Jabber account with username stebu.johny@domain.com‘s log will be found in this path.

You can find various users that the user have chatted with.

Example:

darelegacy stebu.johny@domain.com # pwd
/home/darelegacy/.purple/logs/jabber/stebu.johny@domain.com
darelegacy stebu.johny@domain.com # ll
drwx------  2 darelegacy darelegacy  4096 Mar 18 05:03 abhijith.pm@domain.com
drwx------  2 darelegacy darelegacy  4096 Jun  6 13:55 abhilash@domain.com
drwx------  2 darelegacy darelegacy  4096 Apr 10 08:40 abin@domain.com
drwx------  2 darelegacy darelegacy  4096 Jun  3 13:07 ajay.joseph@domain.com
Go to the directories that you want to check the logs.

Example: 

 # cd abhijith.pm@domain.com

You'll get the log files for that user.

Example:
 -rw-r--r--  1 darelegacy darelegacy   912 Mar  5 07:21 2014-03-05.005451+0530IST.html
-rw-r--r--  1 darelegacy darelegacy  3404 Mar  7 06:47 2014-03-07.033705+0530IST.html
-rw-r--r--  1 darelegacy darelegacy 23804 Mar 18 05:14 2014-03-18.050323+0530IST.html
Open the .html log using the command below.
  # elinks -dump -dump-color-mode 1 <file>.html

Thats it. :-)




Saturday, 7 June 2014

Extract Images From Videos Using ffmpeg

If you want to extract images from a video file. You can use ffmpeg to get images from a video.

ffmpeg
ffmpeg is a very useful command line program which can be used to transcode media files. It is part of the FFmpeg leading multimedia framework that has many functionalities such as the ability to  decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.

There are many various tools included in the framework each of which has a specific role. For example the ffserver is used to stream multimedia for live broadcasts, ffprobe is used to analyze multimedia stream, ffplay can be used as a simple media player and ffmpeg has the ability to convert multimedia files between formats.
Steps:
 You need to install the ffmpeg command line utility in your linux machine for extracting images from the video file.

Ubuntu users can easily install the ffmpeg utility by typing and running the following command in their terminal.
  • sudo apt-get install ffmpeg
Fedora/Centos users can install ffmpeg directly from the repos.
  • yum install ffmpeg
After that,
  • cd /usr/local/src/wget http://www.ffmpeg.org/releases/ffmpeg-2.2.3.tar.bz2
  •  ./configure
  • tar -xvjf ffmpeg-2.2.3.tar.bz2
  •  cd ffmpeg-*
  • ./configure
Note: If the following error occurs,
yasm/nasm not found or too old. Use --disable-yasm for a crippled build.
 Execute the command below.
  • ./configure --disable-yasm
continue by compiling,
  •   make
Once the compile is finished run the following command to install ffmpeg.
  • su -c 'make install'
Note: Everything has been finished now, you have to type a few commands in your terminal and you will be able to extract images from any type of video file.

Before going any further make sure you are in the same directory with the video file from which you want to extract images from. Use the cd command to navigate to the right directory. Since the video I am using for the purpose of this tutorial is in my Desktop i use the following command to navigate to my desktop.

  • cd <file_location>

Then I use the following command to extract images from my video file.
  •  ffmpeg -i "Exapmle_video.mp4" -r 1 -q:v 2 -f image2 image-3%d.jpeg
The -i option serves to get the input which in my case is the video file named "Exapmle_video.mp4", the -r option sets the number of frames to be extracted as images every second. I like to extract one frame every second.

Then a very important option that should be mentioned and I like to use is the -q:v which is used to set the image quality of the images being extracted. I  always get high quality images when extracting them from a video by using the value of 2.

FFmpeg Basic Commands

Here is the list of few ffmepg basic commands list.

  • ffmpeg -version        :         show version
  • ffmpeg -formats       :         show available formats
  • ffmpeg -codecs         :        show available codecs
  • ffmpeg -decoders     :        show available decoders
  • ffmpeg -encoders     :        show available encoders
  • ffmpeg -bsfs             :        show available bit stream filters
  • ffmpeg -protocols    :        show available protocols
  • ffmpeg -filters          :        show available filters
  • ffmpeg -pix_fmts      :        show available pixel formats
  • ffmpeg -layouts        :        show standard channel layouts
  • ffmpeg -sample_fmts:        show available audio sample formats

Try it :-)

Wednesday, 4 June 2014

The uninstallation and installation procedures for Nginx and Apache webserver.


Step 1: Login to the server as root, Please refer the following commands

Installation of Nginx

  • cd /usr/local/src
  • wget http://nginxcp.com/latest/nginxadmin.tar(download stable release)
  • tar xf nginxadmin.tar
  • cd publicnginx
  • ./nginxinstaller install

Note: You may need to run the pythonfix script if you are installing it in first time.

As It's a major release so if you have previously installed the any version of the nginx, please uninstall and then perform the installation.

Uninstallation of Nginx

  • cd /usr/local/src
  • wget http://nginxcp.com/latest/nginxadmin.tar (download stable release)
  • tar xf nginxadmin.tar
  • cd publicnginx
  • ./nginxinstaller uninstall

Installation Apache server.


Please refer the following commands.

Step 1      : Download the latest stable release.

Step 2      : Extract the Apache Files.

Example  : gunzip -d httpd-2_0_NN. tar. gz
                  tar xvf httpd-2_0_NN.tar

Step 3      : Configuring Your Server for Apache.
                   ./configure

Step 4     : Build Apache.
                    make
                    make install

Step 5     : Customize Apache. (Configuration file edit ie, httpd.conf).

Step 6     : Restart httpd service.
                  service httpd restart

Inorder to unistall Apache.

We can use "yum" command by executing the command.

  • yum erase httpd --nodeps

Note: There is no need to remove httpd from the server, you may stop the httpd service permanently by executing the commands below.

  • service httpd stop
  • chkcfg httpd off

Please note that the packages for the server may differ according server configuration and it is strongly recommended to make sure all before proceeding.

Sunday, 1 June 2014

FIXED [Temporary Blocks: IP:X.X.XX.XXX Port: Dir:in TTL:3600 (lfd - *Port Scan* detected from X.X.XX.XXX ]

If you have getting following the error while checking IP block for the specific IP.

# csf -g <IP>
Temporary Blocks: IP:X.X.XX.XXX Port: Dir:in TTL:3600 (lfd - *Port Scan* detected from X.X.XX.XXX (KE/Kenya/X.X.XX.XXX.domain.com). 6 hits in the last 255 seconds)

Use the below command to remove temporary IP block from the CSF firewall.

Exapmle:

# csf -tr <IP>
DROP  all opt -- in !lo out *  X.X.XX.XXX  -> 0.0.0.0/0 
csf: X.X.XX.XXX temporary block removed
csf: There are no temporary IP allows





Friday, 21 February 2014

[FIXED]Exim Line Mismatch Error

While we try to delete mail from the Queue it showing "Line Mismatch Error" as below
root@mailserver [~]# exiqgrep  -f  "<>" -i| xargs exim -Mrm
Line mismatch: 5h 1Qmr1H-0005ql-So

If we try to delete that mail Id as below,Defenetely it will delete but may another mail id will occupies that place again.

Example:
  root@mailserver [~]# exim -Mrm 1Qmr1H-0005ql-So
  Spool data file for 1Qmr1H-0005ql-So does not exist
  Continuing, to ensure all files removed
  Message 1Qmr1H-0005ql-So has been removed or did not exist

This is very annoying for that we could delete mails from "<>" (mailnull) through the mails by,
root@mailserver [~]# exim -bpru | grep '<>' | awk '{print $3}'|xargs exim -Mrm
We could add deleting mail by tim,
root@mailserver [~]# exim -bpru | grep '10h' | awk '{print $3}'|xargs exim -Mrm
Do add concerned parameter to delete mails from the Queue.

Example:
root@mailserver [~]# exim -bpru | grep 'user@domain' | awk '{print $3}'|xargs exim -Mrm

:-)

Friday, 7 February 2014

DNS: Command to delete a line containg specific from all *.db files in server


If you want to delete line containing the string "ns1.<domain_name>.com" from all *.db extention in the server.

Change directory by,
# cd  /var/named/
Run the command below,
# sed -i '/ns1.<domain_name>.com./d' *.db
Note: The above commamd will delete the line specified by the string "ns1.<domain_name>.com "  from all *.db files in the server .

[FIXED]mytop Error in option spec: “long|!”

Sometimes after installing "mytop" , it may show the following error,
Error in option spec: "long|!"

To fix this error , edit " /usr/local/bin/mytop " , by

# vim /usr/local/bin/mytop

Find the line  "long|!" and comment that line by adding '#' to that line.

Example :


#  "long|!"              =&gt; \$config{long_nums},

That's it, Now run mytop. :-)

Thursday, 6 February 2014

[FIXED]ERROR: Message not sent. Server replied: Connection timed out 110 Can’t open SMTP stream.


" Message not sent. Server replied: Connection timed out 110 Can’t open SMTP stream."

If you have got the above ERROR while trying to send mails from your account,


Login to the server as root and Edit the csf.conf,

# vi /etc/csf/csf.conf

 Search for the line " SMTP_BLOCK = "1" " and change it into " SMTP_BLOCK = "0" .

That's it. Now try to send mails.


Wednesday, 5 February 2014

script for checking Server memory

If you would like to know the advanced memory details of your server, Just do the below steps ..

1)Download the Script by executing the command,

# wget http://www.pixelbeat.org/scripts/ps_mem.py

2) Change the permission by ,

# chmod +x ps_mem.py
3) Show your server memory details by executing the command ,
# ./ps_mem.py

Now you could see the memory usage of all applications. :-)

[FIXED](98)Address already in use: make_sock: could not bind to address 80


If you'd got  the the following error  while starting Httpd service ,do the steps

 " (98)Address already in use: make_sock: could not bind to address 80"



First check and  make sure that the port 80/443 is not being used by any other service or application using the netstat command, by
# netstat -tulpn| grep :80
 If port 80 is bind to httpd, kill all process by ,
# killall -9 httpd
 Now start the httpd service by,
# /etc/init.d/httpd start

That's it. :-)





[FIXED]Name or service not known: mod_unique_id: unable to find IPv4 address of ""


When you came to know about Apache service status is not running and while trying to restart, it failed and the Apache error logs showed following error

"[alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "server.example.com"
Configuration Failed
"

Just check the Apache configuration syntax file by using command,

 # httpd -t
Syntax OK
This is Okay,

Now the issue will be on your " /etc/hosts ' file ,

# vi /etc/hosts
check the file and add your hostname.

after that, restart apache.

That's it. :-)

[FIXED]MySQL ERROR: The server quit without updating PID file

Some cases you will  may face to get this error on MySQL service.

root@ [~]# /etc/init.d/mysql status
ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists

If you've got  above error just remove the " MySQL lock file " and restart the server.
root@ [~]# rm /var/lock/subsys/mysql
rm: remove regular empty file `/var/lock/subsys/mysql’? y


 If you may get the following pid error while restarting the mysqld service,

 —————————
root@ [~]# /etc/init.d/mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL… ERROR! The server quit without updating PID file (/var/lib/mysql/hostname.pid).

 —————————

In this case check the MySQL process and kill it.

———————
root@ [~]# ps aux | grep mysql
root 32616 0.0 0.0 107412 864 pts/3 S+ 11:14 0:00 grep mysql
——————–

Here, there is no more MySQL process, so I need to check the MySQL log.

Sample log:
—————
130728 11:23:45 [ERROR] /usr/sbin/mysqld: unknown variable ‘set-variable=max_user_connections=50′
130728 11:23:45 [ERROR] Aborting

130728 11:23:45 InnoDB: Starting shutdown…
130728 11:23:45 InnoDB: Shutdown completed; log sequence number 2153996
130728 11:23:45 [Note] /usr/sbin/mysqld: Shutdown complete

130728 11:23:45 mysqld_safe mysqld from pid file /var/lib/mysql/hostname.pid ended
—————
If the issue still persist please check the MySQL log may be there is any incorrect entry on my.cnf file.

Edit the my.cnf file and #hash the enrty then start the MySQL.

—————
root@ [~]# /etc/init.d/mysql start
Starting MySQL.. SUCCESS!
root@ [~]#

—————

That's it. :-)

[FIXED] cPanel/WHM EasyApache failed YUM error

Some cases if you try running " /scripts/easyapache " , Yum is showing error

!! " The server’s system package manager, ‘YUM’, failed.  " !!

In order to run easy apache run the commands below, 
# yum clean headers
# yum clean packages
# yum clean metadata
# yum clean dbcache
# yum clean all
If the above commands doesn't work well , Run yum update command, to resolve the error.
 # yum update
If yum update failed it may possible that the RPM database is corruption it can be resolved by running below commands,
# rm -f /var/lib/rpm/__db.*
# rpm -vv –rebuilddb
# yum update
Once yum update is successful try running" /scripts/easyapache " which should work without any error now.

Thats it. :-)

Friday, 31 January 2014

[FIXED]"MySQL is running but PID file could not be found" error


While restarting MySQL service, you may get the error below ,
"MySQL is running but PID file could not be found"
In order to to fix this error , Lets try to do the below steps,

1) Create the directory " var/run/mysql ".
# mkdir /var/run/mysql
2) Now create  file " mysqld.pid " .
# touch mysqld.pid
3) change its ownership of " mysqld.pid " to "mysql:mysql "
# chown mysql:mysql mysqld.pid
4) Restart MySQL service by,
# /etc/init.d/mysql start
That's it, try this and let me know you've get the result. :-)

[FIXED] "(20014)Internal error: Error retrieving pid file logs/httpd.pid Remove it before continuing if it is corrupted." while starting Apache/httpd.


 " (20014)Internal error: Error retrieving pid file logs/httpd.pid
Remove it before continuing if it is corrupted.
"

If you see the above  Error while stopping httpd/Apache , Just do the following steps ,

1) change the directory to  " /usr/local/apache/logs " .
# cd /usr/local/apache/logs

2) remove/rename the file "httpd.pid" ,by

# mv httpd.pid httpd.pid.bak

3) just stop and restart the Httpd , by

# /etc/init.d/httpd start
4) now check the status of  Apache/httpd by,

# /etc/init.d/httpd status

That's it. :-) 

Wednesday, 29 January 2014

[FIXED] How to Change Ubuntu/Lubuntu's Root password using "sudo command"

After installing Ubuntu/LUbuntu ,we could able to login through a user ,we didn't have the root privillage at that time.

If you want to gain the root privilege we have to know the Root password , but we haven't 

Just do the below commands to gain root privilege ,

1) open  terminal/console.

2) type the command ,

$ sudo su

you want to enter your password, type your password.

stebu@DareLegacy:~$ sudo su
[sudo] password for stebu: 


3)Change the root password by,

# passwd

 root@DareLegacy:/home/stebu# passwd 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@DareLegacy:/home/stebu# 

Type your New password.

That's it. Now you can run as root. :-)
  

Executing Script/commands Using "alias command "

The alias command makes it possible to launch any command or group of commands,It allows a user to create simple names or abbreviations (even consisting of just a single character) for commands regardless of how complex the original commands are and then use them in the same way that ordinary commands are used.

Synax :
$ alias [-p] [name="value"]

In order to assign a lengthy command to a single character ,type

# alias <your_desired_string>="<command>"
 
example:
          # alias a="ls -l"

If you want make a alias for a script , type

$ alias <character>="sh <script_name>"
Example:

$ alias 1="sh exim.sh"
Multiple commands can be included in the same alias by inserting them within the same pair of quotation marks and separating them with semicolons(;). For example, the alias sp could be created to first launch hostname and then immediately launch hostname -i :
$ alias sp='hostname;hostname -i'

Now you can run the "Script/command" by typing the alias of it.
That's it. :-)


Change Cpanel default port.

We can  change Cpanel default port by editing the file " /var/cpanel/cpanel.config " .

 # vi  /var/cpanel/cpanel.config
Change  the below value to desired port ,

port=2082
  
This will change the  default Cpanel port, then run the below commands ,

# /usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
# /etc/init.d/httpd restart

That's it :-)

Monday, 27 January 2014

SSH Login Without Password

Login to the Remote server via SSH  without password using ssh-keygen & ssh-copy-id.

"ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host’s public key to the remote-host’s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys. "
1) Generates ssh-key using ssh-keygen

$ ssh-keygen

Hit ENTER

2) Copy the public key to remote-host using ssh-copy-id


$ ssh-copy-id username@ipaddress -pXXXX


Here,

username - Type the username of remote host
ipaddress - Type IP address of remote host.
XXXX     - Type port number if any,(ignore " -pXXX " if the remote sever has no ssh port)

Note : You need to Enter a one-time password.That's it.

Now login to the remote server without password. :-)

Saturday, 25 January 2014

How to Backup Cpanel Reseller's Domains via Command

If you want to backup the domains under a reseller account in the server,It will be difficult to backup 100+ domains under the reseller account .

In order to backup Cpanel Reseller's Domains via script , Just do following two steps.

1) This command will generate the list of users under the reseller 'reseller'.
# cat /etc/trueuserowners | grep reseller | cut -d: -f1 > reseller_list.txt
Note : The file /etc/trueuserowners shows which reseller owns each account.


Now "reseller_list.txt" generated in your " pwd " contains the list of users under the reseller named ' reseller'.

To backup the domains under the reseller to a path /backup, you can execute the command :
# for i in `cat reseller_list.txt` ; do /scripts/pkgacct $i /backup; done

That's it . :-)

Friday, 24 January 2014

Reducing CPU Load in Server

Initial Check up :

To print the cpu load
# cat /proc/loadavg

To see the No: of user logged in server ,
#

To see the uptime and load average
# uptime

To see live process running
# top -c

To print  process current process
# ps aux

To filter user/process/pid from process, type
# ps aux | grep <user/process/pid>

If the cpu load is controllable ,just check the process list and filter the user which taking more resource of the server.

To kill the Process Id(PID) by
# pkill -9 <PID>

To kill the user By
# pkill -9 -u <username>

To kill the service , type
# killall -9 <service>
 Example:  # killall -9 php


To kill a file , type

# fuser -k <file_path>

Example:   # fuser -k  /usr/bin/php


Following command will find top 5 users in server.

# ps faux |grep -i 'p[h]p\|.pl\|perl\|dispatch' | grep -v 'ftp\|imap\|nobody\|mailnull\|root\|mysql\|cpanel\|32004\|32021' |  awk '{print $1}'  | sort | uniq -c | sort -nr | head -n 5

Following command will kill top 2 users in server


# for i in `ps faux |grep -i 'p[h]p\|.pl\|perl\|dispatch' | grep -v 'ftp\|imap\|nobody\|mailnull\|root\|mysql\|cpanel\|32004\|32021' |  awk '{print $1}'  | sort  | uniq -c  | sort -nr |head -n 2|awk '{print$2}'` ; do echo $i; killall -u $i; cat /proc/loadavg ; done


If the sever load is high , execute the commands

To kill the process using for loop ,

# for i in { 1..100 } ; do killall -9 php ; cat /proc/loadavg ; done
 or
 # for i in { 1..100 } ; do fuser -k /usr/bin/php ; cat /proc/loadavg ; done

In some cases ,users/process in the server may be the cause for server load , filter the user and run the command,
# ps aux | grep <user/process_name> | awk {'print $2'} | xargs kill -9 
If the server load is again increasing , stop the service which using  the server resource load , By executing the command ,

# /etc/init.d/<service> stop
Example:  # /etc/init.d/exim stop

The above command is not recommended to execute , Examine the process and block the unwanted   IPs.


Command to find sorted memory usage in server,

 # ps aux | awk '$11!~/\[*\]/ {print $6/1024" Mb --> "$11,$12,$13,$14}' | sort -g

 Troubleshooting wait average [Amount of time the CPU has been waiting for I/O to complete.]

# for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done 

Important - PLEASE do the below command if the load is increasing heavily ,

# ps aux |egrep "clam|php|find|maldet|exim|spam|lfd" | awk '{print $2}' | xargs kill -9

The above command will kill the processes specified in "egrep command" , add or remove the process according to the status of the server .


Please give the name in the '<user>' field of below script  to get process run by the user:


# user=<username> ;for blah in seq; do echo ; uptime;echo; echo "Running Proceses:" ;echo;for pass in 1 2 3 4; do echo "---Pass $pass---"; x=1 ; while [ $x -lt 2 ]; do ps faux | grep "^${user}" ; [ $? -eq 0 ] && echo "The above processes were found to be running for user ${user} when this was executed by  Stebu Johny during each pass at a 2 second interval `date` ..." || echo "No processes were found to be running for user ${user} when this was executed by  Stebu Johny during each pass at `date` ..."; sleep ".2"; let x++ ;done;echo;sleep 2;done; echo "MySQL Processes:";mysqladmin proc --verb | grep "${user}_" | perl -p -e 's/\s+\|/\|/g' | grep "" ; [ $? -eq 0 ] && echo "The above queries were found to be running for user ${user} when this was executed by  Stebu Johny at `date` ..." || echo "No queries were running for user ${user} when this was executed by  Stebu Johny at `date` ..."; echo $'\n'; echo "Incoming Connections:"; lynx --dump --width=10000 localhost/whm-server-status | grep "GET\|POST" | awk '{print $11,$12,$14}' | column -t | sort | grep "/~$/|Client\|$(grep ": ${user}$" /etc/userdomains | cut -d : -f1 | cut -c 1-31)"; echo; echo; done











Thursday, 23 January 2014

Create MySQL database via SSH


We can create MySQL databases  through two ways :

phpmyadmin 
or 
 through the SSH command line
how to create a MySQL database with SSH command

1) First log in to mysql with your user name (change if not root). You will be prompted for a password.
mysql  -p
2)  create the database with a unique name
CREATE DATABASE <new_database>;

3) If you want to give the other_user all the privileges, type the command:
GRANT ALL PRIVILEGES ON <new_database.>* to other_user@localhost;
4)Then, type:

flush privileges;

5) Now the other user can log in and access the database with the command

mysql -u other_user -p'passwd' new_database

Wednesday, 22 January 2014

How to change Cpanel password of all Users In the Server Via SSH

Scripts to change Cpanel password of all Users In the Server,

1)  Login to the server as root

2)  Run the following Command ,
# for i in `cat /etc/trueuserdomains | awk '{print $2}'`  ; do j=$(openssl rand -base64 10);  /scripts/chpass $i $j; echo "$i : $j" >> /root/accountdetails; done

3) That's it .. :-)

Note: This command will change all user's cpanel password instantly ,please be beware before using it.

thanks to sanju jagan for this Script. :-)

Tuesday, 21 January 2014

How to change cPanel password via SSH

If you do not have access to WHM then the cPanel password for a particular account can be updated from shell.
The following steps should help you to change / reset /update cPanel password of particular account from shell    

1) Access the server as a root user through SSH

2) Execute following command
 # /scripts/chpass <username> <password>

Thats it. :-) 

Backup and Restore a Domain account via SSH

How to Backup an account via SSH

In some situations, the account can also be backed up via SSH.
Every CPanel server comes with scripts that can be executed via SSH.


For this case we will use the script pkgacct from the /scripts folder on your server.
1. Log into your server by using SSH
2. Execute the CPanel script for the account backup:
# /scripts/pkgacct <username>
(replace the username with the actual account username that you are going to backup)
The screen output will look similar to this:
Copying domain Config…DoneCopying Mail files….DoneCopying proftpd file….DoneCopying www logs…DoneGrabbing mysql dbs…DoneGrabbing mysql privs…DoneCopying mailman lists….DoneCopying mailman archives….DoneCopying homedir….Done
3. The backup file will be placed in the users home directory.
You can now access the file and copy or move it to your backup drive or download it via ftp.

How to restore a Domain Account via SSH

1. Upload or copy the backup file (Example File Name: cpmove-joeuser.tar.gz) to the domain account             Home directory via FTP.
2. Log into your server by using SSH
3. Execute the appropriate CPanel script for the account restoration:
# /scripts/restorepkg <username>
(replace username with the domain account username)
(make sure that the file name matches the necessary naming convention – follow the naming scheme seen in our example)
This will restore the domain account from the backup, as well as it will create the CPanel account.. Please test accordingly..

Basic Linux Server Administration Commands


1. Uptime Command

In Linux uptime command shows since how long your system is running and the number of users are currently logged in and also displays load average for 1,5 and 15 minutes intervals.
# uptime
2. W Command

It will displays users currently logged in and their process along-with shows load averages. also shows the login name, tty name, remote host, login time, idle time, JCPU, PCPU, command and processes.
# w
Available options:
-h : displays no header entries.
-s : without JCPU and PCPU.
-f : Removes from field.
-V : (upper letter) – Shows versions.

3. Users Command

Users command displays currently logged in users. This command don’t have other parameters other than help and version.
# users
4. Who Command

who command simply return user name, date, time and host information. who command is similar to w command. Unlike w command who doesn’t print what users are doing. Lets illustrate and see the different between who and w commands.
# who
Who command Options:

-b : Displays last system reboot date and time.
-r : Shows current runlet.
-a, –all : Displays all information in cumulatively.

5. Whoami Command

whoami command print the name of current user. You can also use “who am i” command to display the current user. If you are logged in as a root using sudo command “whoami” command return root as current user. Use “who am i” command if you want to know the exact user logged in.
# whoami
6. ls Command

ls command display list of files in human readable format.
# ls -l
Sort file as per last modified time.
# ls -ltr
7. Crontab Command

List schedule jobs for current user with crontab command and -l option.
# crontab -l
Edit your crontab with -e option. In the below example will open schedule jobs in VI editor. Make a necessary changes and quit pressing :wq keys which saves the setting automatically.
# crontab -e
8. Less Command
less command allows quickly view file. You can page up and down. Press ‘q‘ to quit from less window.
# less install.log
9. More Command

more command allows quickly view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.
# more install.log
10. CP Command

Copy file from source to destination preserving same mode.
# cp -p fileA fileB
You will be prompted before overwrite to file.
# cp -i fileA fileB
11. MV Command

Rename fileA to fileB. -i options prompt before overwrite. Ask for confirmation if exist already.
# mv -i fileA fileB
12. Cat Command

cat command used to view multiple file at the same time.
# cat fileA fileB
You combine more and less command with cat command to view file contain if that doesn’t fit in single screen / page.
# cat install.log | less
# cat install.log | more
13. Cd command (change directory)

with cd command (change directory) it will goes to fileA directory.
# cd /fileA
14. pwd command (print working directory)

pwd command return with present working directory.
# pwd
15. Sort command

Sorting lines of text files in ascending order. with -r options will sort in descending order.
#sort fileA.txt
#sort -r fileA.txt
16. VI Command

Vi is a most popular text editor available most of the UNIX-like OS. Below examples open file in read only with -R option. Press ‘:q‘ to quit from vi window.
# vi -R /etc/shadows
17. SSH Command (Secure Shell)

SSH command is used to login into remote host. For example the below ssh command will connect to remote host (192.168.50.2) using user as narad.
# ssh <user_name>@192.168.50.2
To check the version of ssh use option -V (uppercase) shows version of ssh.
# ssh -V
18. Ftp or sftp Command

ftp or sftp command is used to connect to remote ftp host. ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example the below commands will connect to ftp host (192.168.50.2).
# ftp 192.168.50.2
# sftp 192.168.50.2
Putting multiple files in remote host with mput similarly we can do mget to download multiple files from remote host.
# ftp > mput *.txt
# ftp > mget *.txt
19. Service Command

Service command call script located at /etc/init.d/ directory and execute the script. There are two ways to start the any service. For example we start the service called httpd with service command.
# service httpd start
OR
# /etc/init.d/httpd start
20. Free command
Free command shows free, total and swap memory information in bytes.
# free
Free with -t options shows total memory used and available to use in bytes.
# free -t
     
21. Top Command

top command displays processor activity of your system and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used. Use top command with ‘u‘ option this will display specific User process details as shown below. Press ‘O‘ (uppercase letter) to sort as per desired by you. Press ‘q‘ to quit from top screen.
# top -u <username>
22. Tar Command
tar command is used to compress files and folders in Linux. For example the below command will create a archive for /home directory with file name as archive-name.tar.
# tar -cvf archive-name.tar /home
To extract tar archive file use the option as follows.
# tar -xvf archive-name.tar

23. Grep Command

grep search for a given string in a file. Only tecmint user displays from /etc/passwd file. we can use -i option for ignoring case sensitive.
# grep <string_to_search> /etc/passwd
24. Find Command

Find command used to search files, strings and directories. The below example of find command search tecmint word in ‘/‘ partition and return the output.
# find / -name <string>
25. lsof Command

lsof mean List of all open files. Below lsof command list of all opened files by user tecmint.
# lsof -u tecmint
26. last command

With last command we can watch user’s activity in the system. This command can execute normal user also. It will display complete user’s info like terminal, time, date, system reboot or boot and kernel version. Useful command to troubleshoot.
# last
You can use last with username to know for specific user’s activity as shown below.
# last <username>
27. ps command
ps command displays about processes running in the system. Below example show init process only.
# ps -ef | grep init
28. kill command

Use kill command to terminate process. First find process id with ps command as shown below and kill process with kill -9 command.
# ps -ef | grep init
root         1     0  0 07:53 ?        00:00:04 /sbin/init
root      7508  6825  0 11:48 pts/1    00:00:00 grep init

# kill- 9 7508
29. rm command

rm command used to remove or delete a file without prompting for confirmation.
# rm filename
Using -i option to get confirmation before removing it. Using options ‘-r‘ and ‘-f‘ will remove the file forcefully without confirmation.
# rm -i test.txt
30. mkdir command

mkdir command is used to create directories under Linux.
# mkdir directoryname

Install / Enable PHP MsSQL Extension in cPanel/WHM Server

If there is a requirement for MsSQL extension on cPanel/WHM server, you need to install it manually by following the steps listed below.

You need to install a few modules before installing the MsSQL extension.
1. unixODBC
2. freeTDS
3. mssql.so
Do not use rpms as it will show lots of dependency errors. Better download the source file and compile it.

Install unixODBC package

1. Get the source from here

2. tar -xvf unixODBC-2.2.12.tar.gz

3. Now use the following command to configure.

./configure -prefix=/usr/local -enable-gui=no

Please note that if you use enable-gui option as yes and dont have Qt package, you will get the error. So make sure you use it as no.

4. make

5. make install

Install freeTDS package

1. Download from ftp://ftp.freetds.org/pub/freetds/old/0.82/freetds-0.82.tar.gz (Note that if you are using a latest version of freetds, sometimes you may get an error while trying to run the configure with unixODBC option. So I have to use an older version 0.82.)

2. tar -xvf freetds-0.82.tar.gz

3. ./configure -with-tdsver=8.0 -with-unixODBC=/usr/local

4. make

5. make install

Configure freeTDS

1. Locate the freetds.conf and add the following entries.

[MSHOSTNAME]
host = MSHOSTNAME
port = 1433
tds version = 8.0

Generating mssql.so

In cPanel servers the extensions are located at /home/cpeasyapache/src/php-x.x.x/ext. Navigate to the above directory and then to mssql directory.

cd /home/cpeasyapache/src/php-x.x.x/ext/mssql

phpize
./configure
make
make install

The above commands will generate a copy of mssql.so in the installed extensions directory. Check and make sure that mssql.so is there and add the following to php.ini

extension=”mssql.so”

Restart httpd and check the modules using the following command.

php -m | grep mssql

or

You can create a phpinfo page with the following contents and search for mssql.

<?

phpinfo();

?>

Thats it. :-) 

Friday, 17 January 2014

Exim - Find Spammer

Steps to find the Orgin Of Spam Mails

Find the Total Queue on Exim
#exim -bpc
To get the sorted list of mails from domain
#  exim -bp | exiqsumm -c | head
To get a sorted list of email sender in exim mail queue,below command will show you the number of mails send by each one,
# exim -bpr | grep "<" | awk {'print $4'} | cut -d "<" -f 2 | cut -d ">" -f 1 | sort -n | uniq -c | sort -n
You will get a result as like follows,

1 mridul@testdomain.com

2 prasanth@test1domain.com

3 nithin@test123.com

4 stebu@testdomain.co.in

29 eljo@testdomain.in

124 hacker@test123domain.com

Print the total mails from the e-mail Id,
# exiqgrep -f <e-mail@domain> -i | wc -l
To print the mail Ids from the e-mail Id,
# exiqgrep -f <e-mail@domain> -i
You'll get mail Ids ,from the list Open one or two mails using the command,

# exim -Mvh <e-mail_ID >
# exim -Mvb <e-mail_ID >
# exim -Mvl <e-mail_ID >
 You'll get " auth_id "  from the mail header , If the user is spammer ,we want to stop it by changing  E-mail password of the authenticated user_e-mail id/domain.

spamming will definitely stop now , If it won't work  evaluate the  "exim_main log"
# tail -f /var/log/exim_mainlog | grep login
We can see the current spamming going through Exim ,Evaluate the log and check who is currently spamming , you 'll get a IP adress which is used for spamming , block IP by,
# csf -d <IP_address>  
Suspend the User for the securing the server.


To remove the mails from a specific user,type
# exiqgrep -f <e-mail@domain> -i | xargs exim -Mrm

To remove mailnull(<>) mails from the mail queue , type
exiqgrep -f "<>" -i | xargs exim -Mrm


If the spammer is sending mails using scripts :


Check mail log to know which home directory is used for spamming,

# tail -f /var/log/exim_mainlog|grep home

The following scripts will check the script that will originate spam mails:

# grep "cwd=/home" /var/log/exim_mainlog | awk '{for(i=1;i<=10;i++){print $i}}' | sort | uniq -c | grep cwd | sort -n
# awk '{ if ($0 ~ "cwd" && $0 ~ "home") {print $3} }' /var/log/exim_mainlog | sort | uniq -c | sort -nk 1
# grep 'cwd=/home' /var/log/exim_mainlog | awk '{print $3}' | cut -d / -f 3 | sort -bg | uniq -c | sort -bg
You will get a result as like follows for the first two scripts. The third script is just a sub of the first two scripts.
9 cwd=/home/test1/public_html10 cwd=/home/test2/public_html/a1/www15 cwd=/home/test3/public_html91 cwd=/home/test4/public_html178 cwd=/home/test5/public_html/web770 cwd=/home/test6/public_html/foro803 cwd=/home/test7/public_html/web124348 cwd=/home/test8/public_html/wp/wp-content/themes/twentyeleven
If we need to find out exact spamming script. The following script will shows the current spamming script running now. The following script will help you in all time of mail servers. It will help you to find the exact script which sending mails.
# ps auxwwwe | grep <user> | grep --color=always "<location of script>" | head
The usage of the above script is as shown below.
# ps auxwwwe | grep test8 | grep --color=always "/home/test8/public_html/wp/wp-content/themes/twentyeleven" | head
Once you find the exact script, the following script will help you to find the IP address which is responsible for spamming. You will get a list of IPs from the following script. The IPs address which has high number of access is most probably causing spamming. You can block the IP address in csf or apf firewall.
# grep "<script_name>" /home/user/access-logs/testdomain.com | awk '{print $1}' | sort -n | uniq -c | sort -n
Following command that will show you the script which is using script to send the email. If it is from php then use
# egrep -R "X-PHP-Script"  /var/spool/exim/input/*
It shows top 50 domains using mail server with options.
# eximstats -ne -nr /var/log/exim_mainlog
It shows from which user’s home the mail is going, so that you can easily trace it and block it if needed.it shows the mails going from the server.
# ps -C exim -fH ewww | grep home
It shows the IPs which are connected to server through port number 25. It one particular Ip is using more than 10 connection you can block it in the server firewall.
# netstat -plan | grep :25 | awk {'print $5'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1
In order to find “nobody” spamming, issue the following command
# ps -C exim -fH ewww | awk '{for(i=1;i<=40;i++){print $i}}' | sort | uniq -c | grep PWD | sort -n
 It will give some result like:

Example :
6 PWD=/
347 PWD=/home/sample/public_html/test
Count the PWD and if it is a large value check the files in the directory listed in PWD
(Ignore if it is / or /var/spool/mail /var/spool/exim)

The above command is valid only if the spamming is currently in progress. If the spamming has happened some hours before, use the following command.
# grep "cwd=" /var/log/exim_mainlog | awk '{for(i=1;i<=10;i++){print $i}}' | sort | uniq -c | grep cwd | sort -n

To remove bounced emails from the server

  • # cd /var/spool/exim/input
  • # find . -type f -iname ‘*’ -exec grep -li "Failed" {} \; -exec rm {}\;

To remove all messages from the queue, enter:


# exiqgrep -i | xargs exim -Mrm
or 
# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash
Or

Open a new screen using Screen command

# screen

change directory by ,

# cd /var/spool/exim/input/

remove all directories to clear entire Queue,

# rm -rf *

That's it ,Entire mail queue will clear by this. :-)

Full XEN VPS Migration

This guide has been written to aid you in SAFELY transfering Xen PV & HVM virtual servers between nodes.

Creating a Copy of the Virtual Server

We need to find the correct LV that needs backing up. You do this by issuing lvdisplay in ssh on the source node:

[root@herculis ~]# lvdisplay

--- Logical volume ---
LV Name /dev/vps/vm1010_img
VG Name vps
LV UUID pFtowh-vnxa-DXeE-KqqZ-N1h1-IQ2z-4VFSad
LV Write Access read/write
LV Status available
# open 0
LV Size 10.00 GB
Current LE 160
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:52
 --- Logical volume ---
LV Name /dev/vps/vm1010_swap
VG Name vps
LV UUID iBGJKk-do9U-5tGM-fqZT-fD1U-Ejqa-Dih3VT
LV Write Access read/write
LV Status available
# open 0
LV Size 256.00 MB
Current LE 4
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:53
vm1010 is the vps we need to backup so we now have the LV details we need.

Next we need to find some space on the the server to make the backup to. If you have enough space on the normal / partition you can put the backup there but in most cases you won't ,so you need to create an LV to put the backup into:
# lvcreate -n vm1010_backup --size 15G /dev/vps
We created an new LV called vm1010_backup with a size 5GB bigger than the source LV.

Now format the new LV and mount it:
# mkfs.ext3 /dev/vps/vm1010_backup
# mkdir -p /home/vm1010_backup
# mount /dev/vps/vm1010_backup /home/vm1010_backup
Next we need to shutdown the source vps either using SolusVM or the commandline:
# xm shutdown vm1010
Now its time to create the backup:
# dd if=/dev/vps/vm1010_img of=/home/vm1010_backup/vm1010_backup.img
When complete the backup will be stored in /home/vm1010_backup:
# ls -lh /home/vm1010_backup
-rw-r--r-- 1 root root 10G May 29 00:10 vm1010_backup.img
Transfer to the destination node

On the destination node you need to create a set of LV's for the backup and the new vps:
# lvcreate -n vm1010_backup --size 15G /dev/vps
# lvcreate -n vm1010_img --size 10G /dev/vps
The following is only for xen pv:
# lvcreate -n vm1010_swap --size 256M /dev/vps
# mkswap /dev/vps/vm1010_swap
Mount the LV on the destination node for the backup:
# mkfs.ext3 /dev/vps/vm1010_backup
# mkdir -p /home/vm1010_backup
# mount /dev/vps/vm1010_backup /home/vm1010_backup
Transfer the backup to the destination server:
# scp -C /home/vm1010_backup/vm1010_backup.img root@remote.server.com:/home/vm1010_backup/
Restoring the Virtual Server

Once the transfer is complete we can restore the backup to the new LV:
# dd if=/home/vm1010_backup/vm1010_backup.img of=/dev/vps/vm1010_img
Updating SolusVM and Starting the Virtual Server
When the restore is complete you need to update SolusVM so it knows where the vps has been moved to.
In SSH on your master do the following:
# /scripts/vm-migrate <VSERVERID> <NEWNODEID>
<VSERVERID> is the ID listed in your VM list in SolusVM <NEWNODEID> is the ID of the node listed in your node list in SolusVM

Example moving vserverid 150 to node 4:
# /scripts/vm-migrate 150 4
All you need to do now is boot up the vps on the new node by clicking the reboot button within SolusVM. You must use the reboot button so it writes a new configuration file on the new slave.
# Cleanup
When you have confirmed the vps has been moved and is up and running on the new slave you need to remove any LV's and mount points you made.

On the source node:
# umount /home/vm1010_backup
# lvremove /dev/vps/vm1010_backup
# lvremove /dev/vps/vm1010_img
# lvremove /dev/vps/vm1010_swap
On the destination node:
# umount /home/vm1010_backup
# lvremove /dev/vps/vm1010_backup