Need Help Backing Up MYSQL Database

Need Help Backing Up MYSQL Database

Posted by: Sleepy_Sentry
Posted on: 2006-07-08 16:40:00

I followed the directions in the wiki for backing up my MYSQL database (http://wiki.dreamhost.com/index.php/Automatic_Backup#Database_backup)
and got this error:

/bin/sh: /home/sleepysentry/backups/mysql.sh: /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?

Re: Need Help Backing Up MYSQL Database

Posted by: sdayman
Posted on: 2006-07-08 18:25:00

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

-Scott

Re: Need Help Backing Up MYSQL Database

Posted by: Sleepy_Sentry
Posted on: 2006-07-08 19:15:00

Here is the script.

#!/bin/bash
mkdir /home/sleepysentry/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -upfljoomla -pPASSWORD -h pfljoomla.gsreview.com 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!

Re: Need Help Backing Up MYSQL Database

Posted by: matttail
Posted on: 2006-07-08 20:00:00

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 script.sh
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
art.googlies.net - personal website

Re: Need Help Backing Up MYSQL Database

Posted by: Sleepy_Sentry
Posted on: 2006-07-09 14:06:00

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

/home/sleepysentry/backups/mysql.sh: line 1: #!/bin/bash
: No such file or directory
/home/sleepysentry/backups/mysql.sh: line 4: backups/mysql/jom_pfljoomla.060709
.sql
: 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/mysql.sh: line 7:
: command not found

Re: Need Help Backing Up MYSQL Database

Posted by: sdayman
Posted on: 2006-07-09 15:04:00

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

-Scott

Re: Need Help Backing Up MYSQL Database

Posted by: Sleepy_Sentry
Posted on: 2006-07-09 18:05:00

I did what you said and this is what my mysql.sh file looks like:
#!/bin/bash
mkdir /home/sleepysentry/backups/mysql
suffix=$(date +%y%m%d)
mysqldump --opt -upfljoomla -pPASSWORD -h pfljoomla.gsreview.com 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 SettingsdanielMy Documentsmysql_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/mysql.sh: line 1: #!/bin/bash
: No such file or directory
mkdir: cannot create directory `/home/sleepysentry/backups/mysqlr': File exists
/home/sleepysentry/backups/mysql.sh: 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


Re: Need Help Backing Up MYSQL Database

Posted by: sdayman
Posted on: 2006-07-09 18:22:00

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.

-Scott

Re: Need Help Backing Up MYSQL Database

Posted by: matttail
Posted on: 2006-07-09 21:06:00

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



--Matttail
art.googlies.net - personal website

Re: Need Help Backing Up MYSQL Database

Posted by: Sleepy_Sentry
Posted on: 2006-07-11 11:25:00

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!



Re: Need Help Backing Up MYSQL Database

Posted by: sdayman
Posted on: 2006-07-11 12:16:00

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.

-Scott

Tags: mysql databasewikidreamhostbackup databasedatabase backupautomatic backupinterpreterbackupsdirectionsphphttpindexhelp