From 8646572466e90838f561860fe002ad38d75882a3 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Wed, 20 Sep 2023 11:19:31 +0000 Subject: [PATCH 1/7] updated notification message to be less confusing --- update-portainer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update-portainer.sh b/update-portainer.sh index b57d116..53ce2d5 100755 --- a/update-portainer.sh +++ b/update-portainer.sh @@ -43,5 +43,5 @@ esac curl \ -H priority:default \ -H tags:update,docker,portainer,${HOSTNAME} \ - -d "The ${image_name} portainer image has been updated." \ + -d "The ${image_name} image has been updated." \ https://notify.peterwood.rocks/lab From 17e24eabc8ba9ea1c56a59c248804d1989d76b33 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Tue, 3 Oct 2023 08:29:52 -0400 Subject: [PATCH 2/7] shell script to move files from vperanda to NAS. sends notification when complete. expected that this will run on WSL --- move-backups.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 move-backups.sh diff --git a/move-backups.sh b/move-backups.sh new file mode 100755 index 0000000..a6a9c42 --- /dev/null +++ b/move-backups.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +function move-backups() { + rsync -vrzPh --include '*.gz' --remove-source-files vperanda:/home/acedanger/backup/docker-data /mnt/m/backups/ +} + +if [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then + move-backups +fi + +# 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 From 2d105cd0d83162b1b2496d94ca19ed39ecaf1992 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Tue, 3 Oct 2023 08:31:50 -0400 Subject: [PATCH 3/7] removed rclone commands --- backup-docker.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/backup-docker.sh b/backup-docker.sh index 18d139e..d7e993c 100755 --- a/backup-docker.sh +++ b/backup-docker.sh @@ -2,24 +2,19 @@ # vaultwarden tar zcf /home/acedanger/backup/docker-data/vaultwarden-data-bk-`date +%Y%m%d`.tar.gz /var/lib/docker/volumes/vaultwarden_data/_data -rclone move /home/acedanger/backup/docker-data/vaultwarden-data-bk-`date +%Y%m%d`.tar.gz onedrive:Documents/rclone/vaultwarden # portainer tar zcf /home/acedanger/backup/docker-data/portainer-data-bk-`date +%Y%m%d`.tar.gz /var/lib/docker/volumes/portainer_data/_data -rclone move /home/acedanger/backup/docker-data/portainer-data-bk-`date +%Y%m%d`.tar.gz onedrive:Documents/rclone/portainer # paperless tar zcf /home/acedanger/backup/docker-data/paperless-data-bk-`date +%Y%m%d`.tar.gz /var/lib/docker/volumes/paperless-ng_data/_data tar zcf /home/acedanger/backup/docker-data/paperless-media-bk-`date +%Y%m%d`.tar.gz /var/lib/docker/volumes/paperless-ng_media/_data tar zcf /home/acedanger/backup/docker-data/paperless-pgdata-bk-`date +%Y%m%d`.tar.gz /var/lib/docker/volumes/paperless-ng_pgdata/_data -rclone move /home/acedanger/backup/docker-data/paperless-data-bk-`date +%Y%m%d`.tar.gz onedrive:Documents/rclone/paperless -rclone move /home/acedanger/backup/docker-data/paperless-media-bk-`date +%Y%m%d`.tar.gz onedrive:Documents/rclone/paperless -rclone move /home/acedanger/backup/docker-data/paperless-pgdata-bk-`date +%Y%m%d`.tar.gz onedrive:Documents/rclone/paperless # send a notification to https://notify.peterwood.rocks\lab curl \ -H priority:default \ -H tags:backup,docker,vaultwarden,portainer,paperless,${HOSTNAME} \ -d "Completed backup of vaultwarden, portainer, paperless data" \ - https://notify.peterwood.rocks/lab \ No newline at end of file + https://notify.peterwood.rocks/lab From efa9898731dfe852320357de8af62c773b5cd103 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Wed, 4 Oct 2023 08:47:26 -0400 Subject: [PATCH 4/7] simplified flags for running as cron job --- move-backups.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/move-backups.sh b/move-backups.sh index a6a9c42..f6e9b67 100755 --- a/move-backups.sh +++ b/move-backups.sh @@ -1,7 +1,11 @@ #! /bin/bash function move-backups() { - rsync -vrzPh --include '*.gz' --remove-source-files vperanda:/home/acedanger/backup/docker-data /mnt/m/backups/ +# -q quiet +# -r recursive +# -z compress + rsync -qrz --include '*.gz' --remove-source-files vperanda:/home/acedanger/backup/docker-data + /mnt/m/backups/ } if [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then From 9f3419f777099542dec398abcc3ab7fb151e13fd Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Thu, 5 Oct 2023 08:16:50 -0400 Subject: [PATCH 5/7] updated rsync flags to allow it to run as root --- move-backups.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/move-backups.sh b/move-backups.sh index f6e9b67..93f06a6 100755 --- a/move-backups.sh +++ b/move-backups.sh @@ -1,11 +1,7 @@ -#! /bin/bash +#!/bin/bash function move-backups() { -# -q quiet -# -r recursive -# -z compress - rsync -qrz --include '*.gz' --remove-source-files vperanda:/home/acedanger/backup/docker-data - /mnt/m/backups/ + rsync --recursive --quiet -e 'ssh -p 58022' --include '*.gz' --remove-source-files acedanger@vperanda:/home/acedanger/backup/docker-data /mnt/m/backups/ } if [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then From cefd7fc0a3f011b887df98f76de4cc45bb120a0e Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Thu, 5 Oct 2023 21:29:27 -0400 Subject: [PATCH 6/7] adapted path for svr-office instead of wsl --- move-backups.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/move-backups.sh b/move-backups.sh index 93f06a6..5aff03e 100755 --- a/move-backups.sh +++ b/move-backups.sh @@ -1,7 +1,7 @@ #!/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/m/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 From 4ed5d253e2658ee068e21eeea51fb79fafe8fa9e Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Wed, 25 Oct 2023 07:19:22 -0400 Subject: [PATCH 7/7] rewritten. only send notification if there were files transfered --- move-backups.sh | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/move-backups.sh b/move-backups.sh index 5aff03e..cd7dd8f 100755 --- a/move-backups.sh +++ b/move-backups.sh @@ -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 \