Announcement

Collapse
No announcement yet.

DB backup in scriptcase blank

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DB backup in scriptcase blank

    Hey guys

    Am trying to create a database backup but I just cant get it working as it should, it displays as complete but no backup is actualy made and no file created. hope somebody can shine some light on this so that I can get it working.

    This is the blank page code:

    Code:
    $date = date('dFY');
    // file backup path
    $path = '../_lib/file/doc/backup/'.[clubID].'/';
    // file names
    $file_one = ''.$date.'_members_table.sql';
    $file_two = ''.$date.'_payment_history.sql';
    // tables to backup
    $table_members = "mbr";
    $table_history = "history";
    // Check for record
    $backup_file_one  = ''.$path.''.$file_one.'';
    $backup_file_two  = ''.$path.''.$file_two.'';
    
    // select fields to backup - table two
    $check_sql_one = "SELECT * INTO OUTFILE '$backup_file_one' FROM $table_members WHERE mbrClubID = '[clubID]'";
    sc_lookup(rs1, $check_sql_one);
    
    // select fields to backup - table one
    $check_sql_two = "SELECT * INTO OUTFILE '$backup_file_two' FROM $table_history WHERE history_clubID = '[clubID]'";
    sc_lookup(rs2, $check_sql_two);
    
    ?>
    
    <style>
    .staff-box {width:100%;margin:0 auto;padding:20px;}
    .staff-box img {float:left;padding:20px;margin-top:-20px;}
    .staff-box-msg {padding:10px;-webkit-border-radius: 8px;
    border-radius: 8px;background-color:#fff;}
    .staff-box-msg a {color:#3B3B3B;text-decoration:none;font-weight:normal;font-size:12px;
    		font-family:palatino linotype, palatino, serif;}
    .staff-box-msg a:hover  {color:#737373;
    		text-style:none;}
    </style>
    <div class="staff-box">
    	<h3><?php echo {lang_backup_title}; ?></h3>
    	<hr/>
    	<div class="staff-box-msg">
    		<img width="140" height="140" border="0" src="../_lib/img/sys__NM__members-only-medium.jpg"></img>
    	<div style="list-box-small">
    		
    <?php
    // checks and display file for download
    if(! $check_sql_one )
    {
    die('Could not take data backup: ' . mysql_error());
    }
    else
    {
    echo {lang_backup_members};
    ?>
    <br/>
    <a href="<?php echo $path; ?><?php echo $file_one; ?>"><?php echo $file_one; ?></a>
    <?php
    }
    ?>
    <br/>
    <?php
    if(! $check_sql_two )
    {
    die('Could not take data backup: ' . mysql_error());
    }
    else
    {
    ?>
    <br/>
    <?php
    echo {lang_backup_history};
    ?>
    <br/>
    <a href="<?php echo $path; ?><?php echo $file_two; ?>"><?php echo $file_two; ?></a>
    <br/>
    <div style='padding-top:20px;'><?php echo {lang_backup_msg}; ?></div>
    <?php
    }
    ?>
    </div>
    </div>
    </div>
    <?php
    thanks in advance

  • #2
    Hint of the day, grab xdebug and singlestep through your code... You should find it quickly then. You have to test it on its deployed version.
    There are too many things that can go wrong. Likely the path doesnt exist or is not accessible. Anyway with xdebug you should find it out quickly.

    Comment


    • #3
      lol nice hint, already using PHPStorm for debugging but not finding any errors other than the scriptcase commands included....
      The file path is ok as I have managed to save files to the same path with another blank app I have working....

      Any other tips?

      Comment


      • #4
        I guess the path is restricted to write in. Is mysql allowed to even write in that path then? Shouldnt you test that first with a super simple test?
        ../_lib/file/doc/backup/'.[clubID].'/ can be a read only directory. Technically this looks like it should work.
        I think you need to set up logging in mysql first, since it is mysql that apparently fails. If it is some rights thing you should see it there then (me hopes).

        Comment

        Working...
        X