Can I do a live backup of a leveldb world?

Post Reply
User avatar
Piezo_
Member
Posts: 219
Joined: Fri Jul 20, 2018 21:36
GitHub: is proprietary I use NotABug
Location: (x,y,z)

Can I do a live backup of a leveldb world?

by Piezo_ » Post

...or will that break anything?
while (true) { suffer(); }

User avatar
bhree
Member
Posts: 168
Joined: Tue Jun 19, 2018 07:45
GitHub: bhree
IRC: bhree
In-game: bhree
Location: Alone In The Wild Land
Contact:

Re: Can I do a live backup of a leveldb world?

by bhree » Post


User avatar
Piezo_
Member
Posts: 219
Joined: Fri Jul 20, 2018 21:36
GitHub: is proprietary I use NotABug
Location: (x,y,z)

Re: Can I do a live backup of a leveldb world?

by Piezo_ » Post

bhree wrote:I thinks it is pretty complicated https://stackoverflow.com/questions/129 ... equivalent
What I want to do isn't complicated, just a simple copy command over ssh.

I would think the answer to "is that, specifically, safe" would be a simple yes or no.
while (true) { suffer(); }

User avatar
bhree
Member
Posts: 168
Joined: Tue Jun 19, 2018 07:45
GitHub: bhree
IRC: bhree
In-game: bhree
Location: Alone In The Wild Land
Contact:

Re: Can I do a live backup of a leveldb world?

by bhree » Post

If it is official then it high probably safe. But I will say no to myself then shut the game, make the backup and start again. It is different from my confidence on postgresql as it is clearly documented.

User avatar
sorcerykid
Member
Posts: 1505
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Can I do a live backup of a leveldb world?

by sorcerykid » Post

I personally wouldn't advise copying a live database. Consider that any number of mapblocks could be created or modified during the backup operation. Hence, the target database is unlikely to be a true "snapshot" of the original database at any point in time. To my knowledge the only way to guarantee consistency is to place an exclusive lock on the database. Bu, that defeats the purpose.

Here's an illustration of the inherent problems of a live database backup:
  • 10:00:01 (backup started, mapblock 1 copied)
    Mapblock 1 -> modified by Player45 (dig node, abm set nodes)
    Mapblock 2 -> modified by Player13 (place node)
    Mapblock 8

    10:00:02 (mapblock 2 copied, missed changes to mapblock 1)
    Mapblock 1 -> modified by Player45 (dig node)
    Mapblock 2
    Mapblock 8

    10:00:03 (mapblock 8 copied, missed changes to mapblock 2 and 6)
    Mapblock 1
    Mapblock 2 -> modified by Player13 (node metadata set)
    Mapblock 6 -> created by Player 31 (mapgen)
    Mapblock 8
Notice how the original database is in a perpetually transitory state, so the backup can quickly become out of sync. In the example above, the resulting backup database would not represent a true snapshot of the original database.

User avatar
Piezo_
Member
Posts: 219
Joined: Fri Jul 20, 2018 21:36
GitHub: is proprietary I use NotABug
Location: (x,y,z)

Re: Can I do a live backup of a leveldb world?

by Piezo_ » Post

So, it might be chronologically inconsistent in a few places, but nothing would be corrupted, empty or spontaneously deleted, and there's no chance of the entire map breaking?
while (true) { suffer(); }

User avatar
sorcerykid
Member
Posts: 1505
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Can I do a live backup of a leveldb world?

by sorcerykid » Post

As far as I know mapgen generates mapblocks in chunks (I believe are 80x80x80 nodes). So if the backup operation only captures a portion of a new chunk, then that could result in overgeneration of existing mapblocks. However, beyond that anomaly, all database transactions are atomic. So it should be impossible for mapblock data to be corrupted. Nevertheless, chronological inconsistencies could have serious implications as far as integrity of gameplay.

Let's say that Player39 empties out their chest in mapblock 1 that contains 10 stacks of gold and diamond blocks. Then they teleport to mapblock 100 and deposit those gold and diamond blocks into a different chest. A few days later the world directory becomes corrupted, so the map is restored from backup. But as it turns out the former backup operation captured the chest with the 10 stacks of gold and diamond blocks in mapblock 1 and then by the time it reached mapblock 100, it captured the 10 stacks of gold and diamond blocks in that chest as well. Now Player39 has 20 stacks of gold and diamond blocks. Similar problems could occur if entities move from one mapblock to another in the course of a backup operation. So on and so forth.

843jdc
Member
Posts: 352
Joined: Tue Jan 19, 2016 16:46
GitHub: jdc843
IRC: jdc843
In-game: 843jdc
Location: USA

Re: Can I do a live backup of a leveldb world?

by 843jdc » Post

Yes. Doing database backups with the MT server shut down is best. Pretty fast if you use solid state drives also.
Editing the database while it's live is not recommended either.
SK - From what I've read about Leveldb, I don't see why backups and editing shouldn't work. But better safe than sorry. That teleporting though. That's a way of thinking I didn't think of. Salex, BBMine, and others would love exploiting that haha

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests