In H-Sphere 2.4 and up, the system database must be in UNICODE (UTF-8). To convert your database to Unicode:
Step 1. Stop the control panel
Log in as root and stop the control panel:
For Linux:
/etc/rc.d/init.d/httpdcp stop
killall -9 java
For FreeBSD:
/usr/local/etc/rc.d/apachecp.sh stop
killall -9 java
Step 2. Find out your current database encoding
To find the encoding, type:
su -l cpanel -c 'psql hsphere'
hsphere# \encoding
If the encoding is UNICODE (UTP-8), you've found what you need. If not, the next step is to
dump H-Sphere system database.
Step 3. Dump H-Sphere system database
Create and enter backup directory:
mkdir pg_backup
cd pg_backup
Get the password for wwwuser. You'll need it
to query the database:
cat ~cpanel/shiva/psoft_config/hsphere.properties | grep PASS
Dump H-Sphere system database.
Export schema:
pg_dump -u -s -f schema.db hsphere
chmod 600 schema.db
cp -p schema.db schema_backup.db
Export data:
pg_dump -u -a -f data.db hsphere
chmod 600 data.db
cp -p data.db data_backup.db
Notes:
If your system database is large, the dump can take several hours
to complete. You can speed it up by setting
fsync=off
in postgresql.conf. When you are done, unset this option back for safety reasons.
The dump file is created with 644 permissions by default;
you need to set more secure 600 permissions
to prevent the data from being read by other users.
- For additional security, you may disallow access to the backup directory for all other users:
chmod 700 .
Step 4. Convert the dump to UNICODE
Convert the dump into Unicode with the iconv utility.
Linux:
iconv --from-code=<REGIONAL_ENCODING>
--to-code=UTF-8 -o utf_data.db data.db
mv utf_data.db data.db
FreeBSD:
iconv -f <REGIONAL_ENCODING> -t UTF-8 data.db > utf_data.db
mv utf_data.db data.db
[ -]
If your dump file exceeds 2GB
1) Split it into smaller files, 1GB each:
split -b 1024m data.db data_db
2) Run iconvfor for each of these files to convert them to UNICODE:
iconv --from-code=<REGIONAL_ENCODING>--to-code=UTF-8 -o utf_data_db.aa data_db.aa
iconv --from-code=<REGIONAL_ENCODING>--to-code=UTF-8 -o utf_data_db.ab data_db.ab
...
3) Join them back into data.db:
cat utf_data_db.aa utf_data_db.ab utf_data_db.ac ... > data.db
Here, <REGIONAL_ENCODING> is the source encoding.
For example, for native US English encoding:
Linux:
iconv --from-code=ISO-8859-1 --to-code=UTF-8 -o utf_data.db data.db
FreeBSD:
iconv -f ISO-8859-1 -t UTF-8 data.db > utf_data.db
The resulting data.db file will contain the data converted to Unicode.
For better security, run the following command:
chmod 600 data.db
Step 5. Save the postgres directory in a backup location
- Stop the database:
For Linux:
/etc/rc.d/init.d/postgresql stop
For FreeBSD:
/usr/local/etc/rc.d/010.pgsql.sh stop
- Save the postgres directory:
For Linux:
cp -pR ~postgres/data ./
For FreeBSD:
cp -pR ~pgsql/data ./
- Start the database:
For Linux:
/etc/rc.d/init.d/postgresql start
For FreeBSD:
/usr/local/etc/rc.d/010.pgsql.sh start
Step 6. Recreate H-Sphere database
-
Delete old H-Sphere database:
# su - cpanel
$ dropdb hsphere
Create database:
createdb -E UNICODE -U wwwuser hsphere
- Create H-Sphere DB schema:
psql -q -U wwwuser -f schema.db hsphere
- Import H-Sphere system data:
psql -q -U wwwuser -f data.db hsphere
Note: If you face problems with importing data, please see the
Troubleshooting section in CP Acceleration guide.
- If you added
fsync=off
to postgresql.conf, don't forget to delete it
- Start the Control Panel.
|