stevepedwards.com/DebianAdmin linux mint IT admin tips info

RAFAEL GOULART’s Handy Gdrive Backup Script

http://tech.rgou.net/en/linux-2/backup-script-on-google-drive-for-linux/

With 15GB of space available on a Gdrive account now, it is a useful space to use. This easy to understand script will upload a folder's total file contents for you - handy for a GUI-less PC...with more research for gdrive dirs and auth etc.

sudo apt install grive

I followed the above page grive install instructions and script creation and it works fine. Just remember to create the "backups" directory on your Gdrive account.

Amend the directories to suit what you want to upload to Gdrive, and encrypt before hand it if sensitive - at your own Google/NSA hacking risk of course!

I tested it with the default /var/backup setting and it sent it all up:

Screenshot from 2014-04-21 01:27:33.png

At least I finally got something practical out of all the fruitless Blog uploader research I've been doing to find a solution to the Libre/openoffice doc Blog publishing nightmare...what?! No other apps than MSWord can format a word processor document with images tidily, AND publish it to a Blog?? Am I dreaming...? Open Source Programmers! There is a big niche market there! Where are you all??

Here's my version:
---------------------------------------------
# Google Drive Sync
# Author: Rafael Goulart
#
# Config BEGIN
# =====================================================================

# Directory to backup
BACKUPDIR=/var/backups

# Google Drive directory
GDRIVEDIR=/home/stevee/Downloads/Gdrive

# Directory target in remote
TARGETDIR=/backups

# =====================================================================
# Config END

# Create backup dir if not exists
echo Creating ${GDRIVEDIR}/${TARGETDIR} if needed
if [ ! -d "${GDRIVEDIR}/${TARGETDIR}" ]; then mkdir ${GDRIVEDIR}/${TARGETDIR}; fi

# Moving to Gdrive Dir
echo Entering ${GDRIVEDIR}
cd ${GDRIVEDIR}

# Initial sync
echo Initial Google Drive Sync
grive

# Coping new content
echo Copying from ${BACKUPDIR}/* to ${GDRIVEDIR}/${TARGETDIR}/
cp -R ${BACKUPDIR}/* ${GDRIVEDIR}/${TARGETDIR}/

# Showing files copied
echo Files to sync
find ${GDRIVEDIR}/${TARGETDIR}/

# Final sync
echo Final Google Drive Sync
grive
------------------------------------------------

It would be nice to have a progress bar of the upload, so I'll try piping it through pv and see if that works...

NAME
pv - monitor the progress of data through a pipe.
To use it, insert it in a pipeline between two processes, with the
appropriate options. Its standard input will be passed through to
its standard output and progress will be shown on standard error.

./googledrive-sync.sh | pv

Not quite a progress bar, but gives a summary of time and upload speed:
Screenshot from 2014-04-21 02:07:19.png

Comments are closed.

Post Navigation