diff --git a/cmd/backup/stop_restart.go b/cmd/backup/stop_restart.go index 7fc558c..32191cb 100644 --- a/cmd/backup/stop_restart.go +++ b/cmd/backup/stop_restart.go @@ -151,15 +151,21 @@ func (s *script) stopContainersAndServices() (func() error, error) { }), Status: true, }) + if err != nil { + return noop, errwrap.Wrap(err, "error querying for services to scale down") + } for _, s := range matchingServices { + if s.Spec.Mode.Replicated == nil { + return noop, errwrap.Wrap( + nil, + fmt.Sprintf("only replicated services can be restarted, but found a label on service %s", s.Spec.Name), + ) + } servicesToScaleDown = append(servicesToScaleDown, handledSwarmService{ serviceID: s.ID, initialReplicaCount: *s.Spec.Mode.Replicated.Replicas, }) } - if err != nil { - return noop, errwrap.Wrap(err, "error querying for services to scale down") - } } if len(containersToStop) == 0 && len(servicesToScaleDown) == 0 {