Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Per User Backup Foss edition

  1. #1
    dhipo is offline Starter Member
    Join Date
    Feb 2010
    Location
    Brasilia - DF Brazil
    Posts
    2
    Rep Power
    5

    Default Per User Backup Foss edition

    This is my script to backup all users mailboxes. The restore can be done using import feature in preferences of user.

    The goal is .. Can be done with live Zimbra Server, no downtime, no offline mode.

    enjoy,
    Code:
    #################cut here####################
    #!/usr/bin/perl 
    ## Perl Script to Backup Mailboxes
    ## All users are backup´ed 
    ## Gpl´d by Douglas Hipocreme (douglas at dhix.com.br)
    use Date::Format;
    use File::Find;
    use File::Find qw(finddepth);
    $periodo= time2str("%d%m%Y", time);
    $bkpdest = "/tmp/mailboxes";
    *name = *File::Find::name;
    finddepth \&zap, $bkpdest;
    sub zap {
        if (!-l && -d _) {
            rmdir($name)  or warn "couldn't rmdir $name: $!";
        } else {
            print "unlink $name\n";
            unlink($name) or warn "couldn't unlink $name: $!";
        }
    }
    mkdir "$bkpdest", 0777 unless -d "$bkpdest";
    $mode = 0777;   chmod $mode, "$bkpdest"; 
    $usuarios = "/$bkpdest/user-list-full";
    
    $mode = 0777;   chmod $mode, "$usuarios";
    
    my $usersid = `su - zimbra -c 'zmprov gaa'>$usuarios`;
    open (MYFILE, $usuarios);
    	while (<MYFILE>) 
    	{
        chomp;
    	 my ($user ) = split(/\;/, $_, 1);
    	 print qq {========================\n};
    	 print qq {"Doing compress on $user" ......\n};
    	 my $process = `su - zimbra -c 'zmmailbox -z -m $user getRestURL '//?fmt=tgz' > $bkpdest/$user.tgz'`;
    	 print qq {"Compressed sucesfully  $user"\n};
    	 print qq {========================\n};
    	}
    close(MYFILE);
    use File::Find;
    use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
    my $dir = $bkpdest;
    my $zip = Archive::Zip->new();
    my $zipped;
    $zipped = $zip->addDirectory( $dir );
    $zipped->desiredCompressionMethod( COMPRESSION_DEFLATED );
    find(\&zip_file, $dir);
    
    die 'write error' unless $zip->writeToFileNamed('/tmp/backup/'.$periodo.'-mailboxes.zip') == AZ_OK;
    
    sub zip_file {
    $zipped = $zip->addFile( $File::Find::name );
    }
    ###### end of script ###########################
    Last edited by phoenix; 02-07-2010 at 11:42 PM.

  2. #2
    dudi is offline New Member
    Join Date
    Feb 2010
    Location
    Indonesia
    Posts
    3
    Rep Power
    5

    Default Bash Scripting Live Backup for FOSS Edition

    i've made a bash script to do a live backup.

    this script is similar with script has been made by dhipo.

    rsync and ssh not including in this script, but I think we can modifying and merging this script with other scripts from the wiki page.

    the goal is to do a remotely synchronization using rsync, ssh and "live" backup for zimbra open source edition.

    Code:
    #!/bin/bash
    ### START CONFIGURATION ###
    DIR="/tmp/zimbra";
    OUTPUT="/tmp/zimbra";
    ### END OF CONFIGURATION ###
    
    USERS=`su - zimbra -c 'zmprov gaa'`;
    DATE=`date +%Y%m%d`;
    
    if [ ! -d $DIR ]; then mkdir $DIR; chown zimbra:zimbra $DIR; fi
    
    for ACCOUNT in $USERS; do
            NAME=`echo $ACCOUNT | awk -F@ '{print $1}'`;
            su - zimbra -c "zmmailbox -z -m $ACCOUNT getRestURL '//?fmt=tgz' > $DIR/$NAME.tgz";
    done
    cd $DIR; mkdir $DATE; mv *.tgz $DATE
    tar cjpf $OUTPUT/$DATE.tar.bz2 $DATE;
    cd $DIR; rm -rf $DATE

  3. #3
    stegbth is offline Special Member
    Join Date
    Sep 2008
    Posts
    134
    Rep Power
    6

    Default

    hi,

    i tried this script, but running zmmailbox gives me the following error:

    ERROR: zclient.IO_ERROR (Connection refused) (cause: java.net.ConnectException Connection refused)
    does this need zimbra 6?

    best regards
    thomas
    zmcontrol -v
    1x Release 6.0.10_GA_2692.UBUNTU8_64 NETWORK edition.
    1x Release 6.0.14_GA_2928.UBUNTU8_64 NETWORK edition
    2x Release 7.1.3_GA_3346.UBUNTU10_64 NETWORK edition, Patch 7.1.3_P1
    1x Release 8.0.2.GA.5569.UBUNTU12.64 NETWORK edition

    2x Release 6.0.10_GA_2692.UBUNTU8_64 FOSS edition
    2x Release 7.2.2_GA_2852.UBUNTU10_64 FOSS edition
    1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
    1x Release 8.0.3.GA.5664.UBUNTU12.64 FOSS edition

  4. #4
    dudi is offline New Member
    Join Date
    Feb 2010
    Location
    Indonesia
    Posts
    3
    Rep Power
    5

    Default

    stegbth,

    which script do you use?

  5. #5
    stegbth is offline Special Member
    Join Date
    Sep 2008
    Posts
    134
    Rep Power
    6

    Default

    hi dudi,

    i am running 5.0.18 on ubuntu 8.04amd64 with "zmtlsctl https"
    the error comes, when running the following command
    su - zimbra -c "zmmailbox -z -m myuser@mydomain getRestURL '//?fmt=tgz' > /opt/zimbra/backup/myusermydomain.tgz";
    i run the same on a 6.0.4 test box, there it works (but i curently doesnt know if zmtlsctl is set to https). The blog ZCS-to-ZCS Migrations » Zimbra :: Blog it is notes it should work with 5.0.9+

    i am not sure, but i assume there is a problem with zmtlsctl. as zmmailbox export fails after setting "zmtlsctl https" seems to be a problem when aktivating https only.

    best regards
    thomas
    zmcontrol -v
    1x Release 6.0.10_GA_2692.UBUNTU8_64 NETWORK edition.
    1x Release 6.0.14_GA_2928.UBUNTU8_64 NETWORK edition
    2x Release 7.1.3_GA_3346.UBUNTU10_64 NETWORK edition, Patch 7.1.3_P1
    1x Release 8.0.2.GA.5569.UBUNTU12.64 NETWORK edition

    2x Release 6.0.10_GA_2692.UBUNTU8_64 FOSS edition
    2x Release 7.2.2_GA_2852.UBUNTU10_64 FOSS edition
    1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
    1x Release 8.0.3.GA.5664.UBUNTU12.64 FOSS edition

  6. #6
    dudi is offline New Member
    Join Date
    Feb 2010
    Location
    Indonesia
    Posts
    3
    Rep Power
    5

    Default

    hi stegbth,

    looks like getRestURL only works on http, because the log said:

    <code>Connection refused</code>

    It means, there's no http services listen on port 80. you can try to setup zmtlsctl both for http and https.

  7. #7
    stegbth is offline Special Member
    Join Date
    Sep 2008
    Posts
    134
    Rep Power
    6

    Default

    hi dudi,

    i dont think so.

    1. when running zmmailbox with parameter -z (or -a) it connects to the admin-port (7071) which is imho always encrypted by ssl)

    2. i upgraded the zimbra now to 5.0.22 and set "zmtlsctl both" --> there is no change, still connection refused.

    but i found in the logs an error,

    2010-02-13 14:27:02,019 INFO [btpool0-14] [ip=127.0.0.1;] soap - AuthRequest
    2010-02-13 14:27:02,027 WARN [btpool0-14] [] log - SSL renegotiate denied: java.nio.channels.SocketChannel[connected local=/127.0.0.1:7071 remote=/127.0.0.1:51393]
    2010-02-13 14:27:02,084 INFO [btpool0-14] [name=zimbra;ip=127.0.0.1;] soap - GetAccountInfoRequest
    2010-02-13 14:27:02,084 INFO [btpool0-14] [name=zimbra;ip=127.0.0.1;] misc - delegated access: doc=GetAccountInfo, authenticated account=zimbra, target account=wiki@mydomain.de
    2010-02-13 14:27:02,088 WARN [btpool0-14] [] log - SSL renegotiate denied: java.nio.channels.SocketChannel[connected local=/127.0.0.1:7071 remote=/127.0.0.1:45084]
    2010-02-13 14:27:02,094 INFO [btpool0-14] [name=zimbra;ip=127.0.0.1;] soap - DelegateAuthRequest
    2010-02-13 14:27:02,094 INFO [btpool0-14] [name=zimbra;ip=127.0.0.1;] misc - delegated access: doc=DelegateAuth, authenticated account=zimbra, target account=wiki@mydomain.de
    2010-02-13 14:27:02,113 WARN [btpool0-14] [] log - SSL renegotiate denied: java.nio.channels.SocketChannel[connected local=/127.0.0.1:7071 remote=/127.0.0.1:37982]
    2010-02-13 14:27:02,167 INFO [btpool0-14] [name=wiki@mydomain.de;aname=zimbra;mid=4;ip=192.16 8.23.3;ua=zclient/5.0.22_GA_3210.UBUNTU8_64;] soap - GetInfoRequest
    2010-02-13 14:27:02,167 INFO [btpool0-14] [name=wiki@mydomain.de;aname=zimbra;mid=4;ip=192.16 8.23.3;ua=zclient/5.0.22_GA_3210.UBUNTU8_64;] misc - delegated access: doc=GetInfo, delegating account=zimbra, authenticated account=wiki@mydomain.de, target account=wiki@mydomain.de
    so it looks like an authentication problem?

    best regards
    thomas
    zmcontrol -v
    1x Release 6.0.10_GA_2692.UBUNTU8_64 NETWORK edition.
    1x Release 6.0.14_GA_2928.UBUNTU8_64 NETWORK edition
    2x Release 7.1.3_GA_3346.UBUNTU10_64 NETWORK edition, Patch 7.1.3_P1
    1x Release 8.0.2.GA.5569.UBUNTU12.64 NETWORK edition

    2x Release 6.0.10_GA_2692.UBUNTU8_64 FOSS edition
    2x Release 7.2.2_GA_2852.UBUNTU10_64 FOSS edition
    1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
    1x Release 8.0.3.GA.5664.UBUNTU12.64 FOSS edition

  8. #8
    phoenix is online now Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,491
    Rep Power
    56

    Default

    Post the output of the following (run on the server you're trying to backup):

    Code:
    cat /etc/hosts
    cat /etc/resolv.conf
    dig yourdomain.com mx
    dig yourdomain.com any
    host `hostname`  <- use that exact ocmmand with backticks not single quotes
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  9. #9
    stegbth is offline Special Member
    Join Date
    Sep 2008
    Posts
    134
    Rep Power
    6

    Default

    hi,

    cat /etc/hosts
    192.168.23.3 zimbra-mydom.mydomain.de zimbra-mydom
    127.0.0.1 localhost
    cat /etc/resolv.conf
    domain haar.mydomain.de
    search haar.mydomain.de
    nameserver 192.168.23.96
    dig mydomain.de mx
    mydomain.de. 604800 IN MX 100 zimbra-mydom.mydomain.de
    dig mydomain.de any
    mydomain.de. 604800 IN SOA localhost. root.mydomain.de. 2008021918 604800 86400 2419200 604800
    mydomain.de. 604800 IN MX 100 zimbra-mydom.mydomain.de.
    mydomain.de. 604800 IN NS gw01-mydom.haar.mydomain.de.
    mydomain.de. 604800 IN NS hornet.haar.mydomain.de. mydomain.de. 604800 IN A 127.0.0.1

    ;; ADDITIONAL SECTION:
    zimbra-mydom.mydomain.de. 604800 IN A 192.168.23.3
    hornet.haar.mydomain.de. 86400 IN A 192.168.23.96
    host `hostname`
    zimbra-mydom.haar.mydomain.de has address 192.168.23.3
    so it is a problem with dns-resolution?
    as the Server is responsible for mydomain.de, but the hostname lookups to haar.mydomain.de ? (and the error in the SOA, which i will fix immediatly)


    best regards
    thomas
    zmcontrol -v
    1x Release 6.0.10_GA_2692.UBUNTU8_64 NETWORK edition.
    1x Release 6.0.14_GA_2928.UBUNTU8_64 NETWORK edition
    2x Release 7.1.3_GA_3346.UBUNTU10_64 NETWORK edition, Patch 7.1.3_P1
    1x Release 8.0.2.GA.5569.UBUNTU12.64 NETWORK edition

    2x Release 6.0.10_GA_2692.UBUNTU8_64 FOSS edition
    2x Release 7.2.2_GA_2852.UBUNTU10_64 FOSS edition
    1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
    1x Release 8.0.3.GA.5664.UBUNTU12.64 FOSS edition

  10. #10
    stegbth is offline Special Member
    Join Date
    Sep 2008
    Posts
    134
    Rep Power
    6

    Default

    still no luck.
    everything resolvs now to zimbra-mydom.mydomain.de.

    why or what url is needed, when the connection from zmmailbox is done via localhost?

    regards
    thomas
    zmcontrol -v
    1x Release 6.0.10_GA_2692.UBUNTU8_64 NETWORK edition.
    1x Release 6.0.14_GA_2928.UBUNTU8_64 NETWORK edition
    2x Release 7.1.3_GA_3346.UBUNTU10_64 NETWORK edition, Patch 7.1.3_P1
    1x Release 8.0.2.GA.5569.UBUNTU12.64 NETWORK edition

    2x Release 6.0.10_GA_2692.UBUNTU8_64 FOSS edition
    2x Release 7.2.2_GA_2852.UBUNTU10_64 FOSS edition
    1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
    1x Release 8.0.3.GA.5664.UBUNTU12.64 FOSS edition

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to backup user database only
    By jama in forum Administrators
    Replies: 12
    Last Post: 03-02-2012, 07:57 AM
  2. Proofing Modified Backup Script
    By dkbk in forum Administrators
    Replies: 0
    Last Post: 11-26-2009, 12:52 PM
  3. Single user migrate (full data) in FOSS
    By VS_onD in forum Administrators
    Replies: 0
    Last Post: 08-30-2008, 02:55 AM
  4. Zimbra 5 Network Edition, Backup & restore question
    By gilus in forum Administrators
    Replies: 0
    Last Post: 05-12-2008, 10:11 AM
  5. zimbra backup and restore - open source edition
    By kmuralidharan in forum Administrators
    Replies: 5
    Last Post: 08-23-2007, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •