Here is the first mention of the Sabbath.
Gen 2:1 Thus the heavens and the earth were finished, and all the host of them.
Gen 2:2 And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.
Gen 2:3 And God blessed the seventh day, and sanctified it: because that in it he had rested from all his work which God created and made.
But the Sabbath is not mentioned even ONCE in that passage. You just assume it. There is no suggestion there that anyone should observe the Sabbath day. It was the day of ceasing work on creation, not a day of rest.
The first mention of the Sabbath in Scripture is in Exodus 16, where it is quite clear that not all the Israelites knew about it. It was only in the giving of the covenant that the Sabbath was made a requirement. It was thus very much a part of the Law of Moses.
according to the text which day is the Sabbath?
No day was mentioned as the Sabbath!!
What did God do to this day?
He ceased creating. Then He blessed it, not because it was the Sabbath but because it was the 'day' on which creation was completed.
Does God need rest?
Of course not.
f not then why did he rest?
He did not rest. He ceased work. An important difference.