Jump to content

Proper way of doing backups


MadBrozzeR

Recommended Posts

Hello!

Let me apologize to begin with. I'm sure it was discussed many times, but I failed to find something useful.

I believe, the way to backup game data is to copy '/ShooterGame/Saved/SavedArks' directory. But is it safe to do it while server is running?

I'd like to run scheduled task to backup game data twice a day, and don't really like the idea of stopping server.

Is there any configuration or command (or just tricky logic) to prevent server from saving data temporary?

My ARK is on Linux server, if it matters.

Thanks in advance!

Link to comment
Share on other sites

2 hours ago, MadBrozzeR said:

Hello!

My ARK is on Linux server, if it matters.

Thanks in advance!

You can do  that while the server is running so long as it it is not going to save halfway through the copy.  What I do though is I run a cron job at 4am my time that actually stops the server (giving players a 10 min warning countdown) and then makes a backup with rsync to a different location on disk and I keep a rolling 7 days history.  Then restart the server, with an ssd this whole process takes about 2 minutes and the server is back up and running, with the added advantage for freeing leaked memory (if any) once a day.  

But another thing you can do is set the server to auto save once a day, and then again using cron get it to save more regularly and that way you will know in advance when it is going to save and can backup between saves.

Also I recommend you investigate ark tools https://github.com/FezVrasta/ark-server-tools

I use it and it make life a lot easier, it has commands to check for updates to the server and mods, and can automatically apply them or download only etc.  It is worth the hour our so it takes to read and setup.

 

 

Link to comment
Share on other sites

16 hours ago, Grounded said:

But another thing you can do is set the server to auto save once a day, and then again using cron get it to save more regularly and that way you will know in advance when it is going to save and can backup between saves.

I like the sound of it. But how? Is there an option to disable automatic server saves and do it manually (e.g. by cron)?

Don't really like to use external tools, prefer writing my own ones as far as API and my knowledge (and also laziness) allows it.

Link to comment
Share on other sites

6 hours ago, MadBrozzeR said:

I like the sound of it. But how? Is there an option to disable automatic server saves and do it manually (e.g. by cron)?

Don't really like to use external tools, prefer writing my own ones as far as API and my knowledge (and also laziness) allows it.

I am not sure there is an option to disable but I set mine to save every 30 hours and since the server restarts once a day it never does the auto save.

Maybe Rcon can issue a save, I don't know.  I understand the desire to write your own, and it is a great way to learn.  Have fun.

Link to comment
Share on other sites

16 hours ago, Grounded said:

I am not sure there is an option to disable but I set mine to save every 30 hours and since the server restarts once a day it never does the auto save.

Maybe Rcon can issue a save, I don't know.  I understand the desire to write your own, and it is a great way to learn.  Have fun.

Rcon should be able to save world, according to command list:

Quote

Forces the server to save the game world to disk in its current state. In single-player mode, the game saves this information locally.
admincheat saveworld

And there is also an option in .ini file that defines world save frequency (AutoSavePeriodMinutes). But does it mean that countdown reset on force save (in order to backup right after save)? And also, as far as I know, server saves data on player log off, so this is still not totally safe.

I have a Minecraft server, and the game have three useful commands for this case: save-off (disable world autosave), save-all (save current world state), save-on (enable world autosave).

 

Other possible and very simple solution that just appeared in my mind is to deny write access (chmod) to game files temporarily. But there is also two questions:

1. How FS behaves on permission change while file is currently accessed?

2. How ARK behaves when cannot access file to write to?

Link to comment
Share on other sites

7 hours ago, MadBrozzeR said:

Rcon should be able to save world, according to command list:

And there is also an option in .ini file that defines world save frequency (AutoSavePeriodMinutes). But does it mean that countdown reset on force save (in order to backup right after save)? And also, as far as I know, server saves data on player log off, so this is still not totally safe.

I have a Minecraft server, and the game have three useful commands for this case: save-off (disable world autosave), save-all (save current world state), save-on (enable world autosave).

 

Other possible and very simple solution that just appeared in my mind is to deny write access (chmod) to game files temporarily. But there is also two questions:

1. How FS behaves on permission change while file is currently accessed?

2. How ARK behaves when cannot access file to write to?

Hey, I ran a minecraft server for about 2 and a half years.  A great game.  

I am not sure, but I am like 99% certain that the server does not save files when it is running other than when instructed to or when it's auto save period kicks in.  This is based on what I have read (but can't provide a link sorry) and experiences with regards to crashing, it was pretty unstable back in June.  So I set mine up to save every 15 mins because of that.

Google is your friend here

Link to comment
Share on other sites

21 hours ago, Grounded said:

I am not sure, but I am like 99% certain that the server does not save files when it is running other than when instructed to or when it's auto save period kicks in.

Unfortunately, that's a remaining 1%.

Some hours ago I started directory change tracker at SavedArks, and there is my research. World (TheIsland.ark) is being saved every 15 minutes, as AutoSavePeriodMinutes option dictates, but player files are not affected by this option. They are being saved on every log in and log out, death and some other events I'm not actually able to track (no game log records). There is a part of tracker log with my comments (censored Steam ID and tribe ID (just in case)):

