Jesus said the Sabbath was made for man (Mark 2:27). When was it made? Some might think that the Sabbath did not exist before Moses, and they say that there is no record of the Sabbath being kept before Israel began to keep it in the wilderness.
There are two examples of Sabbath keeping in the first 30 chapters of Genesis.
There is one very specific example, directly tied to the Sabbath, and also a more general example that shows that someone was keeping the Sabbath when you put a few scriptures together.
When was the Sabbath made, and how was it made? Part of the answer to the question of HOW the Sabbath was made is given in the fourth of the ten commandments: "...Therefore the Lord blessed the Sabbath day and hallowed it" (Exodus 20:11). God made the Sabbath by blessing it and hallowing it, or in other words, putting a special honor upon it and setting it apart from other days for a special purpose.
When did this event occur? It happened at the time of creation. "Then God blessed the seventh day and sanctified it..." (Genesis 2:3).
God Himself observed the Sabbath when He created it, by resting on that day, setting an example for mankind (Genesis 2:1-3). He created the Sabbath by keeping it Himself as well as by blessing and sanctifying it. God often teaches by example (John 13:12-16). Jesus Christ, God in the flesh, lived an entire perfect life without sin as an example of how His followers should live. God rested on the Sabbath, keeping it, for the sole purpose of making the Sabbath, creating the Sabbath day as a special day for mankind, as Jesus said (Mark 2:27-28). There was no other reason for God to rest. God did not need to rest because He was tired. He rested to create the Sabbath by His example. And He created it for mankind immediately after He created mankind, so He intended it to be kept by mankind from the beginning. He sanctified it and set it apart for a holy purpose. That was the first Sabbath. The exact parallel of wording between the commandment in Exodus 20:11 and creation of the Sabbath day in Genesis 2:3 shows that they are talking about exactly the same thing.
The second example is where God said that Abraham kept an entire body of God's law. Genesis 26:5 says, "because Abraham obeyed My voice and kept My charge, My commandments, My statutes, and My laws." This shows that the law of God existed before Moses. It also shows that just because a law is not specifically mentioned before Moses does not mean it didn't exist or wasn't observed. The evidence that the Sabbath was included in this law is the reference to "My law" that God makes in Exodus 16:4-6 when He says that He will test Israel to see if they will keep God's law. God is not creating a new law. He is making reference to a law that already existed prior to the ten commandments and prior to the Old Covenant. This has to be the same law that Abraham obeyed. There is no record of God changing any laws from the time of the flood until Moses, and no record of God creating the Sabbath day by blessing it and sanctifying it after Genesis chapter 2. So since the Sabbath law existed before the Old Covenant, it must have been included in the same body of law that Abraham kept. The whole context of the test of Israel was their willingness to obey the Sabbath law (Exodus 16:27-30).
Notice, in the fourth commandment, God says, "...Therefore the Lord blessed the Sabbath day and hallowed it" (Exodus 20:11). The parallel wording shows that this is pointing to the seventh day of creation when God rested, "Then God blessed the seventh day and sanctified it..." (Genesis 2:3). This answers the question of when God made the Sabbath day. It was made when God blessed the Sabbath day and hallowed it. When was that? It was at creation, because Genesis says God blessed the seventh day and sanctified it. What this shows is that the seventh day of creation which God blessed was not just that one day, but the Sabbath day itself, every seventh day from that time, which is what the Sabbath is, a re-occurring day of the week. Therefore the Sabbath must have existed in Abraham's day, and since God says that Abraham obeyed God's laws, he must have kept the Sabbath.
Some Bible readers might think that because there is no record before Moses of a codified law that says, "you shall rest on the Sabbath", the law of the Sabbath did not exist before Moses. But that line of reasoning is invalidated by God's statement about Abraham's obedience. Abraham obeyed God's laws, yet those laws are not codified in Genesis. The lack of mention of the codification of those laws in Abraham's day doesn't mean they did not exist at that time. God's laws existed before they were codified with Moses. There would be no need for Moses, who wrote Genesis, to itemize all the laws that Abraham obeyed because Moses wrote those laws as God gave them to him in Exodus.
Joseph knew about God's law because he knew what sin is (Genesis 39:9). He knew that to commit adultery with his master's wife was a violation of God's commandment against adultery, the seventh commandment, and therefore was a sin against God. He knew what sin was by the commandments of God. "Whosoever committeth sin transgresseth also the law: for sin is the transgression of the law" (1 John 3:4, King James Version). Which law? The ten commandments. Paul said that he knew that coveting was a sin because the tenth of the ten commandments said, "You shall not covet" (Romans 7:7). See also James 2:10-11.