From 0c22da906dba48af1802d7aaf46ed6fab8e84bf3 Mon Sep 17 00:00:00 2001 From: kiba Date: Fri, 18 Oct 2019 18:03:03 +1100 Subject: [PATCH 1/2] Add Google Drive support using rclone cli tool --- backmeup.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) mode change 100644 => 100755 backmeup.sh diff --git a/backmeup.sh b/backmeup.sh old mode 100644 new mode 100755 index 4b58982..e617d15 --- a/backmeup.sh +++ b/backmeup.sh @@ -94,6 +94,10 @@ case $key in SEVENZIP_COMPRESSION_PASSWORD="$2" shift # past argument ;; + -rcr|--rclone-remote) + RCLONE_REMOTE="$2" + shift # past argument + ;; -s3bn|--s3-bucket-name) S3_BUCKET_NAME="$2" shift # past argument @@ -179,6 +183,15 @@ then fi fi +if [[ "$METHOD" == "gdrive" ]]; +then + if ! [[ -x "$(command -v rclone)" ]]; + then + INSTALLABLE="nope" + ERRORMSGS+=('| You must install rclone cli to run this script to upload backups to Google Drive') + fi +fi + # Let's check whether the script is installable if [[ "$INSTALLABLE" == "yes" ]]; @@ -293,6 +306,24 @@ then echo '|' fi + # If uploading method is set to Google Drive + if [[ "$METHOD" == "gdrive" ]]; + then + if [[ ! -f "$HOME/.config/rclone/rclone.conf" ]]; + then + echo '| You must configure the rclone first!' + echo '| Please run rclone config as the user which will run this script and follow the instructions.' + echo '| After that, re-run this script again' + fi + # https://rclone.org/drive/ + echo '| Creating the directory and uploading to Google Drive...' + rclone mkdir "$RCLONE_REMOTE$BACKUPFOLDER" + rclone copy "$BASEFOLDER/$FILENAME" "$RCLONE_REMOTE$BACKUPFOLDER/$FILENAME" + echo '|' + echo '| Done!' + echo '|' + fi + echo '| Cleaning up...' # Now let's cleanup rm -r $FILENAME From 053d05df1de8998d6c9d04492c2e2c99592ae7e4 Mon Sep 17 00:00:00 2001 From: kiba Date: Sat, 19 Oct 2019 12:37:02 +1100 Subject: [PATCH 2/2] Add --gdrv|--gdrive-remote args Rename Google Drive parameters. --- backmeup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backmeup.sh b/backmeup.sh index e617d15..f54e347 100755 --- a/backmeup.sh +++ b/backmeup.sh @@ -94,7 +94,7 @@ case $key in SEVENZIP_COMPRESSION_PASSWORD="$2" shift # past argument ;; - -rcr|--rclone-remote) + -gdrv|--gdrive-remote) RCLONE_REMOTE="$2" shift # past argument ;;