Note that the reintroduction of border controls provided for in the Schengen Borders Code does not restrict free movement more than slightly: EU citizens and others who enjoy free movement should be allowed to cross those borders after being subjected to the border controls (unless they can be excluded on the grounds set forth in directive 2004/38/EC).
I can't find what basis there is to remove the right to free movement under EU law?
The right of free movement in EU law stems from the treaties establishing the EU. For example, article 45 of the consolidated treaties concerns free movement of workers. Its third paragraph includes the words
subject to limitations justified on grounds of public policy, public security or public health
The broader application of free movement is found in Directive 2004/38/EC. This similarly allows exceptions for public policy, public security or public health, as provided in Chapter VI.
Article 27 sets forth the general principles, including
Subject to the provisions of this Chapter, Member States may restrict the freedom of movement and residence of Union citizens and their family members, irrespective of nationality, on grounds of public policy, public security or public health. ...
The only diseases justifying measures restricting freedom of movement shall be the diseases with epidemic potential as defined by the relevant instruments of the World Health Organisation and other infectious diseases or contagious parasitic diseases if they are the subject of protection provisions applying to nationals of the host Member State.
The directive does appear to require individual determinations to be made in order to restrict free movement, which suggests that wholesale closing of the border may be contrary to Union law. This is not entirely clear, however.
In any event, any person who enjoys free movement should be able to appeal their exclusion from Slovakia under Article 31(1):
The persons concerned shall have access to judicial and, where appropriate, administrative redress procedures in the host Member State to appeal against or seek review of any decision taken against them on the grounds of public policy, public security or public health.
It may prove difficult in practice, however, for people to get an individualized "decision taken against them" that they can appeal. If that happens, one way to approach this would be to try SOLVIT, although it's not likely to yield quick results.