From 6fe136eec86bd6c1d5b47b12892636bf0ddb71c3 Mon Sep 17 00:00:00 2001 From: FindHao Date: Sat, 15 Dec 2018 11:25:21 +0800 Subject: [PATCH] add the remote gdrive directory setting --- backup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index db6332e..53eae3a 100644 --- a/backup.sh +++ b/backup.sh @@ -36,6 +36,10 @@ TEMPDIR="/root/backups/temp/" # File to log the outcome of backups LOGFILE="/root/backups/backup.log" +# Remote gdrive directory to save backups +# Notice: You need to ensure that this name is the only one in your gdrive space. +REMOTEDIR="site-backups" + # OPTIONAL: If you want backup MySQL database, enter the MySQL root password below MYSQL_ROOT_PASSWORD="" @@ -222,7 +226,8 @@ start_backup() { gdrive_upload() { if ${GDRIVE_COMMAND}; then log "Tranferring backup file to Google Drive" - gdrive upload --no-progress ${OUT_FILE} >> ${LOGFILE} + local REMOTE_GDRIVE_DIR_ID=$(gdrive list -q "name = '${REMOTEDIR}'" --no-header | awk '{print $1}' ) + gdrive upload --no-progress -p "${REMOTE_GDRIVE_DIR_ID}" ${OUT_FILE} >> ${LOGFILE} if [ $? -ne 0 ]; then log "Error: Tranferring backup file to Google Drive failed" exit 1