Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options for output folder and filename to createBackup.sh #543

Merged
merged 2 commits into from
Jan 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions buildroot-external/overlay/base-raspmatic/bin/createBackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,34 @@

BACKUPDIR=/usr/local/tmp

if [ -n "${1}" ]; then
BACKUPDIR=$1
source /VERSION 2>/dev/null

BACKUPFILE="$(hostname)-${VERSION}-$(date +%Y-%m-%d-%H%M).sbk"

if [[ $# -eq 1 ]]
then
BACKUPDIR=$1
else
while [[ $# -gt 0 ]]
do
key="$1"

case $key in
-f|--file)
BACKUPFILE="$2"
shift # past argument
shift # past value
;;
-o|--output)
BACKUPDIR="$2"
shift # past argument
shift # past value
;;
*) # unknown option
shift # past argument
;;
esac
done
fi

# make sure BACKUPDIR exists
Expand All @@ -42,11 +68,10 @@ crypttool -s -t 1 <${TMPDIR}/usr_local.tar.gz >${TMPDIR}/signature
crypttool -g -t 1 >${TMPDIR}/key_index

# store the firmware VERSION
source /VERSION 2>/dev/null
cp /VERSION ${TMPDIR}/firmware_version

# create sbk file
tar -C ${TMPDIR} --owner=root --group=root -cf ${BACKUPDIR}/"$(hostname)-${VERSION}-$(date +%Y-%m-%d-%H%M).sbk" usr_local.tar.gz signature key_index firmware_version 2>/dev/null
tar -C ${TMPDIR} --owner=root --group=root -cf ${BACKUPDIR}/${BACKUPFILE} usr_local.tar.gz signature key_index firmware_version 2>/dev/null

# remove all temp files
rm -rf ${TMPDIR}