#!/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) # NOTE: to customize your backups, create a backuptool.conf file in # /storage/.config like this: # LOCATIONS=( # /storage/.config/retroarch/* # /storage/roms/savestates/* # /some/other/folder/file.name* # ) BACKUPFOLDER="/storage/roms/backup" BACKUPFILE="${BACKUPFOLDER}/JELOS_BACKUP.zip" mkdir -p ${BACKUPFOLDER} 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 /storage/.emulationstation/scripts/* ) if [ -e "/storage/.config/backuptool.conf" ] then source /storage/.config/backuptool.conf if [ ! $? = 0 ] then WARN="Error loading custom backuptool configs. Using defaults." ${DEBUG} && echo "${WARN}" logger -t backuptool "${WARN}" COMPRESSLOCATIONS=(${DEFAULT[@]}) else COMPRESSLOCATIONS=(${LOCATIONS[@]}) fi else COMPRESSLOCATIONS=(${DEFAULT[@]}) fi case "${1}" in "restore") systemctl stop ${UI_SERVICE} unzip -o ${BACKUPFILE} -d / systemctl start ${UI_SERVICE} ;; "backup") if [ -f ${BACKUPFILE} ] then TODAY=`date +%y-%m-%d_%H_%M_%S` ARCHIVEFILENAME="ARCHIVED_JELOS_BACKUP-${TODAY}.zip" mv ${BACKUPFILE} "${BACKUPFOLDER}/${ARCHIVEFILENAME}" fi [ -f "${BACKUPFILE}" ] && rm "${BACKUPFILE}" [ -z "$2" ] && systemctl stop ${UI_SERVICE} zip -9 -r ${BACKUPFILE} \ ${COMPRESSLOCATIONS[@]} [ -z "${2}" ] && systemctl start ${UI_SERVICE} ;; esac