หน้าเว็บ

วันอังคารที่ 28 พฤษภาคม พ.ศ. 2562

Zimbra :: Bash Backup Full Or increment .sh

Zimbra :: Bash Backup Full Or increment .sh

  1. echo "*******************************************************"
  2. echo "*     Zimbra - Backup all email accounts              *"
  3. echo "*******************************************************"
  4. Days=`date +%Y%m%d`;
  5. before="$(date +%s)"
  6.  
  7. cd /DATA/zimbra_backup
  8.  
  9. if [ $(date +%u) -eq '6' ]; then
  10.         rm sessions.txt
  11.         rm -r full*
  12.         rm -r inc*
  13.  
  14.         echo Start time of the full backup = $(date +%T)
  15.         su - zimbra -c "zmbkpose -f"
  16.         after="$(date +%s)"
  17.  
  18.         cp sessions.txt /DATA/zimbra_backup/BackupToQnap/
  19.         cp -r full-$Days* /DATA/zimbra_backup/BackupToQnap/
  20.  
  21.         #Zip File For Read Size Not Work. Full Disk#
  22.         #tar -pczf Zimbra_Full_$Days.tar.gz full-$Days* sessions.txt
  23.         #mv Zimbra_Ful_$Days.tar.gz /DATA/zimbra_backup/BackupToQnap/
  24.  
  25. #Old Code
  26.         #scp sessions.txt admin@192.168.0.218:/share/backup/
  27.         #scp -r full-$Days* admin@192.168.0.218:/share/backup/
  28.  
  29.         #scp sessions.txt admin@192.168.2.77:/share/Public/
  30.         #scp -r full-$Days* admin@192.168.2.77:/share/Public/
  31. else
  32.         echo Start time of the incremental backup = $(date +%T)
  33.         su - zimbra -c "zmbkpose -i"
  34.         after="$(date +%s)"
  35.  
  36.         tar -pczf Zimbra_Inc_$Days.tar.gz inc-$Days* sessions.txt
  37.         mv Zimbra_Inc_$Days.tar.gz /DATA/zimbra_backup/BackupToQnap/
  38.  
  39.         #cp sessions.txt /DATA/zimbra_backup/BackupToQnap/
  40.         #cp -r inc-$Days* /DATA/zimbra_backup/BackupToQnap/
  41.  
  42. #Old Code
  43.         #scp sessions.txt admin@192.168.0.218:/share/backup/
  44.         #scp -r inc-$Days* admin@192.168.0.218:/share/backup/
  45.  
  46.         #scp sessions.txt admin@192.168.2.77:/share/Public/
  47.         #scp -r inc-$Days* admin@192.168.2.77:/share/Public/
  48. fi
  49.  
  50. if [ $? -eq 0 ]; then
  51.     echo "*******************************************************"
  52.     echo "=== Transfer COMPLETED ==="
  53.     echo "*******************************************************"
  54. else
  55.     echo "*******************************************************"
  56.     echo "=== Transfer FAIL! ==="
  57.     echo "*******************************************************"
  58. fi
  59.  
  60. echo The process lasted = $(date +%T)
  61. # Calculating time
  62. elapsed="$(expr $after - $before)"
  63. hours=$(($elapsed / 3600))
  64. elapsed=$(($elapsed - $hours * 3600))
  65. minutes=$(($elapsed / 60))
  66. seconds=$(($elapsed - $minutes * 60))
  67. echo The complete backup lasted : "$hours hours $minutes minutes $seconds seconds"
  68. echo "****
***************************************************"

cronteb -e
  1. 10 21 * * 1-5 /DATA/zimbra_backup/autobackup.sh >> /DATA/zimbra_backup/autobackup.log 2>&1
  2. 00 18 * * 6  /DATA/zimbra_backup/autobackup.sh >> /DATA/zimbra_backup/autobackup.log 2>&1

ไม่มีความคิดเห็น:

แสดงความคิดเห็น