Introduction
This article provides the steps needed to import the Roundcube contacts for a single user when Roundcube uses MySQL.
Procedure
The following procedure should only be performed by a qualified system or database administrator.
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
-
Backup the Roundcube database.
mysqldump roundcube > roundcube-backup.sql
- Find the email user's current
user_id
.mysql -e "select user_id from roundcube.identities where email = 'user@domain.tld';"
Please note that "user@domain.tld" must be replaced with the email address to restore the contacts. - Extract the
roundcibe.sql
file from the account backup. - Copy the
INSERT INTO `contacts`
line into a new .sql file.grep "INSERT INTO \`contacts\`" cpmove-username/mysql/roundcube.sql > import-roundcube.sql
Please note that "cpmove-username/mysql/roundcube.sql" must be replaced with the path to the extracted roundcube.sql file. - Open the new .sql file in your preferred text editor.
- Remove any records after
VALUES
that do not match theuser_id
found above.
Please note that parentheses enclose each record. Theuser_id
is the last value in the record. - Save the changes and exit the text editor.
- Enter the mysql command line interface.
mysql
- Change to the
roundcube
database.use roundcube;
- Use the following command to import the user's contacts.
source import-roundcube.sql
Please note that "import-roundcube.sql" must be replaced with the name of the .sql file edited previously. - Exit the mysql command line interface.
Additional resources
How to manually extract individual files from a cPanel backup with the tar utility