distribution/packages/jelos/sources/scripts/backuptool

70 lines
1.9 KiB
Text
Raw Normal View History

2022-02-05 14:23:32 +00:00
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020-present Shanti Gilbert (https://github.com/shantigilbert)
# Copyright (C) 2020 Fewtarius (https://github.com/fewtarius)
2022-06-06 21:48:32 +00:00
# NOTE: to customize your backups, create a backuptool.conf file in
# /storage/.config like this:
2022-02-05 14:23:32 +00:00
2022-06-06 21:48:32 +00:00
# LOCATIONS=(
# /storage/.config/retroarch/*
# /storage/roms/savestates/*
# /some/other/folder/file.name*
# )
BACKUPFOLDER="/storage/roms/backup"
2022-06-07 18:58:21 +00:00
BACKUPFILE="${BACKUPFOLDER}/JELOS_BACKUP.zip"
mkdir -p ${BACKUPFOLDER}
2022-06-06 21:48:32 +00:00
DEFAULT=(
/storage/.config/fancontrol.conf
/storage/.config/backuptool.conf
/storage/.cache/bluetooth/*
/storage/.cache/connman*
/storage/.config/system/configs/system.cfg
/storage/.config/ppsspp/*
/storage/.config/retroarch/*
/storage/.config/moonlight/*
/storage/.config/game/*
/storage/.emulationstation/es_*.cfg
2022-02-05 14:23:32 +00:00
/storage/.emulationstation/scripts/*
2022-06-06 21:48:32 +00:00
)
if [ -e "/storage/.config/backuptool.conf" ]
then
source /storage/.config/backuptool.conf
if [ ! $? = 0 ]
then
WARN="Error loading custom backuptool configs. Using defaults."
2022-06-07 18:58:21 +00:00
${DEBUG} && echo "${WARN}"
2022-06-06 21:48:32 +00:00
logger -t backuptool "${WARN}"
COMPRESSLOCATIONS=(${DEFAULT[@]})
else
COMPRESSLOCATIONS=(${LOCATIONS[@]})
fi
else
COMPRESSLOCATIONS=(${DEFAULT[@]})
fi
case "${1}" in
"restore")
systemctl stop ${UI_SERVICE}
2022-06-06 21:48:32 +00:00
unzip -o ${BACKUPFILE} -d /
systemctl start ${UI_SERVICE}
2022-06-06 21:48:32 +00:00
;;
"backup")
2022-06-07 18:58:21 +00:00
if [ -f ${BACKUPFILE} ]
then
TODAY=`date +%y-%m-%d_%H_%M_%S`
ARCHIVEFILENAME="ARCHIVED_JELOS_BACKUP-${TODAY}.zip"
mv ${BACKUPFILE} "${BACKUPFOLDER}/${ARCHIVEFILENAME}"
fi
2022-06-06 21:48:32 +00:00
[ -f "${BACKUPFILE}" ] && rm "${BACKUPFILE}"
[ -z "$2" ] && systemctl stop ${UI_SERVICE}
2022-06-06 21:48:32 +00:00
zip -9 -r ${BACKUPFILE} \
${COMPRESSLOCATIONS[@]}
[ -z "${2}" ] && systemctl start ${UI_SERVICE}
2022-06-06 21:48:32 +00:00
;;
esac