Fix a couple of issues with restore

* Some variable expansions were unquoted
* *.arktribe etc. were missing
* tar status test was not detecting failures
This commit is contained in:
Ben Peddell 2020-06-13 23:32:59 +10:00 committed by GitHub
parent fd42917408
commit fa979793a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3097,35 +3097,42 @@ doRestore(){
local savedcfgdir="${saverootdir}/Config/LinuxServer"
local savedir="$(getSavedArksDirectory "${saverootdir}")"
local savedir="$(getSavedArksDirectory "${saverootdir}")"
local restorePath=
if [[ $# -ne 0 ]] ; then
backupFile=$1
else
backupFile=$(find ${arkbackupdir}/ -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1)
backupFile=$(find "${arkbackupdir}/" -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1)
fi
if [[ ! -f $backupFile ]] ; then
if [[ ! -f "$backupFile" ]] ; then
if [[ -f "$arkbackupdir/$backupFile" ]] ; then
backupFile="$arkbackupdir/$backupFile"
else
echo File $backupFile not found.
echo "File $backupFile" not found."
exit -1
fi
fi
echo restore ${backupFile}
for file in $(tar -tjf ${backupFile}) ; do
# ini are the config files
if [[ $file == *.ini ]] ; then
tar xjvf $backupFile -C ${savedcfgdir} --strip-components=1 $file
fi # ark file in savedir
if [[ $file == *.ark ]] ; then
tar xjvf $backupFile -C ${savedir} --strip-components=1 $file
fi # arkprofile in config dir
if [[ $file == *.arkprofile ]] ; then
tar xjvf $backupFile -C ${savedir} --strip-components=1 $file
fi
if [[ $? ]] ; then
echo -e "${NORMAL}\e[68G[ ${GREEN}OK${NORMAL} ]"
else
echo -e "${NORMAL}\e[68G[ ${RED}FAILED${NORMAL} ]"
echo "Restoring from ${backupFile}"
for file in $(tar -tjf "${backupFile}") ; do
restorePath=
case "${file}" in
SaveGames/*) # mod persistent info
restorePath="${saverootdir}"
;;
*.ini) # ini are the config files
restorePath="${savedcfgdir}"
;;
*.ark|*.arkprofile|*.arktribe|*.arktributetribe) # ark file in savedir
restorePath="${savedir}"
;;
esac
if [ -n "${restorePath}" ]; then
echo "Restoring ${file} to ${restorePath}"
tar -xjvf "${backupFile}" -C "${restorePath}" --strip-components=1 "${file}"
if [ $? == 0 ] ; then
echo -e "${NORMAL}\e[68G[ ${GREEN}OK${NORMAL} ]"
else
echo -e "${NORMAL}\e[68G[ ${RED}FAILED${NORMAL} ]"
fi
fi
done
echo -e "${NORMAL}Restore Complete \e[68G[ ${GREEN}OK${NORMAL} ]"