Need Help Backing Up MYSQL Database

I followed the directions in the wiki for backing up my MYSQL database (
and got this error:

/bin/sh: /home/sleepysentry/backups/ /bin/bash
: bad interpreter: No such
file or directory

I did set up the file and my permissions are set up so the file is executable.

What’s going on here?

Show us the script, and be sure to hide any sensitive info such as passwords, etc.


Here is the script.

mkdir /home/sleepysentry/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -upfljoomla -pPASSWORD -h jom_pfljoomla > backups/mysql/jom_pfljoomla.$suffix.sql
tar -cf /home/sleepysentry/backups/archives/mysql_backup.$suffix.tar backups/mysql/*
rm -r backups/mysql/

You don’t know how much I appreciate your help right now!

an other user rescently posted on the forums with the same error. I finally determined that the issue was with the way the file had been saved before uploading to the server. I need to update that wiki article, but in the mean time…

You can fix this using one of two methods. Pick the one that seams easiest to you.
A. Open your script in notepad. Make sure that your formatting is still right, no line wraps or anything like that. Now click File Save as.
Type in your script name (or select it to overwirte)
set the Save as type to All files, and the encoding to UTF-8.
Now upload your script and set permissions on it again.

B. from ssh (putty) cd into your backups directory where the shell script is. Open the script with nano. The command will look like
nano -w
If my suspicions are correct you will notice at the bottom of the screen it says “converted from DOS format”. Press ctrl and o at the same time to save (write Out) and then ctrl and x at teh same time to exit.

Repete this process for each shell script you have. With luck your scripts will now work.

–Matttail - personal website

That helped things a little, thanks. After trying to run it again, I was emailed this message:

/home/sleepysentry/backups/ line 1: #!/bin/bash
: No such file or directory
/home/sleepysentry/backups/ line 4: backups/mysql/jom_pfljoomla.060709
: No such file or directory
tar: backups/mysql/*\r: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
rm: cannot remove `backups/mysql/\r’: No such file or directory
/home/sleepysentry/backups/ line 7:
: command not found

You need to use full paths for everything: /home/sleepysentry/backups/…


I did what you said and this is what my file looks like:
mkdir /home/sleepysentry/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -upfljoomla -pPASSWORD -h jom_pfljoomla > /home/sleepysentry/backups/mysql/jom_pfljoomla.$suffix.sql
tar -cf /home/sleepysentry/backups/archives/mysql_backup.$suffix.tar /home/sleepysentry/backups/mysql/*
rm -r /home/sleepysentry/backups/mysql/

It did generate a 10 KB MYSQL file in my backups/archives folder. However, I get this error when I try manually downloading it in FTP:
Failed to open file ‘C:\Documents and Settings\daniel\My Documents\mysql_backup.060709.tar’.
The filename, directory name, or volume label syntax is incorrect.
Transfer failed.

I also got this error in my inbox:

/home/sleepysentry/backups/ line 1: #!/bin/bash
: No such file or directory
mkdir: cannot create directory /home/sleepysentry/backups/mysql\r': File exists /home/sleepysentry/backups/ line 4: /home/sleepysentry/backups/mysql/jom_pfljoomla.060709 .sql : No such file or directory tar: Removing leading/’ from member names
tar: /home/sleepysentry/backups/mysql/*\r: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
rm: cannot remove `/home/sleepysentry/backups/mysql/\r’: No such file or directory

There shouldn’t be a backslash: \r
It looks like there are several of them, probably at the end of every line of your file. I’m guessing it’s because you edited it in Windows. Try logging into your shell account via putty and edit it with pico. mattail (or someone) posted the syntax for pico in this forum recently. Just search this forum for “pico” and you should find it.

For the tar command, I’d cd into that directory first, then tar -cf /fullpath/tarfile *
This will prevent the full paths from being saved in your tarfile, and just leave the files themselves.


The instruction for nano above should accomplish the same thing as pico (nano is a basic clone of pico, or visa versa)

–Matttail - personal website

I got it working and downloaded the file, but after looking at the SQL file I got back, it was only 774 bytes!

I opened the file and it just had some basic information about the SQL file, such as its name.

The file should be much larger considering how much content I have on my Joomla website.

I appreciate all the help I’ve been getting. Thanks!

I suggest you start manually stepping through your script, beginning with setting your shell to /bin/bash (just typing that in will do it). Then go one command at a time and check your results as you go along.