code cleanup, fixes

This commit is contained in:
Hartmut Bauer committed 2025-04-11 22:38:56 +02:00
1 parent a6dd1d3e2c
commit 3dfb79779c
2 files changed
+245 -130

No files matched your search

+244 -129
View File
@@ -14,6 +14,7 @@ EXT=tgz.gpg
LIST_EXT=txt LIST_EXT=txt
DOCKER="/usr/bin/docker compose -f /var/docker/run/docker-compose.yml --ansi never" DOCKER="/usr/bin/docker compose -f /var/docker/run/docker-compose.yml --ansi never"
SYNO_USB=/usr/syno/bin/synousbdisk
LOG_RECIPIENT=hb242@pm.me LOG_RECIPIENT=hb242@pm.me
INFO=INFO INFO=INFO
@@ -26,70 +27,7 @@ WRN=":::"
ERR="###" ERR="###"
DBG="===" DBG="==="
dump_mariadb() { # ----- logging -----
log $DEBUG "$DBG dump_mariadb( $@ )"
local dump_dir=$1
local mysqlconnect="--user=root --password=snafu"
log $DEBUG "$DBG > \$DOCKER exec mysql /usr/bin/mariadb --silent --user=xxx --password=xxx -e \"show databases\" -B"
for db in $($DOCKER exec mysql /usr/bin/mariadb --silent $mysqlconnect -e "show databases" -B 2>>$LOG_FILE | grep -v information_schema 2>>$LOG_FILE | grep -v performance_schema 2>>$LOG_FILE | sed -e 's/\r//' 2>>$LOG_FILE); do
log $DEBUG "$DBG > \$DOCKER exec mysql /usr/bin/mariadb-dump --hex-blob --user=xxx --password=xxx --databases $db"
$DOCKER exec mysql /usr/bin/mariadb-dump --hex-blob $mysqlconnect --databases $db >$dump_dir/$db.sql 2>>$LOG_FILE
is_error $? false && return 1
done
return 0
}
dump_postgresql() {
log $DEBUG "$DBG dump_postgresql( $@ )"
local dump_dir=$1
# users and roles
log $DEBUG "$DBG > \$DOCKER exec -u=postgres postgres pg_dumpall --globals-only"
$DOCKER exec -u=postgres postgres pg_dumpall --globals-only > $dump_dir/_globals.sql 2>>$LOG_FILE
log $DEBUG "$DBG \$DOCKER exec -u=postgres postgres psql -t -c \"select datname from pg_database where not datistemplate\""
for db in $($DOCKER exec -u=postgres postgres psql -t -c "select datname from pg_database where not datistemplate" 2>>$LOG_FILE); do
log $DEBUG "$DBG > \$DOCKER exec -u=postgres postgres pg_dump --create $db"
$DOCKER exec -u=postgres postgres pg_dump --create $db > $dump_dir/$db.sql 2>>$LOG_FILE
is_error $? false && return 1
done
return 0
}
start_docker() {
log $DEBUG "$DBG start_docker()"
log $DEBUG "$DBG > \$DOCKER up -d"
$DOCKER up -d >>$LOG_FILE 2>&1
return $?
}
stop_docker() {
log $DEBUG "$DBG stop_docker()"
log $DEBUG "$DBG > \$DOCKER down"
$DOCKER down >>$LOG_FILE 2>&1
return $?
}
# Script per ssh auf Server $1 im Hintergrund starten
#
# ssh start in background
# -> https://stackoverflow.com/questions/29142/getting-ssh-to-execute-a-command-in-the-background-on-target-machine#comment107117479_29172
#
# $1 - Server
# $@ - Script incl. Parameter
#
run_script_remote() {
local server=$1
shift
ssh $server "sudo sh -c 'nohup $@ &>/dev/null </dev/null &'"
}
# check if function $1 exists
#
# returns true/false
#
isFunction() { declare -Ff "$1" ; }
# Log-Datei schreiben. # Log-Datei schreiben.
# #
@@ -128,7 +66,7 @@ send_mail_log() {
local subject="$@" local subject="$@"
log $DEBUG "$DBG send_mail_log()" log $DEBUG "$DBG send_mail_log()"
log $DEBUG "$DBG > $HERE/mail.sh $LOG_RECIPIENT \"[$HOST_NAME] $subject\" $MAIL_LOG_FILE" log $DEBUG "$DBG > $HERE/mail.sh $LOG_RECIPIENT \"[$HOST_NAME] $subject\" $MAIL_LOG_FILE"
$HERE/mail.sh $LOG_RECIPIENT "[$HOST_NAME] Nightly Backup" $MAIL_LOG_FILE >>$LOG_FILE 2>&1 $HERE/mail.sh $LOG_RECIPIENT "[$HOST_NAME] $subject" $MAIL_LOG_FILE >>$LOG_FILE 2>&1
} }
# Alte Logs löschen # Alte Logs löschen
@@ -137,13 +75,82 @@ prune_logs() {
log $DEBUG "$DBG prune_logs()" log $DEBUG "$DBG prune_logs()"
# Dateien älter als 14 Tage löschen # Dateien älter als 14 Tage löschen
log $DEBUG "$DBG > find \"$LOG_FILE_PATH\" -type f -mtime +14 -delete" log $DEBUG "$DBG > find \"$LOG_FILE_PATH\" -type f -mtime +14 -delete"
find "$LOG_FILE_PATH" -type f -mtime +14 -delete &>>$LOG_FILE find "$LOG_FILE_PATH" -type f -mtime +14 -delete >>$LOG_FILE 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# Fehler nur protokollieren, kein Grund abzubrechen # Fehler nur protokollieren, kein Grund abzubrechen
mail_log $ERROR "$ERR error deleting old log files." mail_log $ERROR "$ERR error deleting old log files."
fi fi
} }
# ----- db dump -----
dump_mariadb() {
log $DEBUG "$DBG dump_mariadb( $@ )"
local dump_dir=$1
local mysqlconnect="--user=root --password=snafu"
log $DEBUG "$DBG > \$DOCKER exec mysql /usr/bin/mariadb --silent --user=xxx --password=xxx -e \"show databases\" -B"
for db in $($DOCKER exec mysql /usr/bin/mariadb --silent $mysqlconnect -e "show databases" -B 2>>$LOG_FILE | grep -v information_schema 2>>$LOG_FILE | grep -v performance_schema 2>>$LOG_FILE | sed -e 's/\r//' 2>>$LOG_FILE); do
log $DEBUG "$DBG > \$DOCKER exec mysql /usr/bin/mariadb-dump --hex-blob --user=xxx --password=xxx --databases $db"
$DOCKER exec mysql /usr/bin/mariadb-dump --hex-blob $mysqlconnect --databases $db >$dump_dir/$db.sql 2>>$LOG_FILE
is_error $? false && return 1
done
return 0
}
dump_postgresql() {
log $DEBUG "$DBG dump_postgresql( $@ )"
local dump_dir=$1
# users and roles
log $DEBUG "$DBG > \$DOCKER exec -u=postgres postgres pg_dumpall --globals-only"
$DOCKER exec -u=postgres postgres pg_dumpall --globals-only > $dump_dir/_globals.sql 2>>$LOG_FILE
log $DEBUG "$DBG \$DOCKER exec -u=postgres postgres psql -t -c \"select datname from pg_database where not datistemplate\""
for db in $($DOCKER exec -u=postgres postgres psql -t -c "select datname from pg_database where not datistemplate" 2>>$LOG_FILE); do
log $DEBUG "$DBG > \$DOCKER exec -u=postgres postgres pg_dump --create $db"
$DOCKER exec -u=postgres postgres pg_dump --create $db > $dump_dir/$db.sql 2>>$LOG_FILE
is_error $? false && return 1
done
return 0
}
# ----- helper functions -----
start_docker() {
log $DEBUG "$DBG start_docker()"
log $DEBUG "$DBG > \$DOCKER up -d"
$DOCKER up -d >>$LOG_FILE 2>&1
return $?
}
stop_docker() {
log $DEBUG "$DBG stop_docker()"
log $DEBUG "$DBG > \$DOCKER down"
$DOCKER down >>$LOG_FILE 2>&1
return $?
}
# Script per ssh auf Server $1 im Hintergrund starten
#
# ssh start in background
# -> https://stackoverflow.com/questions/29142/getting-ssh-to-execute-a-command-in-the-background-on-target-machine#comment107117479_29172
#
# $1 - Server
# $@ - Script incl. Parameter
#
run_script_remote() {
local server=$1
shift
ssh $server "sudo sh -c 'nohup $@ &>/dev/null </dev/null &'"
}
# check if function $1 exists
#
# returns true/false
#
isFunction() { declare -Ff "$1" ; }
# check if $1 is error (!=0) and write result to log # check if $1 is error (!=0) and write result to log
# #
# $1 - return code to check # $1 - return code to check
@@ -278,6 +285,8 @@ delete_dir() {
return 1 return 1
} }
# ----- backup -----
# Slashes "/" im Pfadnamen durch Dashes "-" ersetzen, so dass der String als Dateiname verwendet werden kann. # Slashes "/" im Pfadnamen durch Dashes "-" ersetzen, so dass der String als Dateiname verwendet werden kann.
# #
# $1 - path # $1 - path
@@ -415,7 +424,7 @@ backup_daily() {
# ggf. weekly backup starten (z.ZT. nur auf NAS) # ggf. weekly backup starten (z.ZT. nur auf NAS)
if [ $HAS_WEEKLY -a $WEEKLY_DAY -eq $DAY ]; then if [ $HAS_WEEKLY -a $WEEKLY_DAY -eq $DAY ]; then
log $DEBUG "$DBG starting weekly backup" log $DEBUG "$DBG starting weekly backup"
nohup $THIS_SCRIPT -w &>>$LOG_FILE </dev/null & nohup $THIS_SCRIPT -w >>$LOG_FILE 2>&1 </dev/null &
fi fi
} }
backup_weekly() { backup_weekly() {
@@ -431,20 +440,7 @@ backup_weekly() {
send_mail_log "Weekly Backup" send_mail_log "Weekly Backup"
} }
# Inhalt des Archivs in eine Textdatei ausgeben. # ----- integrity -----
#
# $1 - Archiv
#
# returns 0 for success, 1 otherwise
#
create_list() {
log $DEBUG "$DBG create_list( $@ )"
local archive=$1
log $DEBUG "$DBG > gpg --batch --decrypt --passphrase xxxx \"$archive\" | tar -tzv | tee \"$archive.$LIST_EXT\""
gpg --batch --decrypt --passphrase $PASSPHRASE "$archive" 2>>$LOG_FILE | tar -tzv 2>>$LOG_FILE | tee "$archive.$LIST_EXT" >/dev/null 2>>$LOG_FILE
check_pipe_rc ${PIPESTATUS[@]}
return $?
}
# Integrität des Archivs testen, indem es entschlüsselt, entpackt # Integrität des Archivs testen, indem es entschlüsselt, entpackt
# und der Inhalt auf /dev/null ausgegeben wird. # und der Inhalt auf /dev/null ausgegeben wird.
@@ -462,6 +458,8 @@ test_integrity() {
return $? return $?
} }
# ----- restore -----
# Restore aus Archiv # Restore aus Archiv
# #
# Wird nach pwd ausgegeben! # Wird nach pwd ausgegeben!
@@ -481,6 +479,23 @@ restore() {
return $? return $?
} }
# ----- archive content ------
# Inhalt des Archivs in eine Textdatei ausgeben.
#
# $1 - Archiv
#
# returns 0 for success, 1 otherwise
#
create_list() {
log $DEBUG "$DBG create_list( $@ )"
local archive=$1
log $DEBUG "$DBG > gpg --batch --decrypt --passphrase xxxx \"$archive\" | tar -tzv | tee \"$archive.$LIST_EXT\""
gpg --batch --decrypt --passphrase $PASSPHRASE "$archive" 2>>$LOG_FILE | tar -tzv 2>>$LOG_FILE | tee "$archive.$LIST_EXT" >/dev/null 2>>$LOG_FILE
check_pipe_rc ${PIPESTATUS[@]}
return $?
}
# Liste der Archives auf stdout ausgeben # Liste der Archives auf stdout ausgeben
# #
# Zeigt alle Archive incl. Verzeichnis (ohne $1) an # Zeigt alle Archive incl. Verzeichnis (ohne $1) an
@@ -520,22 +535,61 @@ list_archive_content() {
cat "$root/${archive/#\//}.$LIST_EXT" 2>>$LOG_FILE cat "$root/${archive/#\//}.$LIST_EXT" 2>>$LOG_FILE
} }
# --- export --- # ----- export -----
# Synology-NAS (0) or not (1 - linux)?
#
is_synology() {
if [ -f $SYNO_USB ]; then
return 0
else
return 1
fi
}
# Find exfat formatted device
#
# returns device name
#
get_usb_device() {
if is_synology; then
echo $(get_usb_device_syno)
else
echo $(get_usb_device_linux)
fi
}
# USB-HDD auf Synology-NAS ermitteln
#
get_usb_device_syno() {
log $DEBUG "$DBG get_usb_device_syno()"
log $DEBUG "$DBG > $SYNO_USB -enum | grep -v devices | wc -l"
if [ "$($SYNO_USB -enum 2>>$LOG_FILE | grep -v devices 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then
mail_log $ERROR "$ERR no USB device or too many found @$HOST_NAME."
return 1
fi
log $DEBUG "$DBG > $SYNO_USB -enum | grep -v devices"
echo $($SYNO_USB -enum 2>>$LOG_FILE | grep -v devices 2>>$LOG_FILE)
return 0
}
# exfat-formatierte USB-HDD auf Linux-Server ermitteln # exfat-formatierte USB-HDD auf Linux-Server ermitteln
# #
get_usb_device() { get_usb_device_linux() {
log $DEBUG "$DBG get_usb_device_linux()"
local fstype=exfat local fstype=exfat
local lsblk="lsblk -o KNAME,TYPE,SIZE,MODEL,FSTYPE" local lsblk="lsblk -o KNAME,TYPE,SIZE,MODEL,FSTYPE"
local device local device
log $DEBUG "$DBG $lsblk | grep $fstype | wc -l"
if [ "$($lsblk 2>>$LOG_FILE | grep $fstype 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then if [ "$($lsblk 2>>$LOG_FILE | grep $fstype 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then
echo "ERROR could not query devices" mail_log $ERROR "$ERR could not query devices."
return 1 return 1
fi fi
log $DEBUG "$DBG $lsblk | grep $fstype | sed -E 's/^(\S*).*$/\1/'"
device=$($lsblk 2>>$LOG_FILE | grep $fstype 2>>$LOG_FILE | sed -E 's/^(\S*).*$/\1/' 2>>$LOG_FILE) device=$($lsblk 2>>$LOG_FILE | grep $fstype 2>>$LOG_FILE | sed -E 's/^(\S*).*$/\1/' 2>>$LOG_FILE)
if [ -z "$device" ]; then if [ -z "$device" ]; then
echo "ERROR no exfat USB device found" mail_log $ERROR "$ERR no exfat USB device found."
return 1 return 1
fi fi
@@ -543,42 +597,104 @@ get_usb_device() {
return 0 return 0
} }
# USB-HDD auf Linux-Server mounten # Mount UsB-HDD
# #
# $1 - device (ohne /dev/) # returns mount point
# #
mount_usb_device() { mount_usb_device() {
if is_synology; then
echo $(mount_usb_device_syno $1)
else
echo $(mount_usb_device_linux $1)
fi
}
# Check if auto mounted device is exfat and return mount point
# (fn for consitence with linux fn)
#
# $1 - device name
# returns mount point
#
mount_usb_device_syno() {
log $DEBUG "$DBG mount_usb_device_syno( $@ )"
local device=$1 local device=$1
local mount_point=/var/mnt/backup log $DEBUG "$DBG > $SYNO_USB -info $device | grep -i \"file system\" | sed -E \"s/.*:\s*(.*)\s*/\1/\""
check_directory $mount_point local fs=$($SYNO_USB -info $device 2>>$LOG_FILE | grep -i "file system" 2>>$LOG_FILE | sed -E "s/.*:\s*(.*)\s*/\1/" 2>>$LOG_FILE)
if [ $? -ne 0 ]; then if [ "$fs" != "exfat" ]; then
echo "ERROR mount point does't exist" mail_log $ERROR "$ERR device $device not exfat formatted."
return 1 return 1
fi fi
mount /dev/$device $mount_point >>$LOG_FILE 2>&1 # get mount point
if [ $? -ne 0 ]; then log $DEBUG "$DBG > $SYNO_USB -info $device | grep -i \"mount path\" | sed -E \"s/.*:\s*(.*)\s*/\1/\""
echo "ERROR mounting $device" local mount_point=$($SYNO_USB -info $device 2>>$LOG_FILE | grep -i "mount path" 2>>$LOG_FILE | sed -E "s/.*:\s*(.*)\s*/\1/" 2>>$LOG_FILE)
if [ $? -ne 0 ] || [ ! -d $mount_point ]; then
mail_log $ERROR "$ERR mount point \"$mount_point\" does not exist."
return 1 return 1
fi fi
echo $mount_point echo $mount_point
return 0 return 0
} }
# USB-HDD auf Linux-Server unmounten # USB-HDD auf Linux-Server mounten
# #
# $1 - mount point # $1 - device (ohne /dev/)
# return moint point
# #
umount_usb_device() { mount_usb_device_linux() {
local mount_point=$1 log $DEBUG "$DBG mount_usb_device_linux( $@ )"
local device=$1
umount $mount_point >>$LOG_FILE 2>&1 local mount_point=/var/mnt/backup
check_directory $mount_point
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR unmounting $mount_point" mail_log $ERROR "$ERR mount point \"$mount_point\" does not exist."
return 1 return 1
fi fi
log $DEBUG "$DBG mount /dev/$device $mount_point"
mount /dev/$device $mount_point >>$LOG_FILE 2>&1
if [ $? -ne 0 ]; then
mail_log $ERROR "$ERR mounting /dev/$device failed."
return 1
fi
echo $mount_point
return 0 return 0
} }
# unmount USB-HDD
#
umount_usb_device() {
if is_synology; then
umount_usb_device_syno $1
return $?
else
umount_usb_device_linux $1
return $?
fi
}
# USB-HDD auf Synology-NAS unmounten
#
# $1 - device name
#
umount_usb_device_syno() {
local device=$1
log $DEBUG "$DBG umount_usb_device_syno( $@ )"
log $DEBUG "$DBG > $SYNO_USB -umount $device"
$SYNO_USB -umount $device >>$LOG_FILE 2>&1
return $?
}
# USB-HDD auf Linux-Server unmounten
#
# $1 - device (ohne /dev/)
#
umount_usb_device_linux() {
local device=/dev/$1
log $DEBUG "$DBG umount_usb_device_linux( $@ )"
log $DEBUG "$DBG > umount $device"
umount $device >>$LOG_FILE 2>&1
return $?
}
# USB-HDD suchen und Backup-Typ ermitteln # USB-HDD suchen und Backup-Typ ermitteln
# #
# Der Typ wird über eine Datei auf der USB-HDD festgelegt: # Der Typ wird über eine Datei auf der USB-HDD festgelegt:
@@ -594,14 +710,14 @@ check_backup_device() {
log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | wc -l" log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | wc -l"
if [ "$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then if [ "$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then
mail_log $ERROR "$ERR no tag found on device at $mount_point" mail_log $ERROR "$ERR no tag found on device at $mount_point."
return 1 return 1
fi fi
log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | sed -E \"s/.*$tagP1(.*)$tagP2/\1/\"" log $DEBUG "$DBG > ls $mount_point/${tagP1}*${tagP2} | sed -E \"s/.*$tagP1(.*)$tagP2/\1/\""
local tag=$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | sed -E "s/.*$tagP1(.*)$tagP2/\1/" 2>>$LOG_FILE) local tag=$(ls $mount_point/${tagP1}*${tagP2} 2>>$LOG_FILE | sed -E "s/.*$tagP1(.*)$tagP2/\1/" 2>>$LOG_FILE)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
mail_log $ERROR "$ERR no tag found on device at $mount_point" mail_log $ERROR "$ERR no tag found on device at $mount_point."
return 1 return 1
fi fi
echo $tag echo $tag
@@ -615,34 +731,22 @@ check_backup_device() {
# #
do_export() { do_export() {
log $DEBUG "$DBG do_export ()" log $DEBUG "$DBG do_export ()"
mail_log $INFO "$INF checking USB device" mail_log $INFO "$INF checking USB device."
# get device # get device
log $DEBUG "$DBG > /usr/syno/bin/synousbdisk -enum | grep -v devices | wc -l" local device=$(get_usb_device)
if [ "$(/usr/syno/bin/synousbdisk -enum 2>>$LOG_FILE | grep -v devices 2>>$LOG_FILE | wc -l 2>>$LOG_FILE)" != "1" ]; then if [ -z $device ]; then
mail_log $ERROR "$ERR no USB device or too many found @$HOST_NAME."
return 1
fi
log $DEBUG "$DBG > /usr/syno/bin/synousbdisk -enum | grep -v devices"
local device=$(/usr/syno/bin/synousbdisk -enum 2>>$LOG_FILE | grep -v devices 2>>$LOG_FILE)
# check if exfat
log $DEBUG "$DBG > /usr/syno/bin/synousbdisk -info $device | grep -i \"file system\" | sed -E \"s/.*:\s*(.*)\s*/\1/\""
local fs=$(/usr/syno/bin/synousbdisk -info $device 2>>$LOG_FILE | grep -i "file system" 2>>$LOG_FILE | sed -E "s/.*:\s*(.*)\s*/\1/" 2>>$LOG_FILE)
if [ "$fs" != "exfat" ]; then
mail_log $ERROR "$ERR device $device not exfat formatted"
return 1 return 1
fi fi
# get mount point # check if exfat | mount & get mount point
log $DEBUG "$DBG > /usr/syno/bin/synousbdisk -info $device | grep -i \"mount path\" | sed -E \"s/.*:\s*(.*)\s*/\1/\"" local mount_point=$(mount_usb_device $device)
local mount_path=$(/usr/syno/bin/synousbdisk -info $device 2>>$LOG_FILE | grep -i "mount path" 2>>$LOG_FILE | sed -E "s/.*:\s*(.*)\s*/\1/" 2>>$LOG_FILE) if [ -z $mount_point ]; then
if [ $? -ne 0 ] || [ ! -d $mount_path ]; then
mail_log $ERROR "$ERR mount point \"$mount_path\" does not exist."
return 1 return 1
fi fi
local backup_type=$(check_backup_device $mount_path) # find export type
local backup_type=$(check_backup_device $mount_point)
if [ -z $backup_type ]; then if [ -z $backup_type ]; then
return 1 return 1
fi fi
@@ -652,15 +756,27 @@ do_export() {
case $backup_type in case $backup_type in
int1|int2|1|2) int1|int2|1|2)
# daily + weekly backups -> Auslagerung 1+2, Backup 1+2 # daily + weekly backups -> Auslagerung 1+2, Backup 1+2
if is_synology; then
source_path="/volume1/nfs/backups" source_path="/volume1/nfs/backups"
else
source_path="/var/srv/nas/backups"
fi
;; ;;
serien) serien)
# Serien -> Auslagerung # Serien -> Auslagerung
if is_synology; then
source_path="/volume1/media/serien" source_path="/volume1/media/serien"
else
source_path="/var/srv/media/serien"
fi
;; ;;
video) video)
# Video -> Auslagerung # Video -> Auslagerung
if is_synology; then
source_path="/volume1/media/video" source_path="/volume1/media/video"
else
source_path="/var/srv/media/video"
fi
;; ;;
?*) ?*)
echo "ERROR unknown backup type $backup_type" echo "ERROR unknown backup type $backup_type"
@@ -674,14 +790,13 @@ do_export() {
mail_log $INFO ">>> log file : $LOG_FILE" mail_log $INFO ">>> log file : $LOG_FILE"
mail_log $INFO ">>> " mail_log $INFO ">>> "
mail_log $INFO "$INF exporting $source_path -> $mount_path" mail_log $INFO "$INF exporting $source_path -> $mount_point"
log $DEBUG "$DBG rsync -rti --one-file-system --delete --stats --exclude=@eaDir $source_path $mount_path" log $DEBUG "$DBG rsync -rti --one-file-system --delete --stats --exclude=@eaDir $source_path $mount_point"
rsync -rti --one-file-system --delete --stats --exclude=@eaDir $source_path $mount_path >>$LOG_FILE 2>&1 rsync -rti --one-file-system --delete --stats --exclude=@eaDir $source_path $mount_point >>$LOG_FILE 2>&1
is_error $? is_error $?
mail_log $INFO "$INF unmounting USB device" mail_log $INFO "$INF unmounting USB device $device."
log $DEBUG "$DBG > /usr/syno/bin/synousbdisk -umount $device" umount_usb_device $device
/usr/syno/bin/synousbdisk -umount $device >>$LOG_FILE 2>&1
is_error $? is_error $?
} }
+1 -1
View File
@@ -3,7 +3,7 @@
# entrypoint for all actions # entrypoint for all actions
# #
VER="2.0.1" VER="2.0.4"
show_help() { show_help() {
echo "usage: $0 options" echo "usage: $0 options"