To avoid the copy_to on optimize!, use direct mode:
model = direct_model(Gurobi.Optimizer())
@variables(model, begin
0 <= x <= 5
0 <= y <= 10, Int
z, Bin
end)
@objective(model, Max, x + 2y + 5z)
@constraint(model, x + y + z <= 10)
@constraint(model, x + 2y + z <= 15)
Gurobi.write_model(backend(model), "test.mps")