Skip to content

Commit

Permalink
Updated cpy
Browse files Browse the repository at this point in the history
  • Loading branch information
framps committed Oct 19, 2018
1 parent 7eec715 commit ca4b649
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 73 deletions.
Binary file added extensions/raspiBackupSampleExtensions.tgz
Binary file not shown.
12 changes: 6 additions & 6 deletions extensions/raspiBackup_disk_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ ext_diskUsage_post=( $(getDiskUsage) )

# set any messages and prefix message name with ext_ and some unique prefix to use a different namespace than the script
MSG_EXT_DISK_USAGE="ext_diskusage_2"
MSG_EN[$MSG_EXT_DISK_USAGE]="--- RBK1002I: Disk usage pre backup: Used: %1 Free: %2"
MSG_DE[$MSG_EXT_DISK_USAGE]="--- RBK1002I: Partitionsauslastung vor dem Backup: Belegt: %1 Frei: %2"
MSG_EN[$MSG_EXT_DISK_USAGE]="--- RBK1002I: Disk usage pre backup: Used: %s Free: %s"
MSG_DE[$MSG_EXT_DISK_USAGE]="--- RBK1002I: Partitionsauslastung vor dem Backup: Belegt: %s Frei: %s"
MSG_EXT_DISK_USAGE2="ext_diskusage_3"
MSG_EN[$MSG_EXT_DISK_USAGE2]="--- RBK1003I: Disk usage post backup: Used: %1 Free: %2"
MSG_DE[$MSG_EXT_DISK_USAGE2]="--- RBK1003I: Partitionsauslastung nach dem Backup: Belegt: %1 Frei: %2"
MSG_EN[$MSG_EXT_DISK_USAGE2]="--- RBK1003I: Disk usage post backup: Used: %s Free: %s"
MSG_DE[$MSG_EXT_DISK_USAGE2]="--- RBK1003I: Partitionsauslastung nach dem Backup: Belegt: %s Frei: %s"
MSG_EXT_DISK_USAGE3="ext_diskusage_4"
MSG_EN[$MSG_EXT_DISK_USAGE3]="--- RBK1004I: Free change: %1 (%2 %)"
MSG_DE[$MSG_EXT_DISK_USAGE3]="--- RBK1004I: Änderung freier Platz: %1 (%2 %)"
MSG_EN[$MSG_EXT_DISK_USAGE3]="--- RBK1004I: Free change: %s (%s %)"
MSG_DE[$MSG_EXT_DISK_USAGE3]="--- RBK1004I: Änderung freier Platz: %s (%s %)"
MSG_EXT_DISK_USAGE4="ext_diskusage_5"
MSG_EN[$MSG_EXT_DISK_USAGE4]="--- RBK1005E: bc not found. Please install bc first."
MSG_DE[$MSG_EXT_DISK_USAGE4]="--- RBK1004E: bc nicht gefunden. bc muss installiert werden."
Expand Down
12 changes: 6 additions & 6 deletions extensions/raspiBackup_execute_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#
# Function: Call another script
#
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
#
# $1 has the return code of raspiBackup. If it equals 0 this signals success and failure otherwise
#
#######################################################################################################################
#
# Copyright (C) 2016-2017 framp at linux-tips-and-tricks dot de
# Copyright (C) 2016-2018 framp at linux-tips-and-tricks dot de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -30,15 +30,15 @@
#######################################################################################################################

if [[ -n $1 ]]; then # was there a return code ? Should be :-)
if [[ "$1" == 0 ]]; then
if [[ "$1" == 0 ]]; then
wall <<< "Extension detected ${0##*/} succeeded :-)"
else
wall <<< "Extension detected ${0##*/} failed :-("
fi
else
wall <<< "Extension detected ${0##*/} didn't receive a return code :-("
fi




18 changes: 9 additions & 9 deletions extensions/raspiBackup_fstab_ready.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

#
# extensionpoint for raspiBackup.sh
# called before dd, tar or rsync backup is started
#
# called before dd, tar or rsync backup is started
#
# Function: Copy /etc/fstab into backupdirectory
#
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
#
# (C) 201i7 - framp at linux-tips-and-tricks dot de
#

# set any messages and prefix message name with ext_ and some unique prefix to use a different namespace than the script
MSG_EXT_FSTAB_COPY="ext_fstab_copy"
MSG_EN[$MSG_EXT_FSTAB_COPY]="--- RBK1005I: Copy %1 to %2"
MSG_DE[$MSG_EXT_FSTAB_COPY]="--- RBK1005I: Kopiere %1 in %2"
MSG_EN[$MSG_EXT_FSTAB_COPY]="--- RBK1005I: Copy %s to %s"
MSG_DE[$MSG_EXT_FSTAB_COPY]="--- RBK1005I: Kopiere %s in %s"

FSTAB_FILENAME="/etc/fstab"
FSTAB_TARGET_DIR="raspiBackup/extensionSaveArea"
TARGET_DIR="$BACKUPTARGET_DIR/$FSTAB_TARGET_DIR"

# write message to console
# write message to console
writeToConsole $MSG_LEVEL_MINIMAL $MSG_EXT_FSTAB_COPY "$FSTAB_FILENAME" "$TARGET_DIR"

