Updated backup script logic