I have an issue where sometimes, for some ungodly reason, ROBLOX’s API has a hiccup or thinks I’m requesting actions on a datastore too many times when in reality I only do it once every 5-10 minutes.
I know there are way to mitigate this and solve the issue by doing a repeat + pcall, however,
In the case that these datastore issues do happen and it results in a datastore wipe, I need to be able to revert the datastore back to a previous version where there was data. Perhaps roll it back no less than an hour.
Is there a way I can effectively do this? I know how to roll back data doing something like the following:
local listSuccess, pages = pcall(function()
return myDatastore:ListVersionsAsync("IntelTyphoon", nil)
end)
if listSuccess then
if pages.IsFinished == false then
repeat
warn("Next Page...")
pages:AdvanceToNextPageAsync()
until pages.IsFinished == true
end
warn("Final Page")
local items = pages:GetCurrentPage()
for key, info in pairs(items) do
warn("Key:", key, "; Version:", info.Version, "; Created:", info.CreatedTime, "; Deleted:", info.IsDeleted)
end
local success, value, info = pcall(function()
return myDatastore:GetVersionAsync("IntelTyphoon", "08DBEAB9EEE65235.00000000AD.08DBF075CB5436A7.01")
end)
if success then
local setOptions = Instance.new("DataStoreSetOptions")
setOptions:SetMetadata(info:GetMetadata())
myDatastore:SetAsync("IntelTyphoon", value, nil, setOptions)
warn("Maybe worked")
else
warn("ya done messed up bro")
end
end
But, how would I do that so if the data returns empty, I can automatically roll the data back?
If you are either being rate-limited or the Roblox DataAtore API is down, rolling back to a previous save won’t help much. You can try to mitigate this in a few ways by avoiding the DataStore API: Use ProfileService or an external DataBase hosted through Firebase, AWS, or MongoDB.
So idk exactly what you are asking, 99% of the time DataStoreService is up and you can use ordered datastores, which save with timeframes, that will allow you to rollback if you ever release a major bug or something. If DataStoreService happens to be down, that is when you would rely on the most recent backup saved through one of the other methods listed.
Is there a way to automatically revert the datastore to a version that existed, say, 1 day ago, without having to go through and manually do it every single time by pulling the pages and finding the correct version id?
If I haven’t explained it adequately enough, the use case ought to be quite obvious nonetheless. If there are issues with the code, or datastores, and data needs to be restored, being able to restore said data is important. I would like to be able to do it by just automatically grabbing a version ID and restoring it based on something else.
Either way, I believe that I explained this in my initial post + title, by explicitly stating that this post was not about ways to mitigate datastore issues and errors and that I already knew of solutions, but rather how to easily and efficiently and automatically roll back said datastores. I’m not sure where it got lost.
Anyhow, it has been two days and I’ve figured out a method to likely use, just by adding versions to a table and then searching for the info.Created timestamp closest to what I need. It’s not perfect, but it works all things considered.
Well, I am recommending external systems because it seems your only use case is when data store service is down. If you can’t access the current version, you won’t be able to access a previous version.