ich777 / docker-steamcmd-server

Simple Dockerfile that installs steamcmd and a selected game server
121 stars 98 forks source link

start-backup.sh archive contains all previous backups #68

Closed andrewtdavis closed 3 weeks ago

andrewtdavis commented 3 weeks ago

Using the 7d2d branch, the start-backup.sh script uses a relative path for tar instead of absolute paths. This creates a situation where it creates backups of all previous backups, in an ever-growing list.

Example:

# tar -tvf 2024-08-21_22.45.07.tar.gz
drwxrwx--- steam/users       0 2024-08-21 14:45 ./
-rwxrwx--- steam/users 147322233 2024-08-21 06:05 ./2024-08-21_13.04.58.tar.gz
-rwxrwx--- steam/users  36833623 2024-08-21 04:04 ./2024-08-21_11.04.55.tar.gz
-rwxrwx--- steam/users 9426243247 2024-08-21 12:15 ./2024-08-21_19.09.55.tar.gz

Suggestion:

Replace

tar -czf ${SERVER_DIR}/Backups/$(date '+%Y-%m-%d_%H.%M.%S').tar.gz .

with

tar -czf ${SERVER_DIR}/Backups/$(date '+%Y-%m-%d_%H.%M.%S').tar.gz ${SERVER_DIR}/User/Saves

This has the added benefit of not duplicating generated worlds, which the one I have (RWG, 10240 tiles) is about 350M but doesn't change.

ich777 commented 3 weeks ago

@andrewtdavis can you please explain that a bit more in detail? I think you missed that it first changes the directory to ${SERVER_DIR}/Saves and then it creates the backup from the Saves directory so no backup is included and this shouldn't cause any issues because the Saves directory is a different directory than Backup directory, at least I don't know why the old backups are included in your case...

The proposed change would also create an issue where the whole file path is included in the backup instead of the relative file path.

Did maybe the path to the saves change? That's the only thing that I can imagine with the v1.0 update?

ich777 commented 3 weeks ago

@andrewtdavis now I get it, it seems that the path changed (in this commit) and I completely forgot to change the start-backup.sh script so that these changes are reflected.

Is the new path then ${SERVER_DIR}/User/Saves? If yes I'll change the script to:

        ...
    cd ${SERVER_DIR}/User/Saves
    tar -czf ${SERVER_DIR}/Backups/$(date '+%Y-%m-%d_%H.%M.%S').tar.gz .
        ...
andrewtdavis commented 3 weeks ago

@ich777 Correct. Here's what the basic structure of $SERVERDIR looks like. Realistically, the only part that changes and would need to be restored is the ./User/Saves folder.

To fix pathing in the backup tar, why not try either: tar -czf ${SERVER_DIR}/Backups/$(date '+%Y-%m-%d_%H.%M.%S').tar.gz -C ./ ${SERVER_DIR}/User/Saves or pushd ${SERVER_DIR}/User/Saves

I find it safer to avoid using relative paths in scripts to prevent them from doing something unexpected with a path. Another option would be to test if we're in a save directory and exit with an error if it's something else.

Here's what $SERVER_DIR looks like with 1.0:

./steamapps
./steamapps/downloading
./steamapps/temp
./Licenses
./7DaysToDieServer_Data
./7DaysToDieServer_Data/Managed
./7DaysToDieServer_Data/Resources
./7DaysToDieServer_Data/StreamingAssets
./7DaysToDieServer_Data/MonoBleedingEdge
./7DaysToDieServer_Data/Plugins
./Data
./Data/Bundles
./Data/Prefabs
./Data/Bluffs
./Data/Worlds
./Data/Config
./Data/ItemIcons
./Data/UMATextures
./Data/Stamps
./Data/Addressables
./Logos
./Mods
./Mods/0_TFP_Harmony
./Mods/TFP_WebServer
./Mods/TFP_MapRendering
./Mods/TFP_CommandExtensions
./Mods/Xample_MarkersMod
./User
./User/Saves
./User/GeneratedWorlds
./User/Twitch
./Backups
ich777 commented 3 weeks ago

Realistically, the only part that changes and would need to be restored is the ./User/Saves folder.

Jup, I simply forgot that to change, the old path was just ${SERVER_DIR}/saves as you can see here.

I find it safer to avoid using relative paths in scripts to prevent them from doing something unexpected with a path. Another option would be to test if we're in a save directory and exit with an error if it's something else.

Done.

I've already pushed an update to the container, please update the container. Thanks for reporting that issue. :)

Please let me know if the update solves the issue.

ich777 commented 3 weeks ago

@andrewtdavis any update on this? I would really like to close this issue if the issue is resolved.

andrewtdavis commented 3 weeks ago

Sorry, it took a few days for k3s to see an update. I can confirm I have the saves are correctly showing up now, and are with the correct paths. Here's a recent backup:

