4PSA – tbrestore from Total Backup for Plesk- phew

 

I bought the 4PSA Total Backup for Plesk some time ago for my Plesk server. Of course, 1 week before I was due to retire the server, it crashed. I had to reimage, and then came the nail biting task of restoring it.
But I had a few errors, I installed the correct version of Total Backup, but when I ran

/usr/local/tbackup/tbrestore

I got the error

 

Error! Cannot cd to directory

‘Crap!’ I thought to myself. Googling didn’t help, nor did the 4PSA forums. Turns out the fix was that I had to specify a local backup directory through the Plesk control panel, for tbrestore to work.

It’s running now, it’s a slow, nail biting experience …..

We made this hard … just to mock you

 

 

 

I had an external hard drive crash last year, and recently, we had an external hard drive case fail in the office. So, I decided to marry the two remaining components in a fit of screws and twisted metal.

Why twisted metal? Because, as I found out, just swapping out hard drives in external enclosures isn’t as easy as swapping drives out of PCs. No.

Each enclosure had it’s collection of pull-here’s, push-there’s, unscrew this, remove this sticker to reveal the screw, and yank at this bit for a while.
They both finally gave up their drives, but, after putting all the bits and pieces together again, I was left with bits and pieces that had fallen or snapped off.

Why can’t these things be easier?

.htaccess problem on 1and1 (1&1) managed server and joomla/mambo

Ok, this one took me a while to figure out, after stuffing around with all sorts of .htaccess files, and being certain that mod_rewrite was in fact on, I was ready to give up. I was seeing:

Error 500, server config error and all sorts.
I knew I’d gotten some wordpress blogs running with SEF, so I just grabbed it’s .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

 

And, amazingly, it worked.

Let’s hear it for wordpress! ( written on a wordpress blog no less )

Migrating from MySQL 4.1 to MySQL 4.0, fixing the missing AUTO_INCREMENT field error

 

After buying a 1and1 managed server, and signing up for two years, I discovered that even in the days of MySQL 5.0, these managed servers are set to use MySQL 4.0,
This sucks for alot of reasons, the main one being the pain in the arse it is to migrate other MySQL databases back to 4.0

After stuffing around at the command line using options like
mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` -p –skip-opt –create-options –compatible=mysql40 –add-drop-table –default-character-set=latin1 mydb > db.sql

It turns out that a bug in mysql4.1 screws up the creation of auto_increment when exporting with compatible=mysql40

Basically this means that if I export from mysql4.1 to mysql4.0, I have to manually add the AUTO_INCREMENT field type to each of the primary keys in the table. And since I’ve had alot of databases to move, each with up to 100 tables, I didn’t really fancy the idea.

So, after stuffing around I found a work around.

Export as normal from phpmyAdmin,

Do a find and replace on the SQL
Find: DEFAULT CHARSET=latin1
And Replace With:

That is just delete all occurances of: DEFAULT CHARSET=latin1

Then find: timestamp NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
And replace with: timestamp NOT NULL

This seems to do the trick

Worked for a Joomla on 4.1 to 4.0 database conversion
Worked for Zen Cart 1.2.6 to mysql 4.1 to 4.0
Worked for b2Evolution mysql 4.1 to 4.0 database conversion
Worked for Mambo 5 mysql 4.1 to 4.0 database conversion
 

MySQL in and around PLESK really useful commands

I’m always having to look up and figure out all this mysql stuff online. So I’m going to save my favourite commands here. I’ll try to include versions where I can…. Stay tuned.

 

OK, exporting ( dumping from a MySQL database ) in Plesk

mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` –add-drop-table –add-drop-database  –default-character-set=latin1 mydb > db.sql

This bit `cat /etc/psa/.psa.shadow` grabs your PLESK MySQL password.

Add –add-drop-table if you’ll be exporting over an existing database or tables

Add –add-drop-database if you’ll be exporting over an existing database

mydb is the database you want to export from.

db.sql is the file you want to export to.

 

To import the file in to a database, connect to MySQL on your server

