BlueMind provides a couple of shell and python scripts to help you with restoring data from a user mailbox backup.
Prerequisites
To be able to use these scripts, the Python Client must be installed on the machine.
Useful files
View file |
---|
name | updateMboxAcls.py |
---|
height | 250 |
---|
|
Procedure
The script restore.sh
will restore user data from the backup directory into a user's or another user's mailbox, as required, into a sub-folder named restored_<timestamp>
.
To start it:
Bloc de code |
---|
./restore.sh USER|MAILSHARE BACKUP_PATH EMAIL_ADDRESS |
USER|MAILSHARE
: to restore a user use the keyword USER, to restore a shared mailbox use the keyword MAILSHAREBACKUP_PATH
: path to the data in the BlueMind backup directory (/var/backups). The path looks like:
/var/backups/bluemind/dp_spool/rsync/<IP>/mail/imap/<backup number>/var/spool/cyrus/data/<bluemind domain>/domain/<domain initial>/<domaine bluemind>/<user initial>/user/<user>/
E.g. for the user "jdoe" on the domain "bluemind.loc":
/var/backups/bluemind/dp_spool/rsync/192.168.122.148/mail/imap/806/var/spool/cyrus/data/bluemind_loc/domain/b/bluemind.loc/j/user/jdoe/
EMAIL_ADDRESS
: email address for the user whose mailbox you want to restore the data into
Examples of use:
Tabs group |
---|
border | all-sides |
---|
navcolor | navy |
---|
|
Restoring contents into the user's mailbox To restore the mailbox of user John Doe (id: jdoe) into his mailbox (email address: jdoe@bluemind.loc) Messages as well as the folder structure, can then be accessed in John Doe's mailbox. Restoring contents into another user's mailboxTo restore the mailbox of user John Doe (id: jdoe) into another user's mailbox (email address: hannibal@bluemind.loc): Les messages, ainsi que l'arborescence de dossiers, sont dès lors consultable dans la boîte de l'utilisateur John Smith. |
Manual restore
Concepts
The data (emails) is stored in the server directory /var/spool/cyrus/data/domain_loc/[...]/[n]/user/nom_user/
([n] being the initial of the login id, i.e. *n*om_user in this example)
The metadata is stored in the server directory /var/spool/cyrus/meta/domain_loc/[...]/[n]/user/nom_user/
. This is email metadata: read status, flags, reply or forward markers, etc.
It is recommended that you backup metadata. Without metadata backups, restoration is still possible, but they will be present in their original state: they will be considered as unread, not replied to and have no particular status.
Prerequisites and example data
The server the data is restored into, if it is not the original server -- must have the same characteristics: same domain name, same IP address, same url, same BlueMind version, etc.
- the user name must be identical to the original user name
For the procedure, we will use the following user:
- domain
bluemind.loc
- user name
jdoe
The data:
- the mailbox data (see above) will be placed in the target server in the following directories:
- data:
/var/backups/jdoe/
- metadata:
/var/backups/jdoe-meta/
- the data will be restored into a subfolder of the user's mailbox named
restore_dir
(this can be any name, you can use the day's date or any other name)
Procedure
Remarque |
---|
In the directory paths or some command lines, the full stop '.' in the domain name is replaced with underscore '_'. Make sure you make this substitution when you adapt the commands to your domain. |
Restoration into mailbox other than the user's
To restore a user's messages into a maibox other than its original mailbox, you have two options:
- restore without the metadata (see below)
- restore with the metadata (see below) then:
- log in with the target user id
- go to parameters > Mail > tab Sharings > click Save"
There is no need to make any changes, simply force-save sharing options.
Log in as root
:
- go into
/var/spool/cyrus/data/bluemind_loc/domain/b/bluemind.loc/j/user/jdoe/
copy the data you want to restore and give the appropriate rights to the directory thereby created:
Bloc de code |
---|
mv /var/backups/jdoe/ restore_dir
chown -R cyrus:mail restore_dir
chmod -R u+rwx restore_dir |
- go into
/var/spool/cyrus/meta/bluemind_loc/domain/b/bluemind.loc/j/user/jdoe/
copy the metadata you want to restore into a new sub-directory with the same name as the directory used for the data:
Bloc de code |
---|
mv /var/backups/jdoe-meta/ restore_dir
chown -R cyrus:mail restore_dir
chmod -R u+rwx restore_dir |
run the Cyrus mailbox reconstruct command:
Bloc de code |
---|
/usr/lib/cyrus/bin/reconstruct -r -f user/jdoe@bluemind.loc |
Remarque |
---|
In the directory paths or some command lines, the full stop '.' in the domain name is replaced with underscore '_'. Make sure you make this substitution when you adapt the commands to your domain. |
Logged into the server as root
:
- go into
/var/spool/cyrus/data/bluemind_loc/domain/b/bluemind.loc/j/user/jdoe/
copy the data you want to restore and give the appropriate rights to the directory thereby created:
Bloc de code |
---|
mv /var/backups/jdoe/ restore_dir
chown -R cyrus:mail restore_dir
chmod -R u+rwx restore_dir |
reproduce the tree structure for the metadata:
Bloc de code |
---|
find restore_dir/ -type d -exec mkdir /var/spool/cyrus/meta/bluemind_loc/domain/b/bluemind.loc/j/user/jdoe/{} \; |
go into the user's metadata folder, create the cyrus.header files and set the appropriate rights:
Bloc de code |
---|
cd /var/spool/cyrus/meta/bluemind_loc/domain/b/bluemind.loc/j/user/jdoe/
find restore_dir -type d -exec touch {}/cyrus.header \;
chown -R cyrus:mail restore_dir |
run the Cyrus mailbox reconstruction command:
Bloc de code |
---|
/usr/lib/cyrus/bin/reconstruct -p bluemind_loc -r -f user/jdoe/restore_dir@bluemind.loc |
Finalizing - in all scenarios
run the quota application command:
Bloc de code |
---|
/usr/lib/cyrus/bin/quota -f -d bluemind.loc user/jdoe |
At this point, the messages should be accessible in webmail. If it isn't he case, make sure you refresh the tree structure cache be following these steps:
- while logged into BlueMind as the user, click the gears button at the bottom left of the folders list > "Manage folders":
Image Added - the
restore_dir
folder and its structure should be visible in the folder structure - go back to webmail without performing any additional actions
- the folder and the restored messages should then be visible
To finalize:
- if a quota is set on the mailbox, make sure it has not been reached; if it has, increase it temporarily.
- in the admin console, while logged in as admin0:
- go to the user management page > Maintenance tab
- check "Repair mailbox indexing"
- click Save