davromaniak / zimbashckup

ZimBashckup : Zimbra Backup Script in Bash
GNU General Public License v2.0
35 stars 17 forks source link

java.net.ConnectException Connection refused #1

Open kamzata opened 10 years ago

kamzata commented 10 years ago

I run Zimbra on Ubuntu 12.04. Command is execute on the same Zimbra server


zimbra@myserver:/$ bashzimbashckup.sh -v

ERROR: zclient.IO_ERROR (Unable to get REST resource from http://mail.domain1.tld/home/galsync@domain1.tld/_zimbra?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /_zimbra, skipping

ERROR: zclient.IO_ERROR (Unable to get REST resource from http://mail.domain2.tld/home/galsync@domain2.tld/_zimbra?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /_zimbra, skipping

ERROR: zclient.IO_ERROR (Unable to get REST resource from http://mail.domain3.tld/home/galsync@domain3.tld/_zimbra?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /_zimbra, skipping

....


Further, I had to convert all ` with ' in the entire script.

davromaniak commented 10 years ago

Hi Kamzata.

Thanks for reporting the issue.

First, can you give some information on your zimbra setup (run 'zmcontrol -v' as the zimbra user) ?

Do you run the script directly from the zimbra server ?

Does "zmprov -l gaa" command launched as the zimbra user gives you anything ?

I don't understand why you need to change all by ' in the entire script, are used by bash to perform command substitution, so without `, the script won't work at all because they are used for the getopt part, which is very important.

Don't hesitate to provide as much information as you can. It will be easier for me to spot the problem here.

Thanks.

kamzata commented 10 years ago

zimbra@myserver:/$ zmcontrol -v Release 8.0.7.GA.6021.UBUNTU12.64 UBUNTU12_64 FOSS edition.

Yes, I run script directly on zimbra server.


zimbra@myserver:/$ zmprov -l gaa info@domain1.com info@domain2.com .....

Yes, it output list of all email address


About substitution, if I leave ` and I run the script it return me an error like:

"Error in line 165... don't expect EOF" "Error in line 166... don't expect EOF"

davromaniak commented 10 years ago

Ok.

I see the issue.

It only appears when the script is launched by the zimbra user. When launching as root, there's no issue.

The last commit (1ab5f7c0d5c4ed091fc8978ad25578203339f284) corrects this issue.

Thanks for reporting the issue and sorry for the inconvenience.

kamzata commented 10 years ago

Thank you for reply. No, even launching script by root nothing change, it show me same problems.

davromaniak commented 10 years ago

Ok, strange because the issue was on the part which is only run when the script is directly run using the zimbra user.

Can you confirm it's working now ?

Thanks.

kamzata commented 10 years ago

This is the output with the latest version you commit:

root@myserver:/# zimbashckup.sh -v galsync@domain1.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain1.com/filters.sieve info@domain2.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/info@domain2.com/filters.sieve galsync@domain2.com /_zimbra => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain2.com/_zimbra.tar ERROR: zclient.IO_ERROR (Unable to get REST resource from http://mail.domain2.com/home/galsync@domain2.com/_zimbra?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /zimbra, skipping _ Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain2.com/filters.sieve vendite@domain2.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/vendite@domain2.com/filters.sieve supporto@domain2.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/supporto@domain2.com/filters.sieve admin@domain3.com /Inbox => /opt/zimbra/backup/mailbox/2014/09/03/admin@domain3.com/Inbox.tar Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/admin@domain3.com/filters.sieve claudio@domain3.com /Emailed Contacts => /opt/zimbra/backup/mailbox/2014/09/03/claudio@domain3.com/Emailed Contacts.tar /Inbox => /opt/zimbra/backup/mailbox/2014/09/03/claudio@domain3.com/Inbox.tar /Sent => /opt/zimbra/backup/mailbox/2014/09/03/claudio@domain3.com/Sent.tar Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/claudio@domain3.com/filters.sieve fabrizio@domain3.com /Emailed Contacts => /opt/zimbra/backup/mailbox/2014/09/03/fabrizio@domain3.com/Emailed Contacts.tar /Inbox => /opt/zimbra/backup/mailbox/2014/09/03/fabrizio@domain3.com/Inbox.tar /Sent => /opt/zimbra/backup/mailbox/2014/09/03/fabrizio@domain3.com/Sent.tar Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/fabrizio@domain3.com/filters.sieve ham.zklkasxj@domain3.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/ham.zklkasxj@domain3.com/filters.sieve spam.dhsk4dqd@domain3.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/spam.dhsk4dqd@domain3.com/filters.sieve galsync.xpxdcsd5wu@domain3.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/galsync.xpxdcsd5wu@domain3.com/filters.sieve virus-quarantine.fihed1fyd@domain3.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/virus-quarantine.fihed1fyd@domain3.com/filters.sieve info@domain4.com /Emailed Contacts => /opt/zimbra/backup/mailbox/2014/09/03/info@domain4.com/Emailed Contacts.tar ERROR: zclient.IOERROR (Unable to get REST resource from http://mail.domain4.com/home/info@domain4.com/Emailed%20Contacts?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /Emailed Contacts, skipping /Inbox => /opt/zimbra/backup/mailbox/2014/09/03/info@domain4.com/Inbox.tar ERROR: zclient.IOERROR (Unable to get REST resource from http://mail.domain4.com/home/info@domain4.com/Inbox?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /Inbox, skipping /Sent => /opt/zimbra/backup/mailbox/2014/09/03/info@domain4.com/Sent.tar ERROR: zclient.IOERROR (Unable to get REST resource from http://mail.domain4.com/home/info@domain4.com/Sent?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /Sent, skipping Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/info@domain4.com/filters.sieve test@domain4.com /Inbox => /opt/zimbra/backup/mailbox/2014/09/03/test@domain4.com/Inbox.tar ERROR: zclient.IOERROR (Unable to get REST resource from http://mail.domain4.com/home/test@domain4.com/Inbox?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /Inbox, skipping Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/test@domain4.com/filters.sieve galsync@domain4.com /_zimbra => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain4.com/_zimbra.tar ERROR: zclient.IO_ERROR (Unable to get REST resource from http://mail.domain4.com/home/galsync@domain4.com/_zimbra?fmt=tar: Connection refused) (cause: java.net.ConnectException Connection refused) ERROR : Unable to backup folder /zimbra, skipping _ Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain4.com/filters.sieve galsync@domain5.com Nothing to backup here... Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain5.com/filters.sieve galsync@domain6.com Nothing to backup here... _ Mail filters (in sieve format) => /opt/zimbra/backup/mailbox/2014/09/03/galsync@domain6.com/filters.sieve

kamzata commented 10 years ago

I tried only backup function, I haven't tried restore backups yet

davromaniak commented 10 years ago

Hi again.

So now we don't have the bash error and I see more clearly the problem you have.

Apparently, you are running a multiple server configuration, and the issue is you can't reach the REST API on those servers (the error messages on Zimbra tools are quite wrong and "Connection refused" simply means zmmailbox cant reach the REST API).

As the zimbra user, list all servers with the command zmprov gas and try to use the ping command on them.

If the ping command is answering something like "ping: unknown host...", then try adding the ip and host combination to your /etc/hosts file and then try the following command : /opt/zimbra/bin/zmmailbox -z -m test@domain4.com getAllFolders

This is the kind of command used my the script, so if it's succeed, there's a big chance of the script succeeding.

By the way, I'm reopening this issue.

Thanks.

kamzata commented 10 years ago

zimbra@myserver:/$ zmprov gas mail.myserver.com zimbra@myserver:/$ ping mail.myserver.com PING mail.myserver.com (192.168.1.53) 56(84) bytes of data. 64 bytes from mail.myserver.com (192.168.1.53): icmp_req=1 ttl=64 time=0.017 ms 64 bytes from mail.myserver.com (192.168.1.53): icmp_req=2 ttl=64 time=0.039 ms 64 bytes from mail.myserver.com (192.168.1.53): icmp_req=3 ttl=64 time=0.042 ms

I have only one server on the same machines: mail.myserver.com

davromaniak commented 10 years ago

Ok, strange, because zmmailbox uses this value to find the REST API server to query to.

Could you try explicitely add the server to the last command I gave by adding "-h http://192.168.1.53" like /opt/zimbra/bin/zmmailbox -h http://192.168.1.53 -z -m test@domain4.com getAllFolders ?

If this works, maybe there's some misconfiguration on your zimbra instance.

Thanks.

kamzata commented 10 years ago

zimbra@myserver:/$ zmmailbox -u http://192.168.1.53 -z -m test@domain4.com getAllFolders Id View Unread Msg Count Path


     1  unkn           0           0  /
    16  docu           0           0  /Briefcase
    10  appo           0           0  /Calendar
    14  mess           0           0  /Chats
     7  cont           0           0  /Contacts
     6  mess           0           0  /Drafts
    13  cont           0           0  /Emailed Contacts
     2  mess           0           3  /Inbox
     4  mess           0           0  /Junk
     5  mess           0           0  /Sent
    15  task           0           0  /Tasks
     3  unkn           0           0  /Trash
davromaniak commented 10 years ago

Ok, so when the URL is set, it works.

Could you run the following command : /opt/zimbra/bin/zmmailbox -d -z -m test@domain4.com getAllFolders ?

It will fail, but you will see some debug "SOAP RECEIVE" and "SOAP SEND", could you paste these parts ?

Thanks.

kamzata commented 10 years ago

zimbra@myserver:/$ zmmailbox -d -z -m test@domain4.com ========== SOAP SEND ==========

soap:Header /soap:Header soap:Body zimbra aWvirwtyw /soap:Body # /soap:Envelope ======== SOAP RECEIVE ========= soap:Header /soap:Header soap:Body 0_4b1b2986bcdca283a15a71cdf5d3f6f35dd9663a_69643d33363a65306661666438392d313336302d313164392d383636312d3030306139356439386566323b6578703d31333a313430393831353438313130323b61646d696e3d313a313b747970653d363a7a696d6272613b 43200000 /soap:Body /soap:Envelope =============================== (140 msecs) ========== SOAP SEND ========== soap:Header 0_4b1b2986bcdca283a15a71cdf5d3f6f35dd9663a_69643d33363a65306661666438392d313336302d313164392d383636312d3030306139356439386566323b6578703d31333a313430393831353438313130323b61646d696e3d313a313b747970653d363a7a696d6272613b /soap:Header soap:Body test@domain4.com /soap:Body # /soap:Envelope ======== SOAP RECEIVE ========= soap:Header /soap:Header soap:Body test@domain4.com 33e24081-8c91-49cb-98a7-868276af0c1a mail.myserver.it http://mail.myserver.it:80/service/soap/ https://mail.myserver.it:7071/service/admin/soap/ http://mail.domain4.com /soap:Body /soap:Envelope =============================== (18 msecs) ========== SOAP SEND ========== soap:Header 0_4b1b2986bcdca283a15a71cdf5d3f6f35dd9663a_69643d33363a65306661666438392d313336302d313164392d383636312d3030306139356439386566323b6578703d31333a313430393831353438313130323b61646d696e3d313a313b747970653d363a7a696d6272613b /soap:Header soap:Body test@domain4.com /soap:Body # /soap:Envelope ======== SOAP RECEIVE ========= soap:Header /soap:Header soap:Body 0_f26c86183f2ac47c01651a0e18237806a2324add_69643d33363a33336532343038312d386339312d343963622d393861372d3836383237366166306331613b6578703d31333a313430393835383638323938363b6169643d33363a65306661666438392d313336302d313164392d383636312d3030306139356439386566323b76763d313a323b747970653d363a7a696d6272613b 86400000 /soap:Body /soap:Envelope =============================== (5 msecs) ========== SOAP SEND ========== soap:Header 0_f26c86183f2ac47c01651a0e18237806a2324add_69643d33363a33336532343038312d386339312d343963622d393861372d3836383237366166306331613b6578703d31333a313430393835383638323938363b6169643d33363a65306661666438392d313336302d313164392d383636312d3030306139356439386566323b76763d313a323b747970653d363a7a696d6272613b test@domain4.com /soap:Header soap:Body /soap:Body # /soap:Envelope ======== SOAP RECEIVE ========= soap:Header 174284 8.0.7_GA_6021 20140408123908 20140408-1242 FOSS /soap:Header soap:Body /soap:Body /soap:Envelope =============================== (64 msecs) ========== SOAP SEND ========== soap:Header 0_f26c86183f2ac47c01651a0e18237806a2324add_69643d33363a33336532343038312d386339312d343963622d393861372d3836383237366166306331613b6578703d31333a313430393835383638323938363b6169643d33363a65306661666438392d313336302d313164392d383636312d3030306139356439386566323b76763d313a323b747970653d363a7a696d6272613b test@domain4.com /soap:Header soap:Body /soap:Body # /soap:Envelope ======== SOAP RECEIVE ========= soap:Header 174284 /soap:Header soap:Body 8.0.7_GA_6021 20140408123908 20140408-1242 FOSS 33e24081-8c91-49cb-98a7-868276af0c1a test@domain4.com 75d852edb249a6d3103629e1de60b3fa 86399921 1 http://mail.domain4.com/home/test@domain4.com 8478 1404067710000 1404067710000 0 FALSE FALSE TRUE TRUE includeBody TRUE times new roman, new york, times, serif html it FALSE list TRUE -PT15M TRUE 60m TRUE default 7d dateDesc FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE 8 TRUE TRUE FALSE outlook TRUE 1h conversation FALSE TRUE FALSE 25 FALSE TRUE FALSE #000000 Europe/Berlin right FALSE FALSE FALSE TRUE FALSE right 0 serenity TRUE TRUE 500ms TRUE FALSE 1:N:0800:1700,2:Y:0800:1700,3:Y:0800:1700,4:Y:0800:1700,5:Y:0800:1700,6:Y:0800:1700,7:N:0800:1700 right TRUE TRUE FALSE TRUE TRUE FALSE TRUE TRUE FALSE TRUE 30s TRUE TRUE TRUE FALSE FALSE 5 25 TRUE FALSE 10 delete FALSE FALSE FALSE TRUE FALSE next dedupeNone TRUE workWeek FALSE 0 ALL > TRUE TRUE FALSE bottom 50 FALSE 0 TRUE sent TRUE TRUE TRUE TRUE 0 FALSE TRUE 12pt advanced FALSE 0 never TRUE 12pt TRUE FALSE 25 includeBody 1 in:inbox FALSE TRUE 0 18 TRUE TRUE away FALSE briefcase FALSE public TRUE FALSE TRUE 100 TRUE !com_zimbra_email !com_zimbra_url !com_zimbra_date +com_zimbra_webex +com_zimbra_ymemoticons +com_zimbra_srchhighlighter +com_zimbra_phone !com_zimbra_attachcontacts !com_zimbra_attachmail 500 TRUE TRUE FALSE TRUE 0 FALSE TRUE 1m FALSE TRUE TRUE 0 0 TRUE 4096 0 it TRUE TRUE 30d FALSE FALSE TRUE FALSE 90d TRUE TRUE 20 100 FALSE TRUE 30d 0 10240000 TRUE FALSE FALSE TRUE TRUE FALSE FALSE 20 TRUE FALSE 70 FALSE 1m 30d 0 20 FALSE TRUE TRUE TRUE 0 0 TRUE 0 100 Facebook LinkedIn SocialCast Twitter 100 TRUE 30d test TRUE FALSE 100 TRUE TRUE FALSE TRUE 33e24081-8c91-49cb-98a7-868276af0c1a 12h TRUE TRUE TRUE 536870912 FALSE FALSE TRUE 10485760 0 TRUE TRUE 64 1m TRUE FALSE TRUE TRUE FALSE TRUE 10000 TRUE TRUE TRUE TRUE 10240 TRUE TRUE FALSE FALSE FALSE 0 TRUE test test TRUE 0 TRUE 20 10m 1m 2m 30m 5m 12h FALSE zimbra FALSE 0m TRUE FALSE example FALSE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE FALSE FALSE TRUE 10000 TRUE TRUE FALSE TRUE TRUE FALSE test2@domain4.com 1m TRUE FALSE TRUE 100 1 TRUE TRUE test test 6 TRUE 33e24081-8c91-49cb-98a7-868276af0c1a > TRUE sent test test includeBody same outlook DEFAULT includeBody 20140625012448Z test@domain4.com http://mail.domain4.com/service/soap/ http://mail.domain4.com /soap:Body /soap:Envelope =============================== (38 msecs) mailbox: test@domain4.com, size: 8.28 KB, messages: 3, unread: 0 authenticated as test@domain4.com mbox test@domain4.com>
davromaniak commented 10 years ago

Here we are :).

Even though the XML markup was eaten by github, I can see some problems.

You see those 3 lines ? : http://mail.forlini.it:80/service/soap/ https://mail.forlini.it:7071/service/admin/soap/ http://mail.domain4.com

Actually, those 3 lines should contain "mail.myserver.com" instead of "mail.forlini.it" and "mail.domain4.com".

I think you imported the Zimbra you have in production to a virtual machine to perform some tests, and it seems Zimbra kept some "old" configuration settings.

You have 2 ways to correct this :

Thanks.

kamzata commented 10 years ago

Sorry, I forget to mask my server name so I edited previous post. I haven't imported but yes, I'm running Zimbra on a OpenVZ CT.

Anyway... Hit, my fault! I added entry "mail.domain4.com" on my /etc/hosts file just to try if it works and... it works!

Now I'm trying to do "more clean way" that you suggest.

Thank you

kamzata commented 10 years ago

How restore backups works?

davromaniak commented 10 years ago

Hi. For the restore process, it has to be performed with the zmmailbox tool (http://wiki.zimbra.com/wiki/Zmmailbox) with the postRestURL command.

Something like /opt/zimbra/bin/zmmailbox -z -m user@domain.com -t 0 postRestURL “//?fmt=tgz&resolve=reset" account.tgz should work, but be carefull (mostly with the resolve parameter, when set to "reset", it will empty the destination mailbox and replace it with the TGZ dump. If you can work with a test zimbra, don't hesitate to test it, I've done a lot of mistakes when testing.

It's scheduled to include a restore functionnality in zimbashckup, but I haven't the time to write it.

But I will add a section in the README file about restoring backups.

Thanks.

davromaniak commented 10 years ago

I just added a section on the README file.

kamzata commented 10 years ago

Great! I'll try to restore backups.

muguiwara commented 9 years ago

Hi, I performed the steps above and get the following error: zmmailbox z -m user@domain.com getRestURL '/ ? fmt = tgz '> user@domain.com.tgz ERROR: zclient.IO_ERROR ( Unable to get REST resource from http://server1.domain.com/home/user@domain.com/?fmt=tgz : Connection refused) (cause : java.net .ConnectException Connection refused) Regards,