Update Readme with Plesk instructions

The readme instructions are updated with instructions for Plesk servers.
This commit is contained in:
bas 2021-10-15 14:41:43 +02:00
parent dc7ee24e37
commit 8fa41ed193
1 changed files with 28 additions and 1 deletions

View File

@ -46,6 +46,12 @@ else
fi
```
Method 3: Plesk server use the admin user
```
sed -i "s|^#MYSQL_USER='root'|MYSQL_USER='admin'|g" /usr/local/sbin/backup_mysql.sh
sed -i "s|^#MYSQL_PW='ThisIsMyMySQLRootPassword'|MYSQL_PW=\$\(cat /etc/psa/.psa.shadow\)|g" /usr/local/sbin/backup_mysql.sh
```
## Install script ##
```
@ -62,7 +68,7 @@ This will add a cronjob to root which will run this script daily at 0:10 am. Adj
```
## Recover database ##
Method 1:
Assuming you want to restore my-testdb from your backups made on 20211012-0010, define variables:
```
DB='my-testdb'
@ -82,4 +88,25 @@ And now the actual recovery (Need to be in the same session! Do not enter this i
sudo mysql -e 'DROP DATABASE IF EXISTS `'${NEWDB}'`'
sudo mysql -e 'CREATE DATABASE `'${NEWDB}'`'
for table in ${BACKUPDIR}/${DB}/*; do gunzip -c $table | sudo mysql ${NEWDB}; done
```
Method 2 - Plesk Servers:
Assuming you want to restore my-testdb from your backups made on 20211012-0010, define variables:
```
DB='my-testdb'
NEWDB='my-testdb'
BACKUPDIR='/var/backup/mysql/20211012-0010'
```
TIP: You can change NEWDB to any other name if you wish to restore to an alternate database name!
Make sure you have a backup of the current database which will be replaced:
```
sudo mysqldump -u admin -p$(cat /etc/psa/.psa.shadow) ${NEWDB} > /root/${NEWDB}-$(date +%Y%m%d).sql
```
And now the actual recovery (Need to be in the same session! Do not enter this in another SSH window / terminal):
```
sudo mysql -u admin -p$(cat /etc/psa/.psa.shadow) -e 'DROP DATABASE IF EXISTS `'${NEWDB}'`'
sudo mysql -u admin -p$(cat /etc/psa/.psa.shadow) -e 'CREATE DATABASE `'${NEWDB}'`'
for table in ${BACKUPDIR}/${DB}/*; do gunzip -c $table | sudo mysql -u admin -p$(cat /etc/psa/.psa.shadow) ${NEWDB}; done
```