# tar -tvf 2024-08-26_14.37.40.tar.gz
drwxrwx--- steam/users       0 2024-08-24 15:52 ./
-rwxrwx--- steam/users    5407 2024-08-24 22:34 ./serveradmin.xml
drwxrwx--- steam/users       0 2024-08-03 09:07 ./Navezgane/
drwxrwx--- steam/users       0 2024-08-03 10:19 ./Navezgane/My Game/
-rwxrwx--- steam/users      66 2024-08-03 10:19 ./Navezgane/My Game/players.xml
-rwxrwx--- steam/users       9 2024-08-03 10:19 ./Navezgane/My Game/turrets.dat
-rwxrwx--- steam/users       5 2024-08-03 10:19 ./Navezgane/My Game/power.dat
-rwxrwx--- steam/users       9 2024-08-03 10:19 ./Navezgane/My Game/vehicles.dat
-rwxrwx--- steam/users       8 2024-08-03 09:07 ./Navezgane/My Game/itemmappings.nim
-rwxrwx--- steam/users       9 2024-08-03 10:19 ./Navezgane/My Game/drones.dat
-rwxrwx--- steam/users     642 2024-08-03 10:19 ./Navezgane/My Game/blockmappings.nim
drwxrwx--- steam/users       0 2024-08-03 09:08 ./Navezgane/My Game/Region/
drwxrwx--- steam/users       0 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/
-rwxrwx--- steam/users  130957 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/item_modifiers.xml
-rwxrwx--- steam/users    5592 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/utilityai.xml
-rwxrwx--- steam/users  126439 2024-08-03 09:07 ./Navezgane/My Game/ConfigsDump/physicsbodies.xml
-rwxrwx--- steam/users  120595 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/biomes.xml
-rwxrwx--- steam/users    1007 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/worldglobal.xml
-rwxrwx--- steam/users   33964 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/vehicles.xml
-rwxrwx--- steam/users   14439 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/misc.xml
-rwxrwx--- steam/users  817239 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/buffs.xml
-rwxrwx--- steam/users   22067 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/spawning.xml
-rwxrwx--- steam/users 1310895 2024-08-03 09:07 ./Navezgane/My Game/ConfigsDump/shapes.xml
-rwxrwx--- steam/users    8183 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/dmscontent.xml
-rwxrwx--- steam/users    1542 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/weathersurvival.xml
-rwxrwx--- steam/users   60310 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/nav_objects.xml
-rwxrwx--- steam/users  319887 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/entityclasses.xml
-rwxrwx--- steam/users   32228 2024-08-03 09:07 ./Navezgane/My Game/ConfigsDump/painting.xml
-rwxrwx--- steam/users  361770 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/twitch.xml
-rwxrwx--- steam/users  350726 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/progression.xml
-rwxrwx--- steam/users  100295 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/ui_display.xml
-rwxrwx--- steam/users   76562 2024-08-03 09:07 ./Navezgane/My Game/ConfigsDump/materials.xml
-rwxrwx--- steam/users    2302 2024-08-03 09:07 ./Navezgane/My Game/ConfigsDump/events.xml
-rwxrwx--- steam/users  528815 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/entitygroups.xml
-rwxrwx--- steam/users     402 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/qualityinfo.xml
-rwxrwx--- steam/users   16149 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/archetypes.xml
-rwxrwx--- steam/users      20 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/videos.xml
-rwxrwx--- steam/users 1791043 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/items.xml
-rwxrwx--- steam/users  161903 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/blockplaceholders.xml
-rwxrwx--- steam/users   63307 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/traders.xml
-rwxrwx--- steam/users 1202287 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/sounds.xml
-rwxrwx--- steam/users  485468 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/gameevents.xml
-rwxrwx--- steam/users    1597 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/loadingscreen.xml
-rwxrwx--- steam/users   21596 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/rwgmixer.xml
-rwxrwx--- steam/users    2843 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/npc.xml
-rwxrwx--- steam/users   22856 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/twitch_events.xml
drwxrwx--- steam/users       0 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi_Common/
-rwxrwx--- steam/users   18340 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi_Common/styles.xml
-rwxrwx--- steam/users   18425 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi_Common/controls.xml
-rwxrwx--- steam/users   68467 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/challenges.xml
-rwxrwx--- steam/users 3350854 2024-08-03 09:07 ./Navezgane/My Game/ConfigsDump/blocks.xml
-rwxrwx--- steam/users  210673 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/subtitles.xml
-rwxrwx--- steam/users   17922 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/dialogs.xml
-rwxrwx--- steam/users  435466 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/loot.xml
-rwxrwx--- steam/users  255518 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/recipes.xml
-rwxrwx--- steam/users  158496 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/quests.xml
-rwxrwx--- steam/users  301533 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/gamestages.xml
drwxrwx--- steam/users       0 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi/
-rwxrwx--- steam/users     292 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi/styles.xml
-rwxrwx--- steam/users  391507 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi/windows.xml
-rwxrwx--- steam/users   16961 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi/xui.xml
-rwxrwx--- steam/users   95138 2024-08-03 09:08 ./Navezgane/My Game/ConfigsDump/XUi/controls.xml
-rwxrwx--- steam/users       9 2024-08-03 10:19 ./Navezgane/My Game/blockLimits.dat
-rwxrwx--- steam/users     263 2024-08-03 09:08 ./Navezgane/My Game/main.ttw.ext.bak
-rwxrwx--- steam/users 1282927 2024-08-03 10:19 ./Navezgane/My Game/decoration.7dt
-rwxrwx--- steam/users     581 2024-08-03 10:19 ./Navezgane/My Game/main.ttw
drwxrwx--- steam/users       0 2024-08-03 09:08 ./Navezgane/My Game/DynamicMeshes/
-rwxrwx--- steam/users     581 2024-08-03 10:19 ./Navezgane/My Game/main.ttw.bak