Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2006
    Location
    Sydney, Australia
    Posts
    66
    Plugin Contributions
    0

    Default Automated database backup

    Hi,

    I am using the mod "Backup MYSQL Plugin" for the database backups that was made by DrByte.

    This is a create mod, however it would be even better if it was something that could be automated.

    So i am trying to make it into a script that i can cron it to run each night/week.

    Here is my code so far, however when i run it does nothing. Can anyone look and see what i've done wrong?

    PHP Code:
    <?php

    require('includes/application_top.php');

    $toolfilename '/usr/local/bin/mysqldump';
    $output DIR_FS_ADMIN 'backup.log';
    $dump_results DIR_FS_ADMIN 'backup-dump.log';
    $backup_file 'db_' DB_DATABASE '-' date('YmdHis') . '.sql';
    $dump_params .= ' "--host=' DB_SERVER '"';
    $dump_params .= ' "--user=' DB_SERVER_USERNAME '"';
    $dump_params .= ' "--password=' DB_SERVER_PASSWORD '"';
    $dump_params .= ' --opt';  
    $dump_params .= ' --complete-insert';  
    $dump_params .= ' "--result-file=' DIR_FS_BACKUP $backup_file '"';
    $dump_params .= ' ' DB_DATABASE;
    $dump_params .= " 2>&1";

    $resultcodes = @exec(OS_DELIM $toolfilename $dump_params $output$dump_results );
    @
    exec("exit(0)");
            
    require(
    'includes/application_bottom.php');

    ?>
    Thanks in advance!!!

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Automated database backup

    PM me for a cron script for this
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Apr 2006
    Location
    Sydney, Australia
    Posts
    66
    Plugin Contributions
    0

    Default Re: Automated database backup

    Hi,

    More of less worked it out myself. Here is my code, everyone free to use / reuse / comment as they feel fit.

    Most of it is inspiried by DrByte, so cheers to him.


    PHP Code:
    <?php

    // Change these to suit your location
    $location '/usr/home/XXXXXX/www/htdocs/XXXXadmin/';
    $toolfilename '/usr/local/bin/mysqldump';
    $gzipfilename '/usr/bin/gzip';

    require(
    $location 'includes/configure.php');

    $output DIR_FS_ADMIN 'backup.log';
    $dump_results DIR_FS_ADMIN 'backup-dump.log';
    $backup_file 'db_' DB_DATABASE '-' date('YmdHis') . '.sql';
    $dump_params ' "--host=' DB_SERVER '"';
    $dump_params .= ' "--user=' DB_SERVER_USERNAME '"';
    $dump_params .= ' "--password=' DB_SERVER_PASSWORD '"';
    $dump_params .= ' --opt';
    $dump_params .= ' --complete-insert';
    $dump_params .= ' "--result-file=' DIR_FS_BACKUP $backup_file '"';
    $dump_params .= ' ' DB_DATABASE;
    $dump_params .= " 2>&1";

    exec($toolfilename $dump_params $output);
    exec($gzipfilename ' ' DIR_FS_BACKUP $backup_file$output);

    ?>

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Automated database backup

    Nice, thank you for sharing this. Maybe you should post this in the Free Add On section so everyone can easily find it?
    Regards
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #5
    Join Date
    Jan 2007
    Posts
    226
    Plugin Contributions
    0

    Default Re: Automated database backup

    Hello Mooneyn,

    Could you provide the steps in how you use your code to create a cron?

    1. Ie. What do we save your code as?
    2. What do we enter in the cron in cpanel?

    Kind regards,
    Anthony

 

 

Similar Threads

  1. Automated Database / MySQL Backup
    By kwright in forum General Questions
    Replies: 7
    Last Post: 14 Jul 2009, 09:27 PM
  2. Automated Nightly DB Backup Script?
    By saschwarz in forum General Questions
    Replies: 5
    Last Post: 27 Jun 2008, 10:02 PM
  3. Backup MySQL Database vs using cPanel backup option?
    By IronMan101 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 30 Jul 2007, 08:46 AM
  4. Automated Backup via CRON ??
    By Netsmurf in forum General Questions
    Replies: 4
    Last Post: 14 May 2007, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg