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