bggo / Zmbkpose

The zmbkpose tool is a shell script that does hot backup and hot restore of ZCS Opensource accounts, GPL(OPENSOURCE). It can run from any host in the net, which means that it can be set on a backup server already existent.
http://wiki.zimbra.com/wiki/HOT_Backup_and_HOT_Restore
GNU General Public License v3.0
79 stars 56 forks source link

No mailbox.tgz in incremental tar files #49

Closed Budzi closed 10 years ago

Budzi commented 10 years ago

Hi,

I have an issue with rewrite_proposal_2.0 of Zmbkpose.

This issue was mentioned in issue #33 by ymarinov but it was not answered as far as I can see. When incremental files are created, if there are no new mails, calendar or any other entries for the specific user, there will be no mailbox.tgz file in the :INC.tar file. This is not an error per se, but when you try to restore that specific user, an error is thrown and the restore stops. The error is in the form:

ERROR: file mailbox.tgz does not exists in tar file "/opt/zimbra/backup/user1.mail@mydomain.com/20140222215236:INC.tar"

NOTE: I changed the domain to mydomain.com for privacy purposes.

The error comes from the code in the restore_account() function, namely this part:

#Restore
        if ! $TAR_cmd -tf "$tar_bkfile" $MAILBOX_FILE_IN_TAR >/dev/null 2>&1;then
            error "file $MAILBOX_FILE_IN_TAR does not exists in tar file \"$tar_bkfile\""
            return 1
        fi
        if [ -z "$SIMULATE" ] ;then
            $TAR_cmd -O -xf "$tar_bkfile" $MAILBOX_FILE_IN_TAR| \
                zimbra_mailbox_restore "$account" "$mailhost" 
        fi 

I changed this code a little bit so that it doesn't stop on error, but just skip. You could also add the check for the -u switch, although this is not an error, this is just the way the incremental files are created. The changed code looks like this:

     #Restore
                if ! $TAR_cmd -tf "$tar_bkfile" $MAILBOX_FILE_IN_TAR >/dev/null 2>&1;then
                        error "file $MAILBOX_FILE_IN_TAR does not exists in tar file \"$tar_bkfile\"
                elif [ -z "$SIMULATE" ] ;then
                                $TAR_cmd -O -xf "$tar_bkfile" $MAILBOX_FILE_IN_TAR| \
                                        zimbra_mailbox_restore "$account" "$mailhost"
                fi        

I am not that good at bash scripting, so I am sure that this can be improved. Hope this helps someone else.

BTW, this is an excellent project.

Thank you for all your efforts and time and keep up the good work!

liandros commented 10 years ago

Thanks Budzi . I submit the change as commit 7315df847b6aabfe8e4dc64c9daa0b6c37b75f3f : Issue #49: Bug restoring inc. backup with no mails. Thanks Budzi

Again, thank you very much Budzi.