Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Add Google Drive support using rclone cli tool #6

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions backmeup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ case $key in
SEVENZIP_COMPRESSION_PASSWORD="$2"
shift # past argument
;;
-gdrv|--gdrive-remote)
RCLONE_REMOTE="$2"
shift # past argument
;;
-s3bn|--s3-bucket-name)
S3_BUCKET_NAME="$2"
shift # past argument
Expand Down Expand Up @@ -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" ]];
Expand Down Expand Up @@ -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
Expand Down