distribution/packages/jelos/sources/scripts/backuptool

70 lines
2 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) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
2022-02-05 14:23:32 +00:00
. /etc/profile
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"
BACKUPFILE="${BACKUPFOLDER}/${OS_NAME}_BACKUP.zip"
2022-06-07 18:58:21 +00:00
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/*
/storage/.emulationstation/themesettings/*
$(find /storage/.emulationstation/themes/* -type d -maxdepth 0 -not -path "*es-theme-art-book-next" -not -path "*system-theme")
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")
unzip -o ${BACKUPFILE} -d /
;;
"backup")
2022-06-07 18:58:21 +00:00
if [ -f ${BACKUPFILE} ]
then
TODAY=`date +%y-%m-%d_%H_%M_%S`
ARCHIVEFILENAME="ARCHIVED_${OS_NAME}_BACKUP-${TODAY}.zip"
2022-06-07 18:58:21 +00:00
mv ${BACKUPFILE} "${BACKUPFOLDER}/${ARCHIVEFILENAME}"
fi
2022-06-06 21:48:32 +00:00
[ -f "${BACKUPFILE}" ] && rm "${BACKUPFILE}"
zip -9 -r ${BACKUPFILE} \
${COMPRESSLOCATIONS[@]}
;;
esac