Go to the directory that has your db.sql file that you’re going to be importing

mysql -uadmin -p`cat /etc/psa/.psa.shadow` -p

Then enter the password

If you’re importing in to a new database:
The type in USE mydatabasename
Where mydatabasename is the name of the database you’re writing over

now type source db.sql;

remember to put the semi colon in there,
You should see a whole lot of
Query OK, 1 row affected (0.01 sec)
Lines, which is fine. Just wait it out and your import should complete all by itself.

Plesk, really useful commands

Ok, I’ve made a text file of all those tricky commands I use on plesk FC2. Many of them have saved my bacon, or just been really useful

cat /var/log/messages | tail -200
What has the server been up to? This message shows the last 200 lines of the servers log, it’s good to track down all sorts like dns errors and ftp errors.

tail /var/log/messages -f -n 14000 | grep ‘Jun 1′
Show server messages from a certain date ( June 1st )

du -sk*
Disk usage, there’s all sorts of variants, but this one’s me fav
chown -R user:group *
Changes the owner of files recursively

chmod -R 755 *
changes the permissions of files recursively

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e’delete from PMM’
Fixes updater never stopping error

mysqlcheck -o -u admin -p`cat /etc/psa/.psa.shadow` –all-databases
Optimizes all tables

Here’s one for all those people having problems with character sets:
When using MySQL’s UTF-8 character set, besides setting the database character set to UTF-8, you must remember to send SET NAMES ‘utf8′ to MySQL prior to querying or inserting. Forgetting to do will surely cost you a substantial amount of hair, sleep, and sanity.
ps -aux
View all active processes

top
View processes live

/sbin/service httpd restart
restart apache

/sbin/service mysqld restart
restart mysql

tar -zxvf file.tar.gz
extract from a tar.gz file

http://forum.ev1servers.net/showthread.php?t=51695
Great place to see how to upgrade php and mysql

4psa total backup

Great backuping up tool for plesk. Much better than their scractchy one
Running plesk update from the command line
/usr/local/psa/admin/sbin/autoinstaller

Debug Spam Assassin
spamassassin -D -lint

Good Resource for SpamAssassin

http://wiki.apache.org/spamassassin/

Update SpamAssassin on Fedora Core 4
yum install spamassassin

