Zweiter Aufrufparameter ist jetzt der Hostname des Pis.

Der Dateiname derBackupdatei wird selbstständig mit Datum zusammengebaut.
This commit is contained in:
Olli Graf
2023-10-08 14:49:15 +02:00
parent 23979a0859
commit b43444d441

View File

@@ -1,6 +1,8 @@
#! /bin/bash #! /bin/bash
VERSION="1.00" BACKUP_REPO="/tank/Backup-Repo"
TEMP_DIR="${HOME}/backup"
VERSION="1.01"
CMD_COMPRESS='pbzip2' CMD_COMPRESS='pbzip2'
verbose=false verbose=false
testmode=false testmode=false
@@ -27,6 +29,12 @@ checksum=($(echo ${1} | tr " " "\n"[0]))
echo "${checksum}" echo "${checksum}"
} }
function format_date() {
tdate=$(date '+%y-%m-%d')
echo "${tdate}"
}
function start_backup { function start_backup {
echo "starting Backup" echo "starting Backup"
sudo dd if=${DEVICE} bs=8M|pv| dd of=${FILE} bs=8M sudo dd if=${DEVICE} bs=8M|pv| dd of=${FILE} bs=8M
@@ -46,6 +54,9 @@ echo "sha512dest= ${sha512dest}"
if [ "${sha512src}" = "${sha512dest}" ]; then if [ "${sha512src}" = "${sha512dest}" ]; then
echo "compressing image with ${CMD_COMPRESS}" echo "compressing image with ${CMD_COMPRESS}"
${CMD_COMPRESS} ${FILE} ${CMD_COMPRESS} ${FILE}
echo "moving compressed image to repo"
FILE="${FILE}.bz2"
mv ${FILE} "${BACKUP_REPO}/${HOSTNAME}"
exit 0 exit 0
else else
echo "checksum verify failed, exiting" echo "checksum verify failed, exiting"
@@ -87,7 +98,10 @@ fi
echo "1=${1} 2=${2}" echo "1=${1} 2=${2}"
DEVICE=${1} DEVICE=${1}
FILE=${2} HOSTNAME=${2}
bdate=$(format_date)
echo "bdate=${bdate}"
FILE="${TEMP_DIR}/${HOSTNAME}-${bdate}.img"
#if [[ ${bzip2} -eq true ]] ; then #if [[ ${bzip2} -eq true ]] ; then
#if [[ echo "${bzip2}" |grep "true" ]] ; then #if [[ echo "${bzip2}" |grep "true" ]] ; then