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 |
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 |
double-dose... :eek:
|
data/backup/DB_Backup
data/backup/DB_Backup
already created!!! but still the same error |
check the ownerships/permissions on that dir. The backup script must be able to see/write to it.
|
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. |
All times are GMT -5. The time now is 08:53 PM. |