People’s demand for high-traffic applications and the need for Internet of Things (IoT) are enormous in smart cities. The amount of data generated by virtual reality, high-definition video, and other IoT applications is growing at an exponential rate that far exceeds our expectations, and the types of data are becoming more diverse. It has become critical to reliably accommodate IoT-based big data with reasonable resource allocation in optical backbone networks for smart cities. For the problem of reliable transmission and efficient resource allocation in optical backbone networks, a novel resource allocation and spectrum defragmentation mechanism for massive IoT traffic is presented in this paper. Firstly, a routing and spectrum allocation algorithm based on the distance-adaptive sharing protection mechanism (DASP) is proposed, to obtain sufficient protection and reduce the spectrum consumption. The DASP algorithm advocates applying different strategies to the resource allocation of the working and protection paths. Then, the protection path spectrum defragmentation algorithm based on OpenFlow is designed to improve spectrum utilization while providing shared protection for traffic demands. The lowest starting slot-index first (LSSF) algorithm is employed to remove and reconstruct the optical paths. Numerical results indicate that the proposal can effectively alleviate spectrum fragmentation and reduce the bandwidth-blocking probability by 44.68% compared with the traditional scheme.