From b43444d4416ade970e9dad1e639a9d8543e6fd14 Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Sun, 8 Oct 2023 14:49:15 +0200 Subject: [PATCH] =?UTF-8?q?Zweiter=20Aufrufparameter=20ist=20jetzt=20der?= =?UTF-8?q?=20Hostname=20des=20Pis.=20Der=20Dateiname=20derBackupdatei=20w?= =?UTF-8?q?ird=20selbstst=C3=A4ndig=20mit=20Datum=20zusammengebaut.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backupsd | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/backupsd b/backupsd index 6410daf..5b9aca1 100755 --- a/backupsd +++ b/backupsd @@ -1,6 +1,8 @@ #! /bin/bash -VERSION="1.00" +BACKUP_REPO="/tank/Backup-Repo" +TEMP_DIR="${HOME}/backup" +VERSION="1.01" CMD_COMPRESS='pbzip2' verbose=false testmode=false @@ -27,6 +29,12 @@ checksum=($(echo ${1} | tr " " "\n"[0])) echo "${checksum}" } +function format_date() { +tdate=$(date '+%y-%m-%d') + + echo "${tdate}" +} + function start_backup { echo "starting Backup" sudo dd if=${DEVICE} bs=8M|pv| dd of=${FILE} bs=8M @@ -46,6 +54,9 @@ echo "sha512dest= ${sha512dest}" if [ "${sha512src}" = "${sha512dest}" ]; then echo "compressing image with ${CMD_COMPRESS}" ${CMD_COMPRESS} ${FILE} + echo "moving compressed image to repo" + FILE="${FILE}.bz2" + mv ${FILE} "${BACKUP_REPO}/${HOSTNAME}" exit 0 else echo "checksum verify failed, exiting" @@ -87,7 +98,10 @@ fi echo "1=${1} 2=${2}" DEVICE=${1} -FILE=${2} +HOSTNAME=${2} +bdate=$(format_date) +echo "bdate=${bdate}" +FILE="${TEMP_DIR}/${HOSTNAME}-${bdate}.img" #if [[ ${bzip2} -eq true ]] ; then #if [[ echo "${bzip2}" |grep "true" ]] ; then