I have tried my hand at building a shell script to backup our wordpress database using tar balls and chron jobs on a Debian environment.
The problem I am facing now is that our wp database after exporting, using the script, and then importing, using phpmyadmin, loses some special characters. Most noteably the €
sign.
Phpmyadmin lists the database as latin1_swedish_ci
and that is the collation setting I am selecting in the Import tab of phpmyadmin (iso-8859-1).
I am using the following script to export the database:
mysqldump --user=user --password=password --default-character-set=latin1 --skip-set-charset databasename -r wp-db.sql
tar -cpzf /home/backups/wp-backups/website-wp-$(date +"%d-%m-%Y--%H-%M").tar.gz wp-db.sql && rm wp-db.sql
My best guess is that there must be some issue with collation but I am not aware where some type of conversion happens in the steps that I am taking. At some point the €
must be dropped.
When inspecting the wp-db.sql
using file
it is described as iso-8859-1
, hence I wonder where conversion takes place.
I have since tried to test some things and discovered that I am not capable of converting a UTF-8
file to iso-8859-1
if it includes a €
sign. At least not using
iconv -f UTF-8 -t ISO_8859-1 test
From what I gather mysql runs in UTF-8
natively, might that be the issue?
If I do not bother with any of this it will completely ruin things. Pretty much everything that isnt wp files but stored in the database will be displayed incorrectly or will be completely missing. By adding these two arguments to my script I have eliminated most of the issues apart from special character problems.