2 Commits

Author SHA1 Message Date
Olli Graf
b43444d441 Zweiter Aufrufparameter ist jetzt der Hostname des Pis.
Der Dateiname derBackupdatei wird selbstständig mit Datum zusammengebaut.
2023-10-08 14:49:15 +02:00
Olli Graf
23979a0859 rmoldest in purgerepo umbenannt. 2023-09-29 07:20:34 +02:00
2 changed files with 31 additions and 2 deletions

View File

@@ -1,11 +1,27 @@
#! /bin/bash
VERSION="1.00"
BACKUP_REPO="/tank/Backup-Repo"
TEMP_DIR="${HOME}/backup"
VERSION="1.01"
CMD_COMPRESS='pbzip2'
verbose=false
testmode=false
bzip2=false
if [ $# -ne 2 ]
then
echo "Usage: backupsd <src_device> <target_file>"
echo "Please try again."
exit 1
fi
if !command -v dd > /dev/null 2>&1
then
echo "required command dd is not installed."
echo " Please check."
exit 2
fi
function isolate_checksum() {
checksum=($(echo ${1} | tr " " "\n"[0]))
@@ -13,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
@@ -32,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"
@@ -73,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

View File

@@ -6,6 +6,7 @@ files_to_remove=$(find . -maxdepth 1 -type f|cut -c3-|xargs ls -t|tail -3)
echo "eldest files ${files_toremove}"
for backupfile in ${files_to_remove}; do
echo "deleting backup ${backupfile}"
rm -f "${backupfile}"
done