Plesk

I know there are a lot of places where you can probably find the code below, but instead of having to look it up again the next time I have to use it, I thought it'd be handy to just add it here as a how-to item.

The code uses the primary admin account which comes default with Plesk, and uses a snippet to pull in the password automatically, then the database name is specified along with a filename for the exported database.

On newer Plesk versions it seems the phpMyAdmin importing is a lot more robust (larger file sizes and execution times) you can then take the exported file and import it using phpMyAdmin into a new Plesk server (if you're migrating from an older Plesk version as I was).

/usr/bin/mysqldump --user=admin --password=`/bin/cat /etc/psa/.psa.shadow` mydatabasename > myexportfile.sql

I was having some trouble the other day exporting a database that was about 40MB from Plesk's phpMyAdmin area and was getting a page could not be found error (though it appeared to work when only trying to export one table). This gave me the sense that it might be a memory issue for Plesk's PHP installation, and on searching I found a really good Parallels forum thread with exact instructions on what to modify. I found these instructions here: http://forum.parallels.com/showthread.php?t=81020

Open your plesk php.ini (my plesk php.ini located: /usr/local/psa/admin/conf/php.ini) 
Find memory_limit change to example: memory_limit = 256M 
Stop and start psa services: 
/etc/init.d/psa stopall
/etc/init.d/psa start
# php.ini location
/etc/php.ini

# php.ini include files
/etc/php.d

# ioncube location on 64-bit OS
/usr/lib64/php/ioncube

# httpd.conf location
/etc/httpd/conf/httpd.conf

# httpd.conf include files
/etc/httpd/conf.d

# php.conf location
/etc/httpd/conf.d/php.conf

When Plesk creates an account for you it will always assign the httpdocs folder to the "psaserv" group, and all files within the httpdocs folder to the "psacln" group.

Sometimes you may run into trouble should you accidentally modify these groups (especially when you change the group of the httpdocs folder from psaserv) so should you need to restore these groupings you may run the following commands in succession:

chown -R your_plesk_username:psacln /your/httpdocs/directory
chown your_plesk_username:psaserv /your/httpdocs/directory

What the first command does is make sure that all of the files and folders within your httpdocs folder are correctly within the "psacln" group. The negative side effect of using the "-R" directive is that it also changes the permissions of the httpdocs directory itself, leading to the second command which only changes the httpdocs folder itself to be part of the "psaserv" group, while leaving the files and folders within with the correct grouping.

Compared to a cPanel environment, where you are almost exclusively required to use a .htaccess file, in Plesk you are able to reconfigure Apache and add to the configuration file on the fly.

In every domain and sub domain created in Plesk there is a folder named "conf" that contains a file named "httpd.include" which contains the automatically generated Apache configuration created by Plesk. Since you don't want to edit an automatically generated file, Plesk includes a way to add-on to the httpd.include via the "vhost.conf" file. In the same "conf" folder, create a new file named "vhost.conf". I typically do this by typing in the following into the command line:

vi vhost.conf

I then add my Apache configurations to the vhost.conf file and then save them by typing in:

:w

Now you'll need to tell Plesk to reload it's Apache configuration by typing in the following (replace example.com with your domain name):

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=example.com

In my wanderings for Plesk assistance I have found the following resources helpful:

And of course, Parallels support has been pretty helpful in most situations too!

This script was created over the course of a few days early on when I first began working. The way things had been setup, we had an instance of our CMS application using a pre-production database that periodically needed to be synced to our production database. Prior to my arrival this procedure had been completed manually every few hours.

Before this I had never written any sort of shell script so I had a fun time looking up the commands and figuring out how to write the script and get things working.