ILIAS 8 Install Tutorial for Ubuntu 22.04

DB-Backup

  • It is crucial to back the database
  • We can do this by a simple script:
mkdir -p  /opt/scripts/dbScripts
cd /opt/scripts/dbScripts
touch dbclone
chmod +x dbclone
nano dbclone
#!/bin/bash
#Credentials, DB-Names
dbuser=ildbuser1
dbnameori=ildb1
dbnameclone=ildb1_backup1
 
# Drop the cloned database if it exists
echo "Dropping the database ${dbnameclone} if it exists..."
mysql --execute="DROP DATABASE IF EXISTS \`${dbnameclone}\`;"
 
# Create a new database clone
echo "Creating a new clone of the database ${dbnameclone}..."
mysql --execute="CREATE DATABASE \`${dbnameclone}\` CHARACTER SET utf8 COLLATE utf8_general_ci;"
 
# Grant privileges to the user for the cloned database
echo "Granting privileges to ${dbuser} for the cloned database ${dbnameclone}..."
mysql --execute="GRANT ALL PRIVILEGES ON \`${dbnameclone}\`.* TO '${dbuser}'@'localhost';"
 
# Check if the SQL backup file already exists and delete it
if [ -f "${dbnameclone}.sql" ]; then
echo "Deleting old backup file ${dbnameclone}.sql from disk..."
rm "${dbnameclone}.sql"
fi
 
# Create a dump of the original database
echo "Copying DB ${dbnameori} into a file on disk named ${dbnameclone}.sql..."
mysqldump ${dbnameori} > ${dbnameclone}.sql
 
# Restore the dump into the cloned database
echo "Restoring the dump into the cloned database ${dbnameclone}..."
mysql ${dbnameclone} < ${dbnameclone}.sql
 
# End of process
echo "End of process."
 
# Show the databases
mysql --execute="SHOW DATABASES;"


No comment has been posted yet.