Open smw opened 6 years ago
I'm somewhat confident that I could fix this but the issue definitely relies with making realpath a required dependency, and editing the usage of realpath in the lgsm/functions/command_backup.sh.
The error I get is from line 115 saying this:
fraghaven1@fraghaven1:~$ ./csgoserver backup fetching command_backup.sh...OK [ OK ] Backup csgoserver: Backup starting [ INFO ] Backup csgoserver: There are no previous backups [ .... ] Backup csgoserver: Backup (18G) csgoserver-2017-12-14-053741.tar.gz, in progress.../home/fraghaven1/lgsm/functions/command_backup.sh: line 115: realpath: command not found tar: ./lgsm/backup/csgoserver-2017-12-14-053741.tar.gz: file changed as we read it
Edit: After installing realpath, I get these errors (looks like we are in the same boat):
fraghaven1@fraghaven1:~$ ./csgoserver backup [ OK ] Backup csgoserver: Backup starting [ INFO ] Backup csgoserver: There are no previous backups [ .... ] Backup csgoserver: Backup (18G) csgoserver-2017-12-14-064806.tar.gz, in progress...realpath: unrecognized option '--relative-to=/home/fraghaven1' Usage: realpath [-s|--strip] [-z|--zero] filename ... realpath -h|--help realpath -v|--version tar: ./lgsm/backup/csgoserver-2017-12-14-064806.tar.gz: file changed as we read it
If you've happened to find a fix for this, please let me know so I can submit a pull request.
function relpath() { python -c "import os,sys;print(os.path.relpath(*(sys.argv[1:])))" "$@"; }
steam@devi:~/lgsm/functions$ relpath $(readlink -f ../../lgsm/) /home/steam
lgsm
I think this will do the same thing, if you don't mind the python dep.
function cedar-realpath() {
# Written by CedarLUG as a realpath alternative in bash
declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g"))
declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g"))
for ((base=0; $base<${#rdirtoks[@]}; base++))
do
[[ "${rdirtoks[$base]}" != "${bdirtoks[$base]}" ]] && break
done
for ((x=${base};$x<${#rdirtoks[@]};x++))
do
echo -n "../"
done
for ((x=${base};$x<$(( ${#bdirtoks[@]} - 1 ));x++))
do
echo -n "${bdirtoks[$x]}/"
done
if (( "$base" < "${#bdirtoks[@]}" ))
then
echo ${bdirtoks[ $(( ${#bdirtoks[@]} - 1)) ]}
else
echo
fi
}
Anything to avoid the havoc caused by python dependencies. The above function seems to do what you need in lieu of realpath. It swaps the realpath dependency for readlink, which is already in coreutils.
Here's sample output:
cedarlug@dhs-scanner:~$ rootdir=/tmp backupdir=/usr/local cedar-realpath
../usr/local
cedarlug@dhs-scanner:~$ realpath --relative-to=/tmp /usr/local
../usr/local
cedarlug@dhs-scanner:~$ mkdir -p foo/bar/a/b/c
cedarlug@dhs-scanner:~$ mkdir -p foo/1/2/3
cedarlug@dhs-scanner:~$ cd foo/bar/
cedarlug@dhs-scanner:~/foo/bar$ pwd
/home/cedarlug/foo/bar
cedarlug@dhs-scanner:~/foo/bar$ backupdir=../1/2/ rootdir=a/b/c/ cedar-realpath
../../../../1/2
cedarlug@dhs-scanner:~/foo/bar$ realpath --relative-to=a/b/c ../1/2
../../../../1/2
Updated: show consistency with realpath.
I need to do more thorough error handling, but you can try this as a command_backup.sh replacement.
Report back your findings and I'll work on error handling/cleanups in preparation for a PR.
cedarlug, i have same problem on Ubuntu 14.04 LTS your script works correctly, thx :)
Hi,
I hit the same bug as @smw too, same OS. Installing realpath package also resulted in unsupported flag.
@cedarlug command_backup.sh replacement did the trick.
BR Draakuns
A fix from cedarlug is on its way ;)
Any update on this? @cedarlug
My assertion is that a simple mkdir -p {$backupdir} prior to the relpath bash script replacement that was composed for the fix addresses everything and that the PR that was made solves the issue.
I was unable to confirm because of the issues with travis, and stopped banging my head against the wall when it became clear that there was more pain being inflicted on my head than on travis.
Backup appears to be broken on ubuntu/debian systems, because
realpath
is not shipped with the coreutils on deb/ubuntu: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693211.There is a separate 'realpath' package, but that version doesn't appear to support the
--relative-to
argument.This appears to be caused by this PR: #1676 , which is a fix for this bug: #1563
Perhaps the usage of
realpath
could be replaced byreadlink -f
somehow?