mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 02:20:11 -08:00
49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
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@ts-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@ts-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@ts-vperanda:$source $destination
|
|
|
|
# send a notification to https://notify.peterwood.rocks/lab
|
|
curl \
|
|
-H priority:default \
|
|
-H tags:backups,${HOSTNAME} \
|
|
-d "The backups have been moved to the NAS." \
|
|
https://notify.peterwood.rocks/lab
|