Sunday, 6 January 2013

Back Up MySQL Databases From The Command Line

While automated backups are important on Linux server, sometimes you just want to take a quick and dirty snapshot before making a change to your data. When changing files in Linux, you can simply copy a file to another name, and c0py it back if your change does not work out. With MySQL, it is not quite that simple, but it is by no means difficult.

Creating A Backup

The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. These dumps are just files with all the SQL commands needed to recreate the database from scratch.

If you want to back up a single database, you merely create the dump and send the output into a file, like so:

mysqldump database_name > database_name.sql


Multiple databases can be backed up at the same time:

mysqldump --databases database_one database_two > two_databases.sql


It is also simple to back up all of the databases on a server:

mysqldump --all-databases > all_databases.sql


Restoring a Backup

Since the dump files are just SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data into the proper database.

mysql database_name < database_name.sql


If you are trying to restore a single database from dump of all the databases, you have to let mysql know like this:

mysql --one-database database_name < all_databases.sql

Restoring Databases From cPanel Backups

Enable Ioncube cPanel

Overview



The following guide will show you enable Ioncube in cPanel.

Enabling Ioncube




  • Login to WHM (root)

  • Go to Server Configuration -> Tweak Settings -> PHP

  • Select ioncube from the radio-button for cPanel PHP loader.

  • Click on Save button.

  • That's it. This will enable Ioncube for you in 3rd party PHP binary.



EnableIoncube

Thursday, 3 January 2013

How to install Git on CentOS running cPanel

Recently when working on creating a new bash script to calculate inode usage I attempted to install Git on a CentOS 5 cPanel server and got a lot of Perl errors. After running the install command from Yum as you can see in the output below it was complaining about dependencies.

Here's a few of the errors that I received when trying to install

# yum install git-core
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.team-cymru.org
* base: yum.singlehop.com
* epel: mirrors.servercentral.net
* extras: mirror.steadfast.net
* rpmforge: fr2.rpmfind.net
* updates: pubmirrors.reflected.net
Excluding Packages in global exclude list
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.i386 0:1.7.3-1.el4.rf set to be updated
--> Processing Dependency: perl-Git = 1.7.3-1.el4.rf for package: git
--> Processing Dependency: libcrypto.so.4 for package: git
--> Processing Dependency: perl(DBI) for package: git
--> Processing Dependency: libssl.so.4 for package: git
--> Processing Dependency: perl(Git) for package: git
--> Running transaction check
---> Package git.i386 0:1.7.3-1.el4.rf set to be updated
--> Processing Dependency: perl-Git = 1.7.3-1.el4.rf for package: git
--> Processing Dependency: perl(DBI) for package: git
--> Processing Dependency: perl(Git) for package: git
---> Package openssl097a.i386 0:0.9.7a-9.el5_4.2 set to be updated
--> Finished Dependency Resolution
git-1.7.3-1.el4.rf.i386 from rpmforge has depsolving problems
--> Missing Dependency: perl(DBI) is needed by package git-1.7.3-1.el4.rf.i386 (rpmforge)
git-1.7.3-1.el4.rf.i386 from rpmforge has depsolving problems
--> Missing Dependency: perl(Git) is needed by package git-1.7.3-1.el4.rf.i386 (rpmforge)
git-1.7.3-1.el4.rf.i386 from rpmforge has depsolving problems
--> Missing Dependency: perl-Git = 1.7.3-1.el4.rf is needed by package git-1.7.3-1.el4.rf.i386 (rpmforge)
Error: Missing Dependency: perl(DBI) is needed by package git-1.7.3-1.el4.rf.i386 (rpmforge)
Error: Missing Dependency: perl(Git) is needed by package git-1.7.3-1.el4.rf.i386 (rpmforge)
Error: Missing Dependency: perl-Git = 1.7.3-1.el4.rf is needed by package git-1.7.3-1.el4.rf.i386 (rpmforge)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest

After searching around and doing a little bit of research I figured out the problem was related to cPanel itself. cPanel was blocking the installation of any Perl modules to prevent it from conflicting with their packages.

Thankfully though there is a really simple way through Yum to install Git and bypass this block from cPanel.

# yum --disableexcludes=main install git

We add in the --disableexcludes=main and you should be able to install Git without any problems.

If you end up having problems with cPanel afterwards (which I have not experienced), you can run this script from cPanel to check the Perl modules installed.

# /scripts/checkperlmodules

Tuesday, 30 October 2012

Plesk – Get email passwords using the command line

There is a built in command to get the email/passwords in plesk. When you ssh to the server just use the following:

/usr/local/psa/admin/sbin/mail_auth_view

Cisco – VPN troubleshooting commands

show crypto isakmp
show vpn-sessiondb summary
clear crypto isakmp sa

mailenable – tool to analyse the logs for errors

If you are having issues with MailEnable and need an easy way to analyse the logs (notepad doesn’t really cut it).

http://www.mailenable.com/tools/MeLogCheck.exe

This tool sumarizes the amount of errors of a type and then provides a description of the error and when it occured.

Friday, 7 September 2012

Install spf records for all accounts on cPanel server

Command to install spf record on single cPanel account.

# /usr/local/cpanel/bin/spf_installer cPanel_username

Put actual username in place of cPanel_username

Instead of installing spf records on cPanel accounts one by one use the following script to install it in one step:

# cd /var/cpanel/users

# for i in `ls /var/cpanel/users` ;do /usr/local/cpanel/bin/spf_installer $i ;done