Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-2010, 04:14 PM
Starter Member
 
Posts: 2
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 10:42 PM..
Reply With Quote
  #2 (permalink)  
Old 02-11-2010, 03:44 AM
New Member
 
Posts: 3
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
Reply With Quote
  #3 (permalink)  
Old 02-12-2010, 03:22 AM
Special Member
 
Posts: 117
Default

hi,

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

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

best regards
thomas
__________________
zmcontrol -v
2x 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 6.0.7_GA_2470.UBUNTU8_64 FOSS edition
1x Release 7.1.2_GA_3268.UBUNTU10_64 FOSS edition
2x Release 7.1.3_GA_3346.UBUNTU10_64 FOSS
1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
Reply With Quote
  #4 (permalink)  
Old 02-13-2010, 03:38 AM
New Member
 
Posts: 3
Default

stegbth,

which script do you use?
Reply With Quote
  #5 (permalink)  
Old 02-13-2010, 04:08 AM
Special Member
 
Posts: 117
Default

hi dudi,

i am running 5.0.18 on ubuntu 8.04amd64 with "zmtlsctl https"
the error comes, when running the following command
Quote:
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
2x 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 6.0.7_GA_2470.UBUNTU8_64 FOSS edition
1x Release 7.1.2_GA_3268.UBUNTU10_64 FOSS edition
2x Release 7.1.3_GA_3346.UBUNTU10_64 FOSS
1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
Reply With Quote
  #6 (permalink)  
Old 02-13-2010, 04:38 AM
New Member
 
Posts: 3
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.
__________________
dudi
http://dgk.or.id
Reply With Quote
  #7 (permalink)  
Old 02-13-2010, 05:49 AM
Special Member
 
Posts: 117
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,

Quote:
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
2x 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 6.0.7_GA_2470.UBUNTU8_64 FOSS edition
1x Release 7.1.2_GA_3268.UBUNTU10_64 FOSS edition
2x Release 7.1.3_GA_3346.UBUNTU10_64 FOSS
1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
Reply With Quote
  #8 (permalink)  
Old 02-13-2010, 05:59 AM
Zimbra Consultant & Moderator
 
Posts: 20,312
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
Reply With Quote
  #9 (permalink)  
Old 02-13-2010, 06:17 AM
Special Member
 
Posts: 117
Default

hi,

cat /etc/hosts
Quote:
192.168.23.3 zimbra-mydom.mydomain.de zimbra-mydom
127.0.0.1 localhost
cat /etc/resolv.conf
Quote:
domain haar.mydomain.de
search haar.mydomain.de
nameserver 192.168.23.96
dig mydomain.de mx
Quote:
mydomain.de. 604800 IN MX 100 zimbra-mydom.mydomain.de
dig mydomain.de any
Quote:
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`
Quote:
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
2x 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 6.0.7_GA_2470.UBUNTU8_64 FOSS edition
1x Release 7.1.2_GA_3268.UBUNTU10_64 FOSS edition
2x Release 7.1.3_GA_3346.UBUNTU10_64 FOSS
1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
Reply With Quote
  #10 (permalink)  
Old 02-13-2010, 07:10 AM
Special Member
 
Posts: 117
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
2x 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 6.0.7_GA_2470.UBUNTU8_64 FOSS edition
1x Release 7.1.2_GA_3268.UBUNTU10_64 FOSS edition
2x Release 7.1.3_GA_3346.UBUNTU10_64 FOSS
1x Release 7.1.4_GA_2555.UBUNTU10_64 FOSS
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.