From 28080140964047985737b09fc174b9e06e37b66e Mon Sep 17 00:00:00 2001 From: WhatTheMike Date: Fri, 19 Mar 2021 00:22:15 -0400 Subject: [PATCH] Added VPS backup script. --- README.md | 3 +++ bash/backupVPS.sh | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 bash/backupVPS.sh diff --git a/README.md b/README.md index 306334b..06cfec5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ **backupProgramFiles.sh** This is a script that I created to zip up my Program Files folders on my C: drive as those are permanently excluded by the backup software I use. I could probably dive in and pick specific applications that I know store their configutaions in the Program Files folders but for now I just do the whole thing. This script also clears out backups older than 2 weeks (I run it weekly) and emails a summary to the provided address through the specified mail relay server. Be sure to edit smtp-creds.sh to include your information. +**backupVPS.sh** +This script was written to automatically sync the backups I create on my server with my local machine as a part of the 32-1 backup rule. + **convertHEICtoJPG.sh** This script will convert your HEIC files (a format Apple saves photos with) to JPGs. Flip saveasjpg at the top to save as PNG instead. This will result in much larger file sizes. Set keeporiginals to 0 to delete the HEIC files after they're converted. The HEIC files are saved kept around by default. For best results set this up as a cron job. \* Requires the ImageMagick CLI software to be installed with HEIC support. There are links at the top of the script to do this. diff --git a/bash/backupVPS.sh b/bash/backupVPS.sh new file mode 100755 index 0000000..d43a737 --- /dev/null +++ b/bash/backupVPS.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories +# https://linuxhandbook.com/bash-arrays/ +# https://stackoverflow.com/a/169517 + +remotedirs=('bookstack' 'gitea') + +# Server must have an ssh entry set up in ~/.ssh/config with the +# host, user, port (if non-standard), and identityFile. +server="vps-b" +remotehome="~" +localhome="/mnt/b/Backups" + +let mydirs="${#remotedirs[@]}-1" + +for i in $(seq 0 $mydirs); do + echo "Downloading $server:$remotehome/${remotedirs[$i]}/ to $localhome/${remotedirs[$i]}/..." + rsync -a $server:$remotehome/${remotedirs[$i]}/ $localhome/${remotedirs[$i]}/ +done