diff --git a/.github/workflows/unit_test_linux_ubuntu.yaml b/.github/workflows/unit_test_linux_ubuntu.yaml index 055f80b..902d085 100644 --- a/.github/workflows/unit_test_linux_ubuntu.yaml +++ b/.github/workflows/unit_test_linux_ubuntu.yaml @@ -1580,9 +1580,25 @@ jobs: run: | echo "----------------------------------" - echo "Test backup manually" - echo "" - mo_ctl backup + echo "Set confs for auto backup" + mo_ctl set_conf BACKUP_CRON_SCHEDULE="* * * * *" + mo_ctl set_conf BACKUP_CLEAN_DAYS_BEFORE="0" + mo_ctl set_conf BACKUP_CLEAN_CRON_SCHEDULE="*/8 * * * *" + + + echo "----------------------------------" + echo "Enable auto backup and auto clean backup" + mo_ctl auto_backup enable + + echo "----------------------------------" + echo "Check auto backup and auto clean backup status" + mo_ctl auto_backup status + + echo "----------------------------------" + echo "wait 70s for next auto backup to be performed" + sleep 70 + + echo "----------------------------------" echo "Show backup path" ls -lth ${{ env.BACKUP_PATH }} for dir in `ls ${{ env.BACKUP_PATH }}`; do @@ -1593,6 +1609,7 @@ jobs: echo "----------------------------------" echo "Clean backup automatically" + mo_ctl auto_backup echo "Sleep 600s" sleep 600 @@ -1600,36 +1617,52 @@ jobs: ls -lth ${{ env.BACKUP_PATH }}/${RUN_MONTH}/ - for dir in `ls ${{ env.BACKUP_PATH }}${RUN_MONTH}/`; do - echo "----------------------------------" - echo "Listing files in ${{ env.BACKUP_PATH }}/${dir}/" - ls -lth ${{ env.BACKUP_PATH }}/${RUN_MONTH}/${dir}/ - done - - dir_count=`ls ${{ env.BACKUP_PATH }}/${RUN_MONTH}/ | wc -l` - if [[ ${dir_count} -ne 0 ]]; then - echo "dir_count: ${dir_count} is not 0, seems like auto_clean_old_backup has failed" - #exit 1 - fi - + echo "----------------------------------" echo "check log path ${MO_CTL_TOOL_LOG_PATH}/auto_backup/" ls -lth ${MO_CTL_TOOL_LOG_PATH}/auto_backup/ + + echo "----------------------------------" + echo "check auto_backup logs: cat ${MO_CTL_TOOL_LOG_PATH}/auto_backup/*" + cat ${MO_CTL_TOOL_LOG_PATH}/auto_backup/* + + echo "----------------------------------" echo "check log path ${MO_CTL_TOOL_LOG_PATH}/auto_clean_old_backup/" ls -lth ${MO_CTL_TOOL_LOG_PATH}/auto_clean_old_backup/ + + echo "----------------------------------" + echo "show auto_clean_old_backup logs: cat ${MO_CTL_TOOL_LOG_PATH}/auto_clean_old_backup/*" + cat ${MO_CTL_TOOL_LOG_PATH}/auto_clean_old_backup/* + + echo "----------------------------------" echo "check cron.d path and file" ls -lth /etc/cron.d/ + echo "----------------------------------" echo "content of file /etc/cron.d/mo_backup" cat /etc/cron.d/mo_backup + echo "----------------------------------" echo "content of file /etc/cron.d/mo_clean_old_backup" cat /etc/cron.d/mo_clean_old_backup + echo "----------------------------------" echo "Disabling auto_backup" mo_ctl auto_backup disable if ! mo_ctl auto_backup; then echo "auto_backup status failed as expected" fi + + for dir in `ls ${{ env.BACKUP_PATH }}/${RUN_MONTH}/`; do + echo "----------------------------------" + echo "Listing files in ${{ env.BACKUP_PATH }}/${RUN_MONTH}/${dir}/" + ls -lth ${{ env.BACKUP_PATH }}/${RUN_MONTH}/${dir}/ + done + + dir_count=`ls ${{ env.BACKUP_PATH }}/${RUN_MONTH}/ | wc -l` + if [[ ${dir_count} -ne 0 ]]; then + echo "dir_count: ${dir_count} is not 0, seems like auto_clean_old_backup has failed" + exit 1 + fi