The Talmud states that one may violate the Shabbat to save a life, because it's worth violating one Shabbat to let someone keep many in the future.
Does this principle apply in other cases? For example, suppose a person is stuck on an island and does not know which day is Shabbat. Every day he harvests enough berries to live from. If he builds a boat to leave the island, he will be able to keep Shabbat much better in the future, but for the moment is likely violating the Shabbat now.
Another example could be someone confined in a labor camp where he must work every day. He figures out how to escape, but it's only possible on Shabbat, and entails certain melakhot. If he violates the Shabbat more than necessary today, he will be able to keep many Shabbats in the future. Does the Talmud's principle extend to such cases, where there is no life at risk?