//BackUpServer/ZM /mnt/ZM cifs user,uid=500,rw,suid,username=ZimbraBackUp,password=123123 0 0
$ mount -t cifs //BackUpServer/ZM /mnt/ZM -o user=ZimbraBackUp,password=123123
mount: wrong fs type, bad option, bad superblock on //BackUpServer1/ZM/, missing codepage or helper program, or other error (for several filesystems (eg nfs, cifs) you might need a /sbin/mount.<type> helper program) In some cases useful info is found in syslog - try dmesg | tail or so.
$ yum install cifs-utils
#!/bin/bash #Куда положить бэкап Path="/mnt/ZM/BackUps" #Куда положить архив бэкапа ArchPath="/mnt/ZM/Archive" #Куда положить месячный бэкап MPath="/mnt/ZM/Mounthly" #Название домена Zimbra ZDomain="zimbramail.home.local" #Список ящиков MBoxes="/mnt/ZM/MBoxesList" #Текущая дата CDate=$(date +%d-%m-%Y) #Запоминаем день месяца MDay=$(date +%d) #Куда писать логи log="/mnt/ZM/BackUpLog.txt" echo -en "BackUp ALL MailBoxes started in $(date +%T)\n" >> $log #Проверка не существования каталога для резервного копирования if [ ! -d $Path ]; then #Создание каталога хранения резервных копий echo "Создание каталога хранения резервных копий..." mkdir -p $Path if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "BackUp dirctory was created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "BackUp dirctory was NOT created in $(date +%T)\n" >> $log fi else echo "Каталог хранения резервных копий существует, проверка существования каталога на сегодняшнее число..." fi #Првоерка не существования каталога на сегодняшнюю дату if [ ! -d $Path/$CDate ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo #Создание каталога хранения резервных копий на сегодняшнее число echo "Создание каталога хранения резервных копий на сегодняшнее число..." mkdir -p $Path/$CDate if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "BackUp CDate dirctory was created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "BackUp CDate dirctory was NOT created in $(date +%T)\n" >> $log fi else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo "Каталог хранения резервных копий существует, запись списка ящиков в файл..." fi #Запись списка ящиков в файл /opt/zimbra/bin/zmprov -l gaa $ZDomain > $MBoxes #Вывод результата записи списка if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Mail Boxes list created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Mail Box list is NOT created! in $(date +%T)\n" >> $log exit fi #создание резервных копий каждого ящика из списка for MailBox in $( cat $MBoxes); do echo "Создание резервной копии ящика $MailBox..." /opt/zimbra/bin/zmmailbox -z -m $MailBox getRestUrl "//?fmt=tgz" > $Path/$CDate/$MailBox if [ $? -eq 0 ]; then #Вывод результата создания резервной копии для каждого ящика echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Mail Box $MailBox BackUp created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Mail Box $MailBox BackUp is NOT created! in $(date +%T)\n" >> $log fi done #Очищаем файл со списком ящиков echo "Очистка файла со споском ящиков..." echo -n > $MBoxes if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "File $MBoxes clear\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "File $MBoxes can NOT be cleared\n" >> $log fi #Создание архива и работа с архивами #Проверка не существования каталога для архивирвоания if [ ! -d $ArchPath ]; then #Создание каталога хранения архивов echo "Создание каталога хранения архивов..." mkdir -p $ArchPath if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Archive dirctory was created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Archive dirctory was NOT created in $(date +%T)\n" >> $log fi else echo "Каталог хранения архивов существует, архививрование..." fi tar -czf $ArchPath/$CDate.tar $Path/$CDate if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Archive created in $(date +%T)\n" >> $log #Каждое первое число месяца копирование архива на долгосрочное хранение if [ "$MDay" = 1 ]; then #Проверка существования каталога хранения долгосрочных архивов if [ ! -d $ArchPath ]; then #Создание каталога хранения долговрочных архивов echo "Создание каталога хранения долгосроных архивов..." mkdir -p $ArchPath if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Long saving dirctory was created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Long saving dirctory was NOT created in $(date +%T)\n" >> $log fi else #Каталог существует echo "Каталог долгосрочного хранения архивов существует, копирование архива на долгосрочное хранение..." fi cp $ArchPath/$CDate.tgz $MPath/$CDate if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Archive is copied in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Archive is NOT copied in $(date +%T)\n" >> $log fi echo "Удаление старых резервных копий (старше 1 недели)..." #Удаление каталогов, содержащих резервные копии, старше недели find $Path -atime +7 | xargs rm -d if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Old BackUps files was deleted\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Old BackUps files is NOT deleted in $(date +%T)\n" >> $log fi #Удаление старых архивов бэкапов (старше 2 месяцев) echo "Удаление старых архивов резервных копий (старше 2 месяцев)..." find $Path -atime +61 | xargs rm -f if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Old BackUps archives was deleted\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Old BackUps archives is NOT deleted in $(date +%T)\n" >> $log fi fi else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Archive is NOT created in $(date +%T)\n" >> $log fi echo "BackUp job finished in $(date +%T)" #запись в лог-файл времени окончания резервного копирования echo -en "BackUp job finished in $(date +%T) $(date +%T)\n" >> $log echo -en "_____________________________________________\n" >> $log
#!/bin/bash #Куда положить бэкап Path="/mnt/ZM/BackUps" #Куда положить архив бэкапа ArchPath="/mnt/ZM/Archive" #Название домена Zimbra ZDomain="zimbramail.home.local" #Список ящиков MBoxes="/mnt/ZM/MBoxesList" #Текущая дата CDate=$(date +%d-%m-%Y) #Куда писать логи log="/mnt/ZM/BackUpLog.txt" read -p "Введите имя почтового ящика (без указания домена), или ALL для резервного копирования всех почтовых ящиков: " A if [[ "$A" = "ALL" || "$A" = "all" ]]; then echo -en "BackUp started in $(date +%T)\n" >> $log #Запись списка ящиков в файл echo "Запись списка ящиков в файл..." /opt/zimbra/bin/zmprov -l gaa $ZDomain > $MBoxes if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Mail Boxes list created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Mail Box list is NOT created! in $(date +%T)\n" >> $log exit fi if ! [ -d $Path/$Date ]; then #Создание каталога резервного копирования mkdir -p $Path/$CDate/ echo -en "BackUp directory created in $(date +%T)\n" >> $log else #Создание резервных копий каждого ящика из списка echo "Создание резервных копий каждого ящика из списка" for MailBox in $( cat $MBoxes); do echo "Создание резервной копии ящика $MailBox..." /opt/zimbra/bin/zmmailbox -z -m $MailBox getRestUrl "//?fmt=tgz" > $Path/$CDate/$MailBox if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Mail Box $MailBox BackUp created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Mail Box $MailBox BackUp is NOT created! in $(date +%T)\n" >> $log fi done fi else MailBox="$A@$ZDomain" #Проверка существования запрошенного ящика echo "Проверка существования запрошенного ящика..." Result=$(/opt/zimbra/bin/zmprov getMailboxInfo $MailBox) if [ $? -eq 0 ]; then #Запрошенный ящик существует echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo "Запрошенный ящик $MailBox существует, резервное копирование..." echo -en "Required Mail Box $MailBox exist $(date +%T)\n" >> $log #Проверка существования каталога для резервного копирования if ! [ -d $Path/$Date ]; then #Создание резервной копии ящика mkdir -p $Path/$CDate/ echo -en "BackUp directory created in $(date +%T)\n" >> $log else #Создание резервной копии ящика $MailBox /opt/zimbra/bin/zmmailbox -z -m $MailBox getRestUrl "//?fmt=tgz" > $Path/$CDate/$MailBox if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Mail Box $MailBox BackUp created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Mail Box $MailBox BackUp is NOT created! in $(date +%T)\n" >> $log fi fi else #Запрошенный ящик не существовует - выход echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo "Запрошенный ящик $MailBox не существует. Завершение работы скрипта" echo -en "Required Mail Box $MailBox is not exist\n" >> $log exit fi fi read -p "Хотите запустить архивацию резервной копии ящика $MailBox? [N]: " F if [[ "$F" = "Y" || "$F" = "y" ]]; then #Проверка не существования каталога для архивирвоания if [ ! -d $ArchPath ]; then #Создание каталога хранения резервных копий echo "Создание каталога хранения архивов..." mkdir -p $ArchPath if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Archive dirctory was created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Archive dirctory was NOT created in $(date +%T)\n" >> $log fi else echo "Каталог хранения архивов существует, архививрование..." fi #Создание архива резервной копии echo "Архивирование резервной копии..." if [[ "$A" = "ALL" || "$A" = "all" ]]; then tar -czf $ArchPath/$CDate.tar $Path/$CDate if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Archive created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Archive is NOT created in $(date +%T)\n" >> $log fi else tar -czf $ArchPath/$MailBox.tar $Path/$CDate/$MailBox if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Archive created in $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Archive is NOT created in $(date +%T)\n" >> $log fi fi else echo "Архив создан не будет" echo -en "User decline archive creating\n" >> $log fi #Очищаем файл со списком ящиков echo "Очистка файла со споском ящиков..." echo -n > $MBoxes if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo fi echo "BackUp job finished in $(date +%T) $(date +%T)" #запись в лог-файл времени окончания резервного копирования echo -en "BackUp job finished in $(date +%T) $(date +%T)\n" >> $log echo -en "_____________________________________________\n" >> $log
#!/bin/bash #Где лежат бэкапы Path="/mnt/ZM/BackUps" #Название домена Zimbra ZDomain="zimbramail.home.local" #Список ящиков MBoxes="/mnt/ZM/MBoxesList" #Куда писать логи log="/mnt/ZM/RestoreLog.txt" read -p "Дата резервной копии, которую необходимо восстановить в формате 02-09-2001: " Date if ! [ -d $Path/$Date ]; then echo "Нет резервных копий на указанную дату." echo -en "No BackUp file at $Date $(date +%T)\n" > $log exit fi read -p "Введите имя почтового ящика (без указания домена), или ALL для восстановления всех почтовых ящиков на указанную дату: " A if [[ "$A" = "ALL" || "$A" = "all" ]]; then echo -en "Restore started in $(date +%T)\n" >> $log #Запись списка ящиков в файл ls "$Path/$Date" > $MBoxes for MailBox in $( cat $MBoxes); do #Проверка существования ящика echo "Проверка существования ящика $MailBox" Result=$(/opt/zimbra/bin/zmprov getMailboxInfo $MailBox) if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6) [OK]" echo echo -en "Start restore job for $MailBox $(date +%T)\n" >> $log echo "Ящик $MailBox существует. Восстановление..." else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Mail Box $MailBox does not exist, creating Mail Box $MailBox $(date +%T)\n" >> $log echo "Ящик $MailBox не существует. Создание ящика $MailBox..." #Проверка создания ящика Result=$(/opt/zimbra/bin/zmprov ca $MailBox 12345678 displayName "$MailBox") if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6) [OK]" echo echo -en "Mail Box $MailBox is created, starting restore $(date +%T)\n" >> $log echo "Ящик $MailBox создан успешно. Восстановление..." else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Can NOT create Mail Box $MailBox ! $(date +%T)\n" >> $log echo "Ящик $MailBox создать не удалось." fi fi #Восстановление ящика Result=$(/opt/zimbra/bin/zmmailbox -z -m $MailBox postRestURL "//?fmt=tgz&resolve=replace" $Path/$Date/$MailBox) if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Ящик $MailBox восстановлен в $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Ящик $MailBox НЕ восстановлен! $(date +%T)\n" >> $log fi done else #Проверка существования запрошенной резервной копии MailBox="$A@$ZDomain" if [ -a $Path/$Date/$MailBox ]; then #Проверка существования ящика echo "Проверка существования ящика $MailBox..." Result=$(/opt/zimbra/bin/zmprov getMailboxInfo $MailBox) if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6) [OK]" echo echo -en "Start restore job for $MailBox $(date +%T)\n" >> $log echo "Ящик $MailBox существует. Восстановление..." else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Mail Box $MailBox does not exist $(date +%T)\n" >> $log echo "Ящик $MailBox не существует." read -p "Хотите создать почтовый ящик с указанным именем и восстановить в него резервную копию? [N]: " B if [[ "$B" = "Y" || "$B" = "y" ]]; then echo "Создание почтового ящика $MailBox..." Result=$(/opt/zimbra/bin/zmprov ca $MailBox 12345678 displayName "$MailBox") #Проверка создания ящика if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6) [OK]" echo echo -en "Mail Box $MailBox is created, starting restore $(date +%T)\n" >> $log echo "Ящик $MailBox создан успешно. Восстановление..." else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo echo -en "Can NOT create Mail Box $MailBox ! $(date +%T)\n" >> $log echo "Ящик $MailBox создать не удалось. Завершение работы скрипта..." exit fi else #Ящик не будет создан, нечего восстанавливать. Выход echo "Ящик не будет создан. Завершение работы скрипта" exit fi fi #Восстановление ящика Result=$(/opt/zimbra/bin/zmmailbox -z -m $MailBox postRestURL "//?fmt=tgz&resolve=replace" $Path/$Date/$MailBox) if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo echo -en "Ящик $MailBox восстановлен в $(date +%T)\n" >> $log else echo -n "$(tput hpa $(tput cols))$(tput cub 6)[FAIL]" echo echo -en "Ящик $MailBox НЕ восстановлен! $(date +%T)\n" >> $log fi else #Запрошенной резервной копии не существует echo "Запрошенной резервной копии не существует. Завершение работы скрипта" echo -en "Required BackUp file is not exist\n" >> $log exit fi fi #Очищаем файл со списком ящиков echo "Очистка файла со споском ящиков..." Result(echo -n > $MBoxes) if [ $? -eq 0 ]; then echo -n "$(tput hpa $(tput cols))$(tput cub 6)[OK]" echo else echo -n "$(tput hpa $(tput cols))$(tput cub 6) [FAIL]" echo fi echo "BackUp job finished in $(date +%T) $(date +%T)" #запись в лог-файл времени окончания резервного копирования echo -en "Restore job complete in $(date +%T)\n" >> $log echo -en "____________________________________\n" >> $log
$ cat your-script.sh | tr -d '\r' > corrected-your-script.sh
$ yum install dos2unix $ dos2unix your-script.sh
$ chmod 0740 /opt/zimbra/BkUpRestScripts/FullBackUp.sh $ chmod 0740 /opt/zimbra/BkUpRestScripts/HandBackUp.sh $ chmod 0740 /opt/zimbra/BkUpRestScripts/Restore.sh
10 0 * * * root /opt/zimbra/ BkUpRestScripts/FullBackUp.sh
Source: https://habr.com/ru/post/439728/