“Синтаксическая ошибка: незавершенная заключенная в кавычки строка”

Я пытаюсь использовать резервный сценарий, который скопирует мою sql базу данных и файлы веб-сайта. Я выполняю версию Ubuntu 12.04 32 битов и zPanel.

Также что является этими переменными:

MYSQL =" $ ()"
MYSQLDUMP =" $ ()"
GZIP =" $ ()"

Я предполагаю, что первый является именем DB.

Вот сценарий:

#!/bin/sh
#----------------------------------------------------------------
# Daily Backup Routine - Backup and Sync to Dropbox
# This script creates a backup using today's date, then deleted
# any backups made 3 days ago. If run every day it will ensure
# you have a week's worth of backups of your MySQL databases and
# zPanel web directories. 
#
# Uses whatever Dropbox account is running on the server.
#
# Written by Richard Ferreira for the backup of zPanel websites.
# Contact me - richard[at]beetle001.com
#----------------------------------------------------------------
#
# Before we get started, we should set some parameters. We'll need these for later.
# The webserver's datafiles:
WEBDIR="/var/zpanel/hostdata/"
# Where do we want the backup to go?  (SET THIS - IT'S A TEMP FOLDER)
BACKUP="/root/backup-temp"
# Where is our dropbox folder? (SET THIS TO YOUR ABSOLUTE BACKUP PATH)
DROPBOX="/root/Dropbox/Backups
# What do we want our date to look like?
NOW=$(date +"%d-%m-%Y")
# We need to know the date 3 days ago to purge any backups that were made 3 days ago.
# This ensures we don't keep unnecessarily old backups.
# It doesn't matter if it skips one every now and then - we'll just have to check manually from time to time.
# If you want to keep more days backups, change the "3 days ago" to "x days ago"
DAYSAGO=$(date --date="3 days ago" +"%d-%m-%Y")
# What should our file backup look like?
WEBFILE="webdirs-full-$NOW.tar.gz"
# Our MySQL Login information and some paths (we'll use 'which' to make sure we get them):
SQLUSER="root"
# Don't forget to change the root password here!
SQLPASS="xxxxxxxxxxxx"
SQLHOST="localhost"
MYSQL="$(db-name)"
MYSQLDUMP="$(db-name)"
GZIP="$(.gz)"
#
# Let's just, for sanity's sake, make sure our temp backup folder exists.
mkdir $BACKUP
# DON'T EDIT ANYTHING BELOW THIS LINE
#----------------------------------------------------------------
# Now let's start!
# Let's get the databases that we want to backup.
DBS="$($MYSQL -u $SQLUSER -h $SQLHOST -p$SQLPASS -Bse 'show databases')"
# Now let's dump them to .sql files and put them in our backup directory.
for db in $DBS
do
FILE=$BACKUP/mysql-$db.$NOW.gz
$MYSQLDUMP -u $SQLUSER -h $SQLHOST -p$SQLPASS $db | $GZIP -9 > $FILE
done
#
# Let's shove the whole webserver directory into a tarball and throw that in with the sql files:
tar -zcvf /root/backup/$WEBFILE $WEBDIR
# That's all done - we should put the backups on Copy by putting them into our Copy folder.
# First let's make a folder for today.
mkdir $DROPBOX/$NOW
# Copy our backups into it.
cp -R $BACKUP/* $DROPBOX/Asterix/$NOW
# We can delete the backup we made 3 days ago from Copy now.
rm -rf $DROPBOX/$DAYSAGO
# And clear out the temporary director for next time.
rm $BACKUP/*
# Job well done!
# Have a beer and relax!

Вот моя проблема: Когда я пытаюсь запустить скрипт, я получаю эту ошибку:./backup.sh: 66:./backup.sh: Синтаксическая ошибка: незавершенная заключенная в кавычки строка

Если бы кто-либо мог бы помочь мне с этим, ценил бы его много!

4
задан 26 November 2017 в 04:42

1 ответ

Строка с

DROPBOX="/root/Dropbox/Backups

не имеет " в конце.

MYSQL, MYSQLDUMP и GZIP переменные обращаются к программам, используемым для выполнения различных команд. Таким образом, они должны содержать путь тех программ:

MYSQL="/usr/bin/mysql"
MYSQLDUMP="/usr/bin/mysqldump"
GZIP="/bin/gzip"

можно использовать вывод which <program name> для наблюдения, что поместить там:

$ which mysql
/usr/bin/msql
$ which gzip
/bin/gzip
8
ответ дан 1 December 2019 в 09:09

Другие вопросы по тегам:

Похожие вопросы: