Restoring a database in Plesk from the Command Line

- by

I had an issue with a brand new Plesk server on IONOS that apparently didn’t have the “apsc” database. Must have corrupted after the first update, but thankfully Plesk had made a backup just before it did this. It was a full server backup, part of which is this database backup. Here’s where we’ll find them:

/var/lib/psa/dumps

Databases are stored in GZ format, so we can use GUNZIP to unZIP them:

gzip mysql.preupgrade.apsc*

I only had a single one of those, but there may be multiple if several backups have run recently. Pick the most recent one before any issues occured. Gunzip will remove the zipped version, so you’re left with the plan .dump file.

Next we’ll use the mysql command to feed the dump back into the database. Here’s how we do that:

MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -f -uadmin apsc < apsc.dump

Replace the file name from your dump as appropriate. This reads the password for the MySQL server from Plesk’s psa database (the stuff in backticks does that), then uses the feed operator to redirect the output. It looks more cryptic than it actually is.

Plesk’s main database is psa, which is something I had to fix next from a similar dump. This brought it back to the point of first registration, but now it seems to work fine. So yeah, databases and corruption. Just another note to self, this might have also been fixed by restoring the backup Plesk had made instead, might try that next.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.