To use a proper anti spam setup
remove psa-spamassassin ( rpm -e psa-spamassassin )
yum install spamassassin
install dcc, pyzor and razor ( http://wiki.apache.org/spamassassin/RazorSiteWide, http://wiki.apache.org/spamassassin/UsingPyzor)
http://www.vmailadmin.org/wiki/index.php?title=HOWTO_SpamAssassin#v310.pre

Restart Spam Assassin
/etc/init.d/spamassassin restart

Get rid of ‘config: not parsing, administrator setting: pyzor_options –homedir /etc/mail/spamassassin//.pyzor’ messages
mv /var/qmail/mailnames///user_prefs /var/qmail/mailnames///user_prefs_old
then restart plesk

If you get ‘/var/dcc/map is not private’ in the logs.
As root run
chmod 0600 /var/dcc/map

If ftp upload session times out or drops out.
Turn off windows firewall on your computer, or turn off the application gateway service.

View mail logs after upgrading to 8.1
tail /usr/local/psa/var/log/maillog -f -n 2000

/usr/local/psa/admin/bin/modules/watchdog/rkhunter –configfile /usr/local/psa/etc/modules/watchdog/rkhunter.conf –update
force update of rkhunter ( rootkit hunter )

Quickly Install Zend 3.0 and then fix php
cd /usr/local/src
wget http://www.eth0.us/files/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
tar -zxf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.0.1-linux-glibc21-i386
./install

Now just hit enter a few times until it is done…
This guy is on the right track, what you need to do is cut out the [Zend] block of text from your php.ini file:

[Zend]
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.0.1
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.0.1
zend_optimizer.version=3.0.1
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

(usr/local/Zend/etc/php.ini as default) and paste it into a file in the /etc/php.d/ directory, you can name the file anything, i called mine zend.ini.

The problem arises because (like this guy said) ionCube will not allow php to run if theres a similar module loaded before it:

PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini file in Unknown on line 0

and since ionCube is an include (in the php.d directory), and the zend code is pasted directly in the php.ini file, the zend code gets executed first. So as long as you move the zend code after the ionCube code, everything should work just fine… just remember, file includes with regards to php and apache are alphabetical, so if you name your file aaazend.ini it will still error out because it comes before ionCube-loader.ini (or whatever your ionCube file is called).

See what’s in the qmail queue:

/var/qmail/bin/qmail-qstat

Zip all files excluding some, use the -x option
zip -r httpdocs_after_lots_of_changes.zip httpdocs/ -x \*.zip
 

Useful commands on plesk

Ok, I’ve made a text file of all those tricky commands I use on plesk FC2. Many of them have saved my bacon, or just been really useful

Get ftp Resume to work
http://forum.swsoft.com/showthread.php?s=3801b6aad2b9f7efded662d50eb0afa2&threadid=25415&highlight=ftp+resume
Login via SSH as root

then open the file /etc/proftpd.include

(to open it just type:

code:
nano -w /etc/proftpd.include


or

code:
vi -w /etc/proftpd.include

)

that should be an empty file…

at this point you have to place inside it this line:

code:
AllowStoreRestart on

then save and exit (ctrl + x if you use nano)

then type at SSH prompt:

code:
/etc/rc.d/init.d/xinetd restart

your FTP service will be restarted and you can resume interrupted downloads (the ftp server now will accept the APPEND command)

some other usefull tweaks to put inside your /etc/proftpd.include are also:

faster login:

code:
UseReverseDNS off IdentLookups off


(in theory that 2 ones had beed added in 7.5.3…)

and this one that force your ftp to show all the files included .htaccess and so on

code:
ListOptions "-a"


view server messages:
cat /var/log/messages | tail -200

disk usage
du -sk*

Plesk Passive FTP ‘connection timeout’ error fix
I’ve had some problems with my plesk on godaddy servers using ftp. The connection often times out. Connecting from home, I found that turning off the ‘application gateway service’ on my computer ( windows ) worked.

But this site http://andryan.wordpress.com/2006/01/23/passive-ftp-workaround-for-plesks-proftpd/ suggests defining the passive ports and opening them on the firewall as follows:

“…

Add the following line:
PassivePorts 49152 65534
to /etc/proftpd.conf
NOT /etc/proftpd.include as that file will be overwritten by Plesk regularly.

No need to restart xinetd (/etc/init.d/xinetd restart) as proftpd is executed only when a connection has been attempted on the port.

Add the following line:
/sbin/iptables -A INPUT -p tcp –dport 49152:65534 -j ACCEPT
to /usr/local/psa/var/modules/firewall/firewall-active.sh

That’s all!
Just need to make sure that the last incoming traffic rule is set to deny all.

Valid for Plesk 7.5. …”

I tried it and it looks like it’s working, more updates soon …

Change Ownership
chown user:group * -R
eg chown apache:apache * -r
( only apache can change the files)
Fix plesk updater problems
mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e’delete from PMM’

Optimize all mysql tables
mysqlcheck -o -u admin -p`cat /etc/psa/.psa.shadow` –all-databases

To move mysql databases around
Export/Import
First dump the whole database to file
In phpmyadmin: –

1. export
2. select all tables
3. compression .gz
4. compatability none
5. Download the file
6. Open file.sql in editor
7. remove all
ENGINE=MyISAM DEFAULT CHARSET=latin1
8. Resave
9. .gzip up
10 Upload to server
11. log in to server ssh
12. go to dir with the .gzip
13. ungzip file.gz

14. type mysql db -p -u user
then enter the password

15 type: source file.sql

UTF-8 and MySQL
SET NAMES ‘utf8’

When using MySQL’s UTF-8 character set, besides setting the database character set to UTF-8, you must remember to send SET NAMES ‘utf8’ to MySQL prior to querying or inserting. Forgetting to do will surely cost you a substantial amount of hair, sleep, and sanity.

View Processes
ps -aux

View live processes
top

Zip Files
zip -r back_2006_04_05 *

Restart apache ( httpd )
/sbin/service httpd restart

Restart mysql
/sbin/service mysqld restart

Install Zend Optimizer
tar -zxvf Zend*
cd Zend*
./install.sh

untar file.tar.gz
tar -zxvf file.tar.gz

upgrading php and mysql
http://forum.ev1servers.net/showthread.php?t=51695

Disable SpamAssassin

http://forum.swsoft.com/showthread.php?s=7dd484ae4a36e0d393e801651615342e&threadid=15092&highlight=disable+spamassassin

Here are steps how spamassasign can be disabled:
1. chkconfig –level 0123456 spamassassin off
2. Open the file /etc/init.d/psa in your editor.
Find this string:
optional_service=”postgresql spamassassin ${PRODNAME}-spamassassin”
change it with
optional_service=”postgresql”

Improve SMTP speed
http://forums.spry.com/showthread.php?t=411

Edit
/etc/xinetd.d/smtp_psa
What you are going to do is, add “-Rt0” to “server_args”. It will then look like this:
server_args = -Rt0 /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true

Save the file, and restart xinetd by issuing this command:

/etc/init.d/xinetd restart

Clear mail queue and stop double bouncebacks

http://forum.swsoft.com/showthread.php?s=646617aa5edfa86fcda65c641effc152&threadid=36297

#2) Kill double bounce backs!!!!!

in /var/qmail/control/ :

echo # > doublebounceto

#3) Flush your existing qmail-queue

Proceed with caution. After setting no doublebouncebacks, I totally cleared my queue.

/var/qmail/queue/

I cleared this out totally:

service qmail stop
rm mess/*/* –force
rm info/*/* –force
rm remote/*/* –force
rm local/*/* –force

better ftp transfers

I had to transfer one site from a dodgy host, to my shiny new godady plesk server.

However, every time I started up the old mget *, I go ‘Remote host has closed the connection‘ errors.

What to do? There were too many files to get and check separatly …

So, I found ncftp, luckily it was already installed on my machine. And it does recursive mgets as well! Anyway, here’s the connect command:
ncftp -u username -p password host.com
Better unzipping – unzip multiple zips at once
Once all the files had been transfered, and I had to restart a few times due to further connection losts, this little command unzips them all. PS I haven’t found out how to deal with spaces in file names yet ..
for i in *.zip; do unzip $i; echo next?; read e;done

Increase IMAP Connections

from: http://www.inertramblings.com/2006/09/22/add-more-courier-imap-connections-under-plesk/
Plesk comes configured with a limit of 4 connections per IP address and a limit of 40 connections total. Modern IMAP clients such as Mozilla Thunderbird use mailbox caching to open up multiple connections to increase performance. In the case of Thunderbird, it opens up 5 connections by default which is already 1 connection more than Courier-IMAP’s default restriction. Add another few family or corporate computers behind a firewall and those additional users won’t be able to connect at all since a single Thunderbird client is already utilizing all 4 connections.

To increase this restriction, modify the /etc/courier-imap/imapd configuration file and change MAXDAEMONS and MAXPERIP to a more sane number. In the case of my configuration, I changed MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40. This allows all the machines behind my home firewall to connect to multiple accounts on the e-mail server with mailbox caching enabled.

View maillogs

tail /usr/local/psa/var/log/maillog -f

Another new server

Set up a new 1and1 dedicated server today for a client. After managing dedicated plesk servers for a while now they’re getting so much easier. It really is a learn as you go thing.

It’s just a value server, but it’s hosted in the UK and won’t be used for any more than static html and a bit of ruby on rails later.

plesk

Update: It took some messing around – see Plesk Notes

But the emailing is working, and spam assassin isn’t killing all the emails …