Data Stores Get Version at Time Live in Engine and Open Cloud

Hi Creators!

This is a follow-up to the Upcoming Changes to Data Stores Versioning announcement. Methods to retrieve data store versions by timestamp are now live in Engine and Open Cloud. As a reminder, the other announced changes went live earlier this year.

These methods make it easier to use Data Stores versions for data rollback to a particular time. For example, if a bad update was published on 12/2/2024 at 6:05 UTC, you can use the following code to retrieve a past version of a key prior to the update:

local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("DataStore")

local key = "key-123"

local timestamp = DateTime.fromUniversalTime(2024, 12, 02, 06, 04, 59)

local success, result, keyInfo = pcall(function()
   return dataStore:GetVersionAtTimeAsync(key, timestamp.UnixTimestampMillis)
end)

if success then
   if result == nil then
      print("No version found at time")
   else
      print("Data before update was", result, keyInfo.Version)
   end
else
   warn(result)
end

And, you can access the same previous version with the following Open Cloud resource URL:
https://apis.roblox.com/cloud/v2/universes/{universe}/data-stores/DataStore/entries/key-123@latest:2024-12-02T06:04:59Z

Previously, you had to use a combination of DataStore:ListVersionsAsync() and DataStore:GetVersionAsync() to achieve the same result.

To get started, check out the Engine API documentation for DataStore:GetVersionAtTimeAsync() and the updated Open Cloud API documentation for Get Data Store Entry.

As always, please let us know if you have any questions or encounter any issues!

The Data Stores team

158 Likes

This topic was automatically opened after 10 minutes.

This is a fantastic change and exactly the kind of functionality that’s been needed for a long time. I could’ve really used this earlier, but I’m glad it’s here now. The ability to roll back data with just a timestamp is going to save so much time and hassle compared to the old ListVersionsAsync method :slight_smile:

16 Likes

Very good quality of life feature! This will definitely make rolling back to a specific time easier. Will be implementing in my game!

17 Likes

this is so good. now its so much easier to revert data if you messed something up. honestly a pretty simple but good feature

12 Likes

In the code sample, timestamp variable should be time, right?

13 Likes

Thanks for the catch :slight_smile:. Yes, updated now.

11 Likes

If there wasn’t data around that specified time, will it just pick something that is close?

10 Likes

It returns the newest version that exists which was created before the requested time. For example, if we have these two versions:

  • Version 1, created at 11/15/24 06:00 UTC
  • Version 2, created at 12/2/24 06:00 UTC,

A call to GetVersionAtTimeAsync with time = 12/2/24 05:59 UTC returns Version 1. A call with time = 12/2/24 06:00 UTC returns Version 2.

15 Likes

Seeing a Roblox staff member wear duolingo ugc is so uncanny.

Anyways, this update was long overdue and it’s good to see it finally happen. Cant help but think (slightly) this was done because of sol’s rng.

13 Likes

prayin for all my fellow devs who mess up their player data somehow looking at this post in the coming months/years :pray:

14 Likes

What makes data added to versions? Even though I wait a minute or published the game, it overwrites the latest one. Should i wait 1 hour?

6 Likes

it’s beautiful, i’m going to shed a tear

5 Likes

The first write to each key in each hour creates a versioned backup of the previous data. All other writes overwrite the current data.

For example, if you write to a key at 5:01, 5:55, 5:59, and 6:01, the version written at 5:59 will be preserved as a versioned backup for thirty days. The versions written at 5:01 and 5:55 are overwritten. The version written at 6:01 would be overwritten by any write before 7:00.

We have some more documentation on this here: Managing Data Stores | Documentation - Roblox Creator Hub.

9 Likes

This would have been super super helpful 3 years ago. Glad to see this come out nonetheless!

8 Likes

The fact that version rollback has been merged from two different functions into a single one makes it so much easier to go back to a previous version.

I will definitly take advantage of this when I need it to and let’s hope many developers do as well when they need to quickly switch versions.

3 Likes

This is an amazing feature, it will make a lot of things easier!
Thanks!

2 Likes