mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
rewritten. only send notification if there were files transfered
This commit is contained in:
@@ -1,13 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
function move-backups() {
|
||||
rsync --recursive --quiet -e 'ssh -p 58022' --include '*.gz' --remove-source-files acedanger@vperanda:/home/acedanger/backup/docker-data /mnt/share/media/backups/
|
||||
}
|
||||
|
||||
if [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
|
||||
move-backups
|
||||
if [ ! "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source="/home/acedanger/backup/docker-data/"
|
||||
destination="/mnt/share/media/backups/docker-data/"
|
||||
|
||||
command="rsync \
|
||||
--archive --verbose --progress --dry-run --stats \
|
||||
-e 'ssh -p 58022' \
|
||||
--include '*.gz' \
|
||||
acedanger@vperanda:$source $destination \
|
||||
| fgrep 'Number of files' | cut -d' ' -f4 | tr -d ,"
|
||||
|
||||
# echo 'Running command => '
|
||||
# echo $command
|
||||
|
||||
num_files=$(rsync \
|
||||
--archive --verbose --progress --dry-run --stats \
|
||||
-e 'ssh -p 58022' \
|
||||
--include '*.gz' \
|
||||
acedanger@vperanda:$source $destination \
|
||||
| fgrep 'Number of files' | cut -d' ' -f4 | tr -d ,
|
||||
)
|
||||
|
||||
# echo 'There are' "${num_files}" 'file(s) to be transferred.'
|
||||
|
||||
if [ "$num_files" == 0 ];
|
||||
then
|
||||
echo 'There are no files to transfer. Exiting.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# move the files from $source to $destination
|
||||
rsync \
|
||||
--recursive --verbose --progress --remove-source-files --archive \
|
||||
-e 'ssh -p 58022' \
|
||||
--include '*.gz' \
|
||||
acedanger@vperanda:$source $destination
|
||||
|
||||
# send a notification to https://notify.peterwood.rocks/lab
|
||||
curl \
|
||||
-H priority:default \
|
||||
|
||||
Reference in New Issue
Block a user