Introduction
There may be times when you need to restore a single email account from a backup instead of the entire account. This can be accomplished from the command line.
Procedure
Please note that in the following examples, "$username," "$emailusername," and "$domain.tld" must be replaced with the cPanel account's username, the email account's username, and the account's domain name, respectively.
- Log into the cPanel user's account.
- Ensure that the target email account exists.
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Extract the contents of the backup for the account.
tar -xf /path/to/backup/location/$username.tar.gz -C /path/to/extraction/folder/
Please note that "/path/to/backup/location/" and "/path/to/extraction/folder/" must be replaced with the path to the backup location and the path to the extraction folder. - Copy the email account's files to the email account's Inbox under the cPanel account.
cp /path/to/extraction/folder/$username/homedir/mail/$domain.tld/$emailusername/cur/* /home/$username/mail/$domain.tld/$emailusername/cur/
Please note that if you wish to restore all emails, you must copy all the mail directories (cur, new, .spam, .Sent, .Trash, etc.). - Change the ownership of the mail files.
find /home/$username/mail/$domain.tld/$emailusername/ ! -user $username -exec chown $username. {} \;
Additional resources
How to manually extract individual files from a cPanel backup with the tar utility
Comments
0 comments
Article is closed for comments.