if [[ -f "$FSTAB_FILENAME" ]]; then
mkdir -p "$TARGET_DIR"
extrc=$?
[[ $extrc != 0 ]] && return $extrc
[[ $extrc != 0 ]] && return $extrc
cp "$FSTAB_FILENAME" "$TARGET_DIR"
ls -la "$TARGET_DIR"
return $?
else
return $?
else
return 1 // terminate raspiBackup
fi

6 changes: 3 additions & 3 deletions extensions/raspiBackup_mem_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ ext_freememory_post=( $(getMemoryFree) )

# set any messages and prefix message name with ext_ and some unique prefix to use a different namespace than the script
MSG_EXT_DISK_FREE="ext_freememory_1"
MSG_EN[$MSG_EXT_DISK_FREE]="--- RBK1001I: Memory usage - Pre backup: Used: %1 Free: %2 - Post backup - Used: %3 Free: %4"
MSG_DE[$MSG_EXT_DISK_FREE]="--- RBK1001I: Speicherauslastung - Vor dem Backup: Belegt: %1 Frei: %2 - Nach dem Backup: Belegt: %3 Frei: %4"
MSG_EN[$MSG_EXT_DISK_FREE]="--- RBK1001I: Memory usage - Pre backup - Used: %s MB Free: %s MB - Post backup - Used: %s MB Free: %s MB"
MSG_DE[$MSG_EXT_DISK_FREE]="--- RBK1001I: Speicherauslastung - Vor dem Backup - Belegt: %s MB Frei: %s MB - Nach dem Backup: Belegt: %s MB Frei: %s MB"

# now write message to console and log and email
# $MSG_LEVEL_MINIMAL will write message all the time
# $MSG_LEVEL_DETAILED will write message only if -m 1 parameter was used
writeToConsole $MSG_LEVEL_MINIMAL $MSG_EXT_DISK_FREE "$(bytesToHuman ${ext_freememory_pre[0]})" "$(bytesToHuman ${ext_freememory_pre[1]})" "$(bytesToHuman ${ext_freememory_post[0]})" "$(bytesToHuman ${ext_freememory_post[1]})"
writeToConsole $MSG_LEVEL_MINIMAL $MSG_EXT_DISK_FREE "${ext_freememory_pre[0]}" "${ext_freememory_pre[1]}" "${ext_freememory_post[0]}" "${ext_freememory_post[1]}"



30 changes: 2 additions & 28 deletions extensions/raspiBackup_mem_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,10 @@

# define functions needed
# use local for all variables used so the script namespace is not poluted
#
# wheezy
#free
# total used free shared buffers cached
#Mem: 494096 468232 25864 0 117024 40384
#-/+ buffers/cache: 310824 183272
#Swap: 102396 29212 73184

# stretch
#free
# total used free shared buff/cache available
#Mem: 1000312 189232 293088 12936 517992 737980
#Swap: 102396 0 102396

function getMemoryFree() {
local f="$(free)"
if grep "^-" <<< "$f"; then
local e=$(grep "^-" <<< "$f" | cut -d ':' -f 2)
local u="${e[0]}"
local f="${e[1]}"
else
local e=( $(grep "^Mem:" <<< "$f") )
local u="${e[2]}"
local f="${e[6]}"
fi
local usedInBytes="$(bc <<< "$u*1024")"
local freeInBytes="$(bc <<< "$f*1024")"

echo "$usedInBytes $freeInBytes"

local temp=$(free -m | grep "^-" | cut -d ':' -f 2)
echo "$(echo $temp)"
}

# set any variables and prefix all names with ext_ and some unique prefix to use a different namespace than the script
Expand Down
8 changes: 4 additions & 4 deletions extensions/raspiBackup_temp_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#
# Function: Display CPU temperature
#
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
#
#######################################################################################################################
#
# Copyright (C) 2015-2017 framp at linux-tips-and-tricks dot de
# Copyright (C) 2015-2018 framp at linux-tips-and-tricks dot de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -31,8 +31,8 @@ ext_CPUTemp_post=$(getCPUTemp)

# set any messages and prefix message name with ext_ and some unique prefix to use a different namespace than the script
MSG_EXT_CPU_TEMPERATURE="ext_CPUTemp_1"
MSG_EN[$MSG_EXT_CPU_TEMPERATURE]="--- RBK1000I: CPU temperature pre and post backup: %1 - %2"
MSG_DE[$MSG_EXT_CPU_TEMPERATURE]="--- RBK1000I: CPU Temperatur vor und nach dem Backup: %1 - %2"
MSG_EN[$MSG_EXT_CPU_TEMPERATURE]="--- RBK1000I: CPU temperature pre and post backup: %s - %s"
MSG_DE[$MSG_EXT_CPU_TEMPERATURE]="--- RBK1000I: CPU Temperatur vor und nach dem Backup: %s - %s"

# now write message to console and log and email
# $MSG_LEVEL_MINIMAL will write message all the time
Expand Down
19 changes: 2 additions & 17 deletions extensions/raspiBackup_temp_pre.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

#
# Plugin for raspiBackup.sh
# extensionpoint for raspiBackup.sh
# called before a backup is started
#
# Function: Display CPU temperature
Expand All @@ -9,22 +10,6 @@
#
# (C) 2015 - framp at linux-tips-and-tricks dot de
#
# Copyright (C) 2015-2017 framp at linux-tips-and-tricks dot de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
#
#######################################################################################################################

# define functions needed
# use local for all variables so the script namespace is not polluted
Expand Down

0 comments on commit ca4b649

Please sign in to comment.