![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Web Programming, Web 2.0 and Mashups Discuss Web Programming and Web Server Administration, including LAMP, Apache, MySQL, Flash, HTML, SEO, Mashups and other Web APIs and topics. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL Developer, meet “Quan” (aka the MySQL Query Analyzer) | iBot | MySQL DevZone RSS | 0 | 05-15-2009 02:30 PM |
| MySQL University - Training on MySQL Development & Internals | iBot | Solaris BigAdmin RSS | 0 | 11-12-2008 09:10 AM |
| how to break mysql dump sql file | learnbash | Shell Programming and Scripting | 2 | 05-14-2008 06:39 AM |
| restore mysql dump file in many remote servers? | blesets | Shell Programming and Scripting | 2 | 09-13-2006 02:17 AM |
| help, what is the difference between core dump and panic dump? | aileen | UNIX for Dummies Questions & Answers | 1 | 06-11-2001 09:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Hello. the purpose of my efforts right now are to get a larger script of mine (which the admin told me he'd put into cron for me) to properly back-up my MySQL database. To test out the sql back-up part (before getting the whole script into cron, and having it not work) I wanted to test it. So here's what I did: PHP file to do my testing (on the live server) Code:
<?php
$test = shell_exec('echo $SHELL');
echo "<pre>$test</pre>";
$output = shell_exec('sh ./sqlBack.sh');
echo "<pre>$output</pre>";
?>
Script being called by the PHP Code:
#!/usr/local/bin/bash # MYSQL BACKUP: sql_bDir="./sql_backups/" #LOCATION FOR SQL BACKUPS TO LAND sql_bName=SqlBackup_$(date "+%A") echo "The Shopping Cart's database backup will be in $sql_bDir and will be named $sql_bName" #NOTICE OF DATABASE BACKUP mysqldump -uNAME -pPASS --opt DBASENAME > $sql_bDir$sql_bName.tgz just for testing, both these files were set to 777 on the server. The output from the PHP file looks just as it should, but then I find the ./sql_backups/ directory empty. I tried the username, password and database of the last line of that script in both capital letters and lower case (read somewhere that capitals works better.. anyways). I'm not experienced with php/mysql.. I found the syntax for that mysqldump line in an article. Thanks in advance for all your help!! |
|
|||||
|
Thanks for the reply!!
Quote:
Quote:
This is what i found: Quote:
Quote:
Quote:
Thanks for all your help!! |
|
||||
|
Quote:
test.php Code:
<?php
$output=shell_exec('sh /home/jzacsh/public_html/private/scripts/dbackup.sh');
echo "<pre>$output</pre>";
?>
the shell script its set to run is: Code:
#!/bin/sh
sql_bDir=./sql_pickup/
#START SQL BACKUP + TGZ
echo " " #VISUAL PADDING
echo "# BEGINNING DATABASE BACKUP PORTION:" #VISUAL
#MYSQL LANDING DIR. CHECK
echo "Checking if sql backup landing directory exists: $sql_bDir"
if test -d "$sql_bDir"
then
echo "Directory to receive database backup exists"
else
echo "Directory to receive database backup does not exist, creating it"
mkdir $sql_bDir
fi #ENDIF SQL DIR. CHECK
echo " " #VISUAL PADDING
# MYSQL BACKUP
sql_bName=SQLBackUp_$(date +%A).gz
sql_Path=$sql_bDir$sql_bName
echo "The Shopping Cart's database backup will be:" $sql_Path #NOTICE OF DATABASE BACKUP
echo "Note: If the main backup is backing up the root directory, you do not need to separately download the database backup."
mysqldump -u name -p wppass --single-transaction db123 | dd bs=1M | gzip -c > $sql_Path
then I visit the above ^ test.php via browser and get this output: Code:
# BEGINNING DATABASE BACKUP PORTION: Checking if sql backup landing directory exists: ./sql_pickup/ Directory to receive database backup exists The Shopping Cart's database backup will be: ./sql_pickup/SQLBackUp_Tuesday.gz Note: If the main backup is backing up the root directory, you do not need to separately download the database backup. When I download the file its only 4KB, and upon unarchiving the file, I find a Zero KB file, which using "cat" via terminal shows that the file is indeed blank. Any ideas what I could be doing wrong?? |
|
||||
|
Quote:
(the file still comes out 0 B, just uncompressed)test.php output: Code:
# BEGINNING DATABASE BACKUP PORTION: Checking if sql backup landing directory exists: ./sql_pickup/ Directory to receive database backup exists The Shopping Cart's database backup will be: ./sql_pickup/SQLBackUp_Tuesday Note: If the main backup is backing up the root directory, you do not need to separately download the database backup. source of dbackup.sh Code:
#!/bin/sh sql_bName=SQLBackUp_$(date +%A) mysqldump -u jzacsh_jzacsh -p wordpres --single-transaction jzacsh_jzwp > $PWD/sql_pickup/$sql_bName actually... just in posting that ^ I realized I haven't checked: echo $SHELL ...it returned /usr/local/cpanel/bin/noshell i'm guessing that means I can't run things properly? (I'm not sure, I obviously had a shell to output a file with and everything... I just wasn't successful in outputting a GOOD file) |
![]() |
| Bookmarks |
| Tags |
| backup, mysql, php test |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|