LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-13-2004, 03:39 AM   #1
varunbihani
Member
 
Registered: Jul 2003
Location: indore, india
Posts: 69

Rep: Reputation: 15
Shell Script


I AM TRYING TO WRITE FOLLOWING SHELL SCRIPT TO TAKE THE BACKUP OF MY DATABASE...

#!/bin/sh
mysqldump -uroot -p --opt <dbname> > /data/backup/DB_Backup/<file>.sql
cd /data/backup/DB_Backup/
tar -zcvf sqldata.tgz *.sql

THE DUMP NAME OF FILE THAT IS BEING CREATED IS <file>.sql? ..
I DONT UNDERSTAND WHY THIS LEADING "?" IS COMING..
I GET FOLLOWING ERROR...
I ALSO DONT UNDERSTAND WHY "NO SUCH FILE / DIRECTORY' ERRO IS COMING..

[root@console]# sh /data/test.sh
Enter password:
: No such file or directory/data/backup/DB_Backup/
tar: *.sql: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
 
Old 09-13-2004, 08:08 AM   #2
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
if /data/backup/DB_Backup/ doesn't already exist, then your script won't work.
You should create that directory before running the script, or add something like this to the beginning of the script:

backup_dir=/data/backup/DB_Backup
if [ ! -d "$backup_dir" ]; then
mkdir -p "$backup_dir"
fi

Last edited by mikshaw; 09-13-2004 at 08:10 AM.
 
Old 09-13-2004, 08:08 AM   #3
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
double-dose...

Last edited by mikshaw; 09-13-2004 at 08:09 AM.
 
Old 09-13-2004, 11:32 AM   #4
varunbihani
Member
 
Registered: Jul 2003
Location: indore, india
Posts: 69

Original Poster
Rep: Reputation: 15
data/backup/DB_Backup

data/backup/DB_Backup
already created!!!
but still the same error
 
Old 09-13-2004, 12:31 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
check the ownerships/permissions on that dir. The backup script must be able to see/write to it.
 
Old 09-13-2004, 06:00 PM   #6
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
it's apparently being run as root, so permissions shouldn't be a problem.

in the script you said the directory was /data/backup/DB_Backup (note the first slash)
and in your more recent post you said data/backup/DB_Backup already created. Is this a typo, or are you talking about two different paths? The second one would be a subdirectory of the current working directory...the first one is a full path starting at root.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 07:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-12-2005 12:08 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM


All times are GMT -5. The time now is 10:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration