I am trying to use a backup script that will backup my sql database and website files. I am running Ubuntu 12.04 32 bit version and zPanel.

Also what are these variables:


I assume the first one is DB name.

Here is the script:

# 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:
# Where do we want the backup to go?  (SET THIS - IT'S A TEMP FOLDER)
# Where is our dropbox folder? (SET THIS TO YOUR ABSOLUTE BACKUP PATH)
# 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?
# Our MySQL Login information and some paths (we'll use 'which' to make sure we get them):
# Don't forget to change the root password here!
# Let's just, for sanity's sake, make sure our temp backup folder exists.
mkdir $BACKUP
# 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
# 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.
# Copy our backups into it.
cp -R $BACKUP/* $DROPBOX/Asterix/$NOW
# We can delete the backup we made 3 days ago from Copy now.
# And clear out the temporary director for next time.
rm $BACKUP/*
# Job well done!
# Have a beer and relax!

Here is my problem: When I try to run the script I get this error: ./backup.sh: 66: ./backup.sh: Syntax error: Unterminated quoted string

If anyone could help me with this would appreciate it a lot!

  • 4
    I think DROPBOX="/root/Dropbox/Backups should be DROPBOX="/root/Dropbox/Backups". – g_p Sep 7 '14 at 17:07

The line with


does not have a " at the end.

The MYSQL, MYSQLDUMP and GZIP variables refer to the programs used to execute various commands. So they should contain the path of those programs:


You can use the output of which <program name> to see what to put there:

$ which mysql
$ which gzip
  • Ok I will see if that fixes. Also in the script I also did not know what to put in at: MYSQL="$()" MYSQLDUMP="$()" GZIP="$()" So I just put my DB name in for the first two and .gz in the third one. Is that fine? – Hamza Sep 7 '14 at 17:08
  • @Hamza for MYSQL in the brackets, use the output of which mysql, and which mysqldump for MYSQLDUMP. Similarly for GZIP. e.g.: MYSQL=/usr/bin/mysql. – muru Sep 7 '14 at 17:10

I faced the same issue as seen below.


then I put a space before # character, then solved.

New contributor
Ahmet Vehbi Olgaç is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.