// Empty server
[27.10.2016 15:00:41] [change] TheIsland.tmp
[27.10.2016 15:15:41] [change] TheIsland.tmp
[27.10.2016 15:30:41] [change] TheIsland.tmp
[27.10.2016 15:45:41] [change] TheIsland.tmp
[27.10.2016 16:00:41] [change] TheIsland.tmp
// Player logged in
[27.10.2016 16:05:26] [change] [censored].profilebak
[27.10.2016 16:05:26] [change] [censored].tribebak
// Player logged out
[27.10.2016 16:11:35] [change] [censored].tmprofile
[27.10.2016 16:11:35] [change] [censored].arkprofile
// Player logged in and remains online
[27.10.2016 16:15:36] [change] [censored].profilebak
[27.10.2016 16:15:36] [change] [censored].tribebak
[27.10.2016 16:15:41] [change] TheIsland.tmp
[27.10.2016 16:30:41] [change] TheIsland.tmp
// Player killed
[27.10.2016 16:39:46] [change] [censored].arktribe
[27.10.2016 16:39:56] [change] [censored].tmprofile
[27.10.2016 16:39:56] [change] [censored].arkprofile
[27.10.2016 16:43:24] [change] [censored].tmprofile
[27.10.2016 16:43:24] [change] [censored].arkprofile
[27.10.2016 16:45:36] [change] [censored].tmprofile
[27.10.2016 16:45:36] [change] [censored].arkprofile
[27.10.2016 16:45:41] [change] TheIsland.tmp

So it is really unpredictable...

Link to comment
Share on other sites

2 hours ago, MadBrozzeR said:

Unfortunately, that's a remaining 1%.

Some hours ago I started directory change tracker at SavedArks, and there is my research. World (TheIsland.ark) is being saved every 15 minutes, as AutoSavePeriodMinutes option dictates, but player files are not affected by this option. They are being saved on every log in and log out, death and some other events I'm not actually able to track (no game log records). There is a part of tracker log with my comments (censored Steam ID and tribe ID (just in case)):

So it is really unpredictable...

Good to know, but since I shut down once a day and do a backup I am not worried about that.  So maybe rethink the need to 24/7 operation, 3 or 4 mins of scheduled downtime a day is not the end of the world.

Link to comment
Share on other sites

18 hours ago, Grounded said:

Good to know, but since I shut down once a day and do a backup I am not worried about that.  So maybe rethink the need to 24/7 operation, 3 or 4 mins of scheduled downtime a day is not the end of the world.

It's totally fine as a last resort. The problem is not about downtime duration, but it still may be annoying sometimes, when you've been caught unprepared, and 10 minutes warning countdown is not always enough to get to safety, you need to look forward to it. Too long countdown is also doesn't look like a good idea. Anyway it's always better to avoid restarts that can be avoided.

So I'm still thinking about changing file permissions. Game itself should be fine while not having write permissions. As I initially started my server by wrong user (without write access), and only problem was a lost game data on server restart.

FS should be fine as well on chmod while file is being modified. I've read that permissions only prevent file from being open, but while it is already open it can be modified regardless of permissions at the moment. So we need to recursively write-protect SavedArks directory and wait for couple of seconds before back up creation, in case if some of files are currently being modified.

But a little bit scared of ruining everything if I'm missing something though...

Link to comment
Share on other sites

6 hours ago, MadBrozzeR said:

It's totally fine as a last resort. The problem is not about downtime duration, but it still may be annoying sometimes, when you've been caught unprepared, and 10 minutes warning countdown is not always enough to get to safety, you need to look forward to it. Too long countdown is also doesn't look like a good idea. Anyway it's always better to avoid restarts that can be avoided.

So I'm still thinking about changing file permissions. Game itself should be fine while not having write permissions. As I initially started my server by wrong user (without write access), and only problem was a lost game data on server restart.

FS should be fine as well on chmod while file is being modified. I've read that permissions only prevent file from being open, but while it is already open it can be modified regardless of permissions at the moment. So we need to recursively write-protect SavedArks directory and wait for couple of seconds before back up creation, in case if some of files are currently being modified.

But a little bit scared of ruining everything if I'm missing something though...

Well I have set some players .arkprofile to be read only when they were being griefers, so I know that the server does not care or throw a wobbly if it can't write to those files.

Link to comment
Share on other sites

Ok, there is what I've done. Works pretty well so far.

now=$(date +'%Y%m%d_%H%M%S')
dir=../../Saved

chmod -R u-w $dir/SavedArks && {
    sleep 2
    tar -zcvf $dir/backup/SavedArks@$now.tar.gz $dir/SavedArks/ $dir/Config/
    chmod -R u+w $dir/SavedArks
}

All directories in SavedArks have rwxr-xr-x permissions, while files have rw-------. So all we need to do is to remove 'w' flag from user permissions and restore it afterwards.

I've made some test tries to copy files with no permission change and with 7 players online. Each time tar complained about file changes during operation process. After I cut write permissions files were successfully compressed.

 

One strange thing happened though... during my experiments one of the players noticed that his Argentavis changed his gender from male to female and amount of max HP from 1000+ to 400. I doubt this events are related (and how possibly can it be related?), but still...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...