From: Patrick Canterino Date: Tue, 12 Oct 2021 18:51:40 +0000 (+0200) Subject: Introduced new config variable dbNoMultibyte for restoring database without multibyte X-Git-Tag: v2.3.0~2^2~1 X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/commitdiff_plain/bac6338631a1e00c2501d7fdb3bb6ad5ba46100c Introduced new config variable dbNoMultibyte for restoring database without multibyte So there is no need to modify code to achieve this anymore --- diff --git a/NextcloudRestore.sh b/NextcloudRestore.sh index fcb6589..6795735 100644 --- a/NextcloudRestore.sh +++ b/NextcloudRestore.sh @@ -63,6 +63,9 @@ dbUser='nextcloud_db_user' # TODO: The password of the Nextcloud database user dbPassword='mYpAsSw0rd' +# TODO: Uncomment this and set to true if the database from the backup DOES NOT use UTF8 with multibyte support (e.g. for emoijs in filenames) +#dbNoMultibyte=true + # File names for backup files # If you prefer other file names, you'll also have to change the NextcloudBackup.sh script. fileNameBackupFileDir='nextcloud-filedir.tar' @@ -237,10 +240,13 @@ echo echo "$(date +"%H:%M:%S"): Creating new DB for Nextcloud..." if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ]; then - # Use this if the databse from the backup uses UTF8 with multibyte support (e.g. for emoijs in filenames): - mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" - # TODO: Use this if the database from the backup DOES NOT use UTF8 with multibyte support (e.g. for emoijs in filenames): - #mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase}" + if [ ! -z "${dbNoMultibyte+x}" ] && [ "${dbNoMultibyte}" = true ] ; then + # Database from the backup DOES NOT use UTF8 with multibyte support (e.g. for emoijs in filenames) + mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase}" + else + # Database from the backup uses UTF8 with multibyte support (e.g. for emoijs in filenames) + mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" + fi elif [ "${databaseSystem,,}" = "postgresql" ] || [ "${databaseSystem,,}" = "pgsql" ]; then sudo -u postgres psql -c "CREATE DATABASE ${nextcloudDatabase} WITH OWNER ${dbUser} TEMPLATE template0 ENCODING \"UNICODE\";" fi