-
Notifications
You must be signed in to change notification settings - Fork 7
/
gdrive-sync.sh
executable file
·82 lines (33 loc) · 987 Bytes
/
gdrive-sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Google Drive Sync
#
# Author: Josh Padilla <[email protected]>
#
# Config BEGIN
# =====================================================================
# Directory to backup
BACKUPDIR=/var/backups
# Google Drive directory
GDRIVEDIR=/mnt/GoogleDrive
# 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