Sign in to follow this  
Followers 0
Blacksheep

SQL to extract base construction from backup

6 posts in this topic

Before I try to reinvent the wheel I would like to ask if anybody has already developed a SQL script to extract base constructions from a backup because of the owner was e.g. on vacation and nobody paid for the base and the db maintenance has ripped the base off?

The idea is to restore a backup into tables (e.g. same db with a prefix) and then do an INSERT INTO SELECT FROM to copy the deleted base construction items for a specific user from a backup.

 

 

 

Share this post


Link to post
Share on other sites

I tried making such a script. But it didn't work, because Exile seems to assign the ID's for each base piece sequentially, somehow regardless of what is actually in the database. So what happened was, I pulled in my backed up base fields, assigned them all new ID's, and inserted them into the table. All was well until someone created new buildable pieces, which were inserted into the table with the same ID's as the ones I had inserted. This resulted in BOTH bases being deleted. 

Furthermore, I did the same thing in the territory table, and added my backed up territory flag, assigned it a new ID and inserted it into the table. When someone created a new territory, it was inserted with the same ID as the one I inserted. This resulted in not only both of those bases being deleted, but every other base became unsynced from it's ID somehow. 

Basically it corrupted both tables and they had to be wiped. SO... I just wanted to share that with you. I don't have a solution yet, but if you intend to try to write a script, be aware that there is something very odd going on below the surface, and it is not a simple pull and push. DEFINITELY use a test environment to try it out before you do it live. 

Hope that helps!

1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

Thanks for sharing your experiences with me! Anyway, I will dig deeper into it since I think this would be helpful....

Will report if I have success.

1 person likes this

Share this post


Link to post
Share on other sites
On 4/14/2016 at 7:40 PM, papahyooie said:

I tried making such a script. But it didn't work, because Exile seems to assign the ID's for each base piece sequentially, somehow regardless of what is actually in the database. So what happened was, I pulled in my backed up base fields, assigned them all new ID's, and inserted them into the table. All was well until someone created new buildable pieces, which were inserted into the table with the same ID's as the ones I had inserted. This resulted in BOTH bases being deleted. 

Furthermore, I did the same thing in the territory table, and added my backed up territory flag, assigned it a new ID and inserted it into the table. When someone created a new territory, it was inserted with the same ID as the one I inserted. This resulted in not only both of those bases being deleted, but every other base became unsynced from it's ID somehow. 

Basically it corrupted both tables and they had to be wiped. SO... I just wanted to share that with you. I don't have a solution yet, but if you intend to try to write a script, be aware that there is something very odd going on below the surface, and it is not a simple pull and push. DEFINITELY use a test environment to try it out before you do it live. 

Hope that helps!

You could assign IDs so far out that they're never going to be overwritten? For anything you're re-importing, start at..50000 for example?

1 person likes this

Share this post


Link to post
Share on other sites
5 minutes ago, kuplion said:

You could assign IDs so far out that they're never going to be overwritten? For anything you're re-importing, start at..50000 for example?

That's what I would imagine I would have to do. Except that I would rather rebuild the base than manually edit the ID's of hundreds of base parts lol. 

I'm sure there is probably a way to do it automatically with SQL code, but I'm not that advanced.

Share this post


Link to post
Share on other sites
4 minutes ago, papahyooie said:

That's what I would imagine I would have to do. Except that I would rather rebuild the base than manually edit the ID's of hundreds of base parts lol. 

I'm sure there is probably a way to do it automatically with SQL code, but I'm not that advanced.

Haha, right there with ya, buddy! I'd opt for rebuilding too. :P

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.