[GH-ISSUE #1563] backup "fails" because --exclude isn't working as expected #1220

Closed
opened 2026-02-27 02:55:57 +03:00 by kerem · 7 comments
Owner

Originally created by @marvinlehmann on GitHub (Aug 3, 2017).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/1563

Originally assigned to: @UltimateByte on GitHub.

Introduced with 0a8bfc3c25 (Line in question)

marvin@ubuntu:~$ ./boserver backup
[  OK  ] Backup boserver: Backup starting
[ INFO ] Backup boserver: There are no previous backups
[ .... ] Backup boserver: Backup (108M) boserver-2017-08-03-230045.tar.gz, in progress...tar: ./backups: file changed as we read it
FAIL
[ FAIL ] Backup boserver: Starting backup

It doesn't work because relative and absolute paths are mixed. The backup will still be created but will also contain the previous ones.

Variant 1:
tar -czf "${backupdir}/${backupname}.tar.gz" --exclude="${backupdir}" --absolute-names ${rootdir}/*

.. would work but then you have \\home\<user>\ in the archive.

I just can't find a good solution to it.

EDIT:
Variant 2:

excludedir=$(realpath --relative-to="${rootdir}" "${backupdir}")
tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" ./*

What about that?

Originally created by @marvinlehmann on GitHub (Aug 3, 2017). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/1563 Originally assigned to: @UltimateByte on GitHub. Introduced with 0a8bfc3c258665d1963025c277c9c220def8fb95 ([Line in question](https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/functions/command_backup.sh#L115)) ``` marvin@ubuntu:~$ ./boserver backup [ OK ] Backup boserver: Backup starting [ INFO ] Backup boserver: There are no previous backups [ .... ] Backup boserver: Backup (108M) boserver-2017-08-03-230045.tar.gz, in progress...tar: ./backups: file changed as we read it FAIL [ FAIL ] Backup boserver: Starting backup ``` It doesn't work because relative and absolute paths are mixed. The backup will still be created but will also contain the previous ones. **Variant 1:** `tar -czf "${backupdir}/${backupname}.tar.gz" --exclude="${backupdir}" --absolute-names ${rootdir}/*` .. would work but then you have `\\home\<user>\` in the archive. I just can't find a good solution to it. EDIT: **Variant 2:** ``` excludedir=$(realpath --relative-to="${rootdir}" "${backupdir}") tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" ./* ``` What about that?
kerem 2026-02-27 02:55:57 +03:00
  • closed this issue
  • added the
    type: bug
    label
Author
Owner

@UltimateByte commented on GitHub (Aug 3, 2017):

Isn't backupdir an absolute path ? If not, that's what we should probably correct.

<!-- gh-comment-id:320101842 --> @UltimateByte commented on GitHub (Aug 3, 2017): Isn't backupdir an absolute path ? If not, that's what we should probably correct.
Author
Owner

@marvinlehmann commented on GitHub (Aug 3, 2017):

It is but -C "${rootdir}" ./* is relative.

EDIT:
We should also keep in mind how to implement #1535. A few games have files in hidden directories like 7DTD, DST or Terraria. All have customizable paths though.

With the first variant we could just add these paths that can be defined somewhere (probably comma separated) to command for including them. With variant 2 we would have ugly paths in the archive.

<!-- gh-comment-id:320102476 --> @marvinlehmann commented on GitHub (Aug 3, 2017): It is but `-C "${rootdir}" ./*` is relative. EDIT: We should also keep in mind how to implement #1535. A few games have files in hidden directories like 7DTD, DST or Terraria. All have customizable paths though. With the first variant we could just add these paths that can be defined somewhere (probably comma separated) to command for including them. With variant 2 we would have ugly paths in the archive.
Author
Owner

@Grimston commented on GitHub (Aug 24, 2017):

The issue is lgsm/functions/command_backup.sh (Line 115)
tar can only use relative or absolute paths, not both backupdir being the full absolute path will not work when you are then using relative paths to create the archive reverting the change here: github.com/GameServerManagers/LinuxGSM@0a8bfc3c25

to:

tar --exclude "backups" -cjf "${backupdir}/${backupname}.tar.bzip2" -C "${rootdir}" ./*

exclude is required to be at the front for some versions of tar an oddity now, but to be safe it should be moved.

A new param could be added for the exclusion path but will need to be relative to the ${rootdir}

<!-- gh-comment-id:324622326 --> @Grimston commented on GitHub (Aug 24, 2017): The issue is `lgsm/functions/command_backup.sh` (Line 115) tar can only use relative or absolute paths, not both backupdir being the full absolute path will not work when you are then using relative paths to create the archive reverting the change here: https://github.com/GameServerManagers/LinuxGSM/commit/0a8bfc3c258665d1963025c277c9c220def8fb95 to: ```BASH tar --exclude "backups" -cjf "${backupdir}/${backupname}.tar.bzip2" -C "${rootdir}" ./* ``` exclude is required to be at the front for some versions of tar an oddity now, but to be safe it should be moved. A new param could be added for the exclusion path but will need to be relative to the ${rootdir}
Author
Owner

@ChrLau commented on GitHub (Oct 10, 2017):

EDIT: While that worked, it is way better to set the backupdir variable in your instance config, so you don't need to modify an LGSM script file. Which, additionally, can be overwritten at any time when updating LGSM.
In my instance config in lgsm/config-lgsm/rustserver/rustserver.cfg I simply specified:

# To fix: https://github.com/GameServerManagers/LinuxGSM/issues/1563
## Backup Directory
backupdir="backups"

Which overwrittes the default configuration in lgsm/config-lgsm/rustserver/_default.cfg:

## Backup Directory
backupdir="${rootdir}/backups"

And it works. No error message and backups only include the server files and not additionally all previously generated backups from the ./backups directory.

DON'T use this. Read above.
Sorry to hop in on this, I'm a first time user running into this problem with my Rust server. I changed the line 115 in lgsm/functions/command_backup.sh to the following:

#tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${backupdir}" ./*
tar --exclude "backups" -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" ./*

And this works. No tar error message during backup and the created backup files don't include previously generated backups anymore.

<!-- gh-comment-id:335475964 --> @ChrLau commented on GitHub (Oct 10, 2017): **EDIT:** While that worked, it is way better to set the backupdir variable in your instance config, so you don't need to modify an LGSM script file. Which, additionally, can be overwritten at any time when updating LGSM. In my instance config in `lgsm/config-lgsm/rustserver/rustserver.cfg` I simply specified: # To fix: https://github.com/GameServerManagers/LinuxGSM/issues/1563 ## Backup Directory backupdir="backups" Which overwrittes the default configuration in `lgsm/config-lgsm/rustserver/_default.cfg`: ## Backup Directory backupdir="${rootdir}/backups" And it works. No error message and backups only include the server files and not additionally all previously generated backups from the ./backups directory. **DON'T use this. Read above.** Sorry to hop in on this, I'm a first time user running into this problem with my Rust server. I changed the line 115 in `lgsm/functions/command_backup.sh` to the following: #tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${backupdir}" ./* tar --exclude "backups" -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" ./* And this works. No tar error message during backup and the created backup files don't include previously generated backups anymore.
Author
Owner

@UltimateByte commented on GitHub (Oct 29, 2017):

Tested working:

excludedir=$(realpath --relative-to="${rootdir}" "${backupdir}")
tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" ./*

Clever fix, I'm PRing

<!-- gh-comment-id:340270895 --> @UltimateByte commented on GitHub (Oct 29, 2017): Tested working: ``` excludedir=$(realpath --relative-to="${rootdir}" "${backupdir}") tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" ./* ``` Clever fix, I'm PRing
Author
Owner

@UltimateByte commented on GitHub (Oct 30, 2017):

Fixed.

<!-- gh-comment-id:340314351 --> @UltimateByte commented on GitHub (Oct 30, 2017): Fixed.
Author
Owner

@lock[bot] commented on GitHub (Oct 30, 2018):

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

<!-- gh-comment-id:434130322 --> @lock[bot] commented on GitHub (Oct 30, 2018): This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Sign in to join this conversation.
No labels
Atomic
Epic
cannot reproduce
command: backup
command: console
command: debug
command: details
command: fast-dl
command: install
command: mods
command: monitor
command: post-details
command: restart
command: send
command: start
command: stop
command: update
command: update-lgsm
command: validate
command: wipe
distro: AlmaLinux
distro: Arch Linux
distro: CentOS
distro: Debian
distro: Fedora
distro: RedHat
distro: Rocky Linux
distro: Ubuntu
distro: openSUSE
engine: goldsrc
engine: source
game: 7 Days to Die
game: ARMA 3
game: Ark: Survival Evolved
game: Assetto Corsa
game: Avorion
game: BATTALION: Legacy
game: Barotrauma
game: Battalion 1944
game: Battlefield 1942
game: Black Mesa: Deathmatch
game: Blade Symphony
game: Call of Duty 2
game: Call of Duty 4
game: Call of Duty: United Offensive
game: Counter-Strike 1.6
game: Counter-Strike 2
game: Counter-Strike: Global Offensive
game: Counter-Strike: Source
game: Day of Infamy
game: Dayz
game: Death Match Classic
game: Don't Starve Together
game: ET: Legacy
game: Eco
game: Factorio
game: Factorio
game: Garry's Mod
game: Half-Life
game: Hurtword
game: Insurgecy
game: Insurgecy
game: Insurgency: Sandstorm
game: Just Cause 3
game: Killing Floor
game: Killing Floor 2
game: Left 4 Dead 2
game: Minecraft
game: Minecraft Bedrock
game: Mordhau
game: Multi Theft Auto
game: Mumble
game: Natural Selection 2
game: No More Room in Hell
game: Pavlov VR
game: Post Scriptum
game: Project Zomboid
game: Quake 3
game: QuakeWorld
game: Red Orchestra: Ostfront 41-45
game: Return to Castle Wolfenstein
game: Rising World
game: Rust
game: San Andreas Multiplayer
game: Satisfactory
game: Soldat
game: Soldier of Fortune 2
game: Squad
game: Squad 44
game: Starbound
game: Stationeers
game: Sven Co-op
game: Team Fortress 2
game: Teamspeak 3
game: Teeworlds
game: Terraria
game: The Front
game: Unreal Tournament 2004
game: Unreal Tournament 3
game: Unreal Tournament 99
game: Unturned
game: Valheim
game: Wurm Unlimited
game: Zombie Master Reborn
game: label missing
good first issue
help wanted
info: alerts
info: dependency
info: docker
info: docs
info: email
info: query
info: steamcmd
info: systemd
info: tmux
info: website
info: website
needs more info
outcome: duplicate
outcome: issue resolved
outcome: issue resolved
outcome: issue unresolved
outcome: pr accepted
outcome: pr rejected
outcome: unconfirmed
outcome: wontfix
outcome: wrong forum
potential-duplicate
priority
pull-request
type: bug
type: feature
type: feature
type: feature request
type: game server request
type: refactor
waiting response
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LinuxGSM#1220
No description provided.