From e155b851d83e2bbe5a83c862637c42fc5ebe7e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?s=C3=A9bastien?= Date: Mon, 15 Jan 2024 14:58:19 +0100 Subject: [PATCH] =?UTF-8?q?=09nouveau=20fichier=C2=A0:=20zimbra/Migration/?= =?UTF-8?q?3=5Fexports=5Ffinal.sh=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20zimbra/Migration/3=5Fexports=5Fmailbox.sh=20=09nouv?= =?UTF-8?q?eau=20fichier=C2=A0:=20zimbra/Migration/4=5Fimports=5Fmailboxes?= =?UTF-8?q?.sh=20=09supprim=C3=A9=C2=A0:=20=20=20=20=20=20=20=20zimbra/Mig?= =?UTF-8?q?ration/5=5Fexport=5Ffiltres.sh=20=09supprim=C3=A9=C2=A0:=20=20?= =?UTF-8?q?=20=20=20=20=20=20zimbra/Migration/6=5Fimport=5Ffiltres.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zimbra/Migration/3_exports_final.sh | 19 ++++++++++++++ zimbra/Migration/3_exports_mailbox.sh | 6 ++--- zimbra/Migration/4_imports_mailboxes.sh | 35 +++++++++++++++++++++++++ zimbra/Migration/5_export_filtres.sh | 5 ---- zimbra/Migration/6_import_filtres.sh | 0 5 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 zimbra/Migration/3_exports_final.sh create mode 100644 zimbra/Migration/4_imports_mailboxes.sh delete mode 100644 zimbra/Migration/5_export_filtres.sh delete mode 100644 zimbra/Migration/6_import_filtres.sh diff --git a/zimbra/Migration/3_exports_final.sh b/zimbra/Migration/3_exports_final.sh new file mode 100644 index 0000000..3155f14 --- /dev/null +++ b/zimbra/Migration/3_exports_final.sh @@ -0,0 +1,19 @@ +#!/bin/bash +RCODE=$? + +echo "Export mailboxes :" +for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; +do +echo "Exporting mailbox $user"; zmmailbox -z -t 0 -m $user getRestURL --startTime $(date -d '-3 day' +%Y/%m/%d) --endTime $(date -d '+1 day' +%Y/%m/%d) -u "https://127.0.0.1:7071" "//?fmt=tgz&resolve=modify" > /opt/zimbra/nfsbackup/migration/archives/$user.tgz ; +done + +if [ $RCODE -eq 1 ]; then + echo "erreur dans l'export'" + exit 1; +fi + +if [ $RCODE -eq 0 ]; then + echo "export terminée !!!!" + echo "Passez à l'import des datas sur serveur dest" + exit; +fi diff --git a/zimbra/Migration/3_exports_mailbox.sh b/zimbra/Migration/3_exports_mailbox.sh index 1beda2d..d4af489 100644 --- a/zimbra/Migration/3_exports_mailbox.sh +++ b/zimbra/Migration/3_exports_mailbox.sh @@ -4,7 +4,7 @@ RCODE=$? echo "Export mailboxes :" for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do -echo "Exporting mailbox $user" ;zmmailbox -z -t 0 -m $user getRestURL -u "https://127.0.0.1:7071" "//?fmt=tgz" > /opt/zimbra/nfsbackup/migration/archives/$user.tgz ; +echo "Exporting mailbox : $user" ;zmmailbox -z -t 0 -m $user getRestURL -u "https://127.0.0.1:7071" "//?fmt=tgz" > /opt/zimbra/nfsbackup/migration/archives/$user.tgz ; done if [ $RCODE -eq 1 ]; then @@ -14,7 +14,7 @@ fi if [ $RCODE -eq 0 ]; then echo "Export des Filtres" - for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do zmprov ga $user zimbraMailSieveScript > filters/$user-filters.txt ;done + for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do echo "Exporting Filters : $user" ; zmprov ga $user zimbraMailSieveScript > filters/$user-filters.txt ;done sed -i -e "1d" /opt/zimbra/nfsbackup/migration/filters/* sed -i -e 's/zimbraMailSieveScript: //g' /opt/zimbra/nfsbackup/migration/filters/* if [ $RCODE -eq 1 ]; then @@ -23,7 +23,7 @@ if [ $RCODE -eq 0 ]; then fi if [ $RCODE -eq 0 ]; then echo "Export des signatures" - for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do zmprov ga $user zimbraPrefMailSignatureHTML > sig/$user-sig.txt ;done + for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do echo "Exporting Default Signature : $user" ; zmprov ga $user zimbraPrefMailSignatureHTML > sig/$user-sig.txt ;done sed -i -e "1d" /opt/zimbra/nfsbackup/migration/sig/* sed -i -e 's/zimbraMailSieveScript: //g' /opt/zimbra/nfsbackup/migration/sig/* if [ $RCODE -eq 1 ]; then diff --git a/zimbra/Migration/4_imports_mailboxes.sh b/zimbra/Migration/4_imports_mailboxes.sh new file mode 100644 index 0000000..61f174e --- /dev/null +++ b/zimbra/Migration/4_imports_mailboxes.sh @@ -0,0 +1,35 @@ +#!/bin/bash +RCODE=$? + +for mailbox in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; +do +zmmailbox -z -t 0 -m $mailbox postRestURL -u "https://127.0.0.1:7071" "//?fmt=tgz&resolve=modify" ./$mailbox.tgz ; echo "$mailbox - done "; +done + +if [ $RCODE -eq 1 ]; then + echo "erreur dans l'import'" + exit 1; +fi + +if [ $RCODE -eq 0 ]; then + echo "Import des Filtres" + for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do echo "Importation des filtres : $user"; zmprov ma $user zimbraMailSieveScript "`cat /opt/zimbra/nfsbackup/migration/filters/$user-filters.txt`";done + if [ $RCODE -eq 1 ]; then + echo "erreur dans l'import des filtres'" + exit 1; + fi + if [ $RCODE -eq 0 ]; then + echo "Import des signatures" + for user in `cat /opt/zimbra/nfsbackup/migration/accounts/users.txt`; do echo "Import des signatures: $user"; zmprov csig $user default zimbraPrefMailSignatureHTML "`cat /opt/zimbra/nfsbackup/migration/sig/$user-sig.txt`";done + if [ $RCODE -eq 1 ]; then + if [ $RCODE -eq 1 ]; then + echo "erreur dans l'import des Signatures'" + exit 1; + fi + if [ $RCODE -eq 0 ]; then + echo "Import terminée'" + exit; + fi + fi + +fi \ No newline at end of file diff --git a/zimbra/Migration/5_export_filtres.sh b/zimbra/Migration/5_export_filtres.sh deleted file mode 100644 index c1e1d82..0000000 --- a/zimbra/Migration/5_export_filtres.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd - -for user in `cat ../accounts/users.txt`; do zmprov ga $user | grep zimbraMailSieveScript | awk '{print $2}' | tee -a $user.txt ;echo $i ;done \ No newline at end of file diff --git a/zimbra/Migration/6_import_filtres.sh b/zimbra/Migration/6_import_filtres.sh deleted file mode 100644 index e69de29..0000000