Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6913737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:15:21+00:00 2026-05-27T09:15:21+00:00

I have developed a script that my company uses to back up our client’s

  • 0

I have developed a script that my company uses to back up our client’s DBs on our server by creating a dump file of their DBs. Here is my code:

$result=mysql_query("SELECT * FROM backup_sites");
while($row=mysql_fetch_array($result)){

    $backup_directory=$row["backup_directory"];
    $thishost=$row["host"];
    $thisusername=$row["username"];
    $thispassword=$row["password"];
    $thisdb_name=$row["db_name"];

    $link=mysql_connect("$thishost", "$thisusername", "$thispassword");
    if($link){
        mysql_select_db("$thisdb_name");
        $backupFile = $thisdb_name ."-". date("Y-m-d-H-i-s", strtotime ("+1 hour")) . '.sql';
        $command = "/usr/bin/mysqldump -h $thishost -u $thisusername -p$thispassword $thisdb_name > site-backups/$backup_directory/$backupFile";
        system($command);   
    }
}

The script gets all the client’s db information from a table (backup_sites) and loops through each one to create the backup file in that client’s directory. This script works great when it is manually executed. The problem that I am having is that it does not work when I set it to run as a Cron job. The email from the Cron job contains this error for each DB backup attempt:

sh: site-backups/CLIENT_DIRECTORY/DB_DUMP_FILE.sql: No such file or directory

So for whatever reason, the Cron job is unable to create/write the DB dump file. I can’t figure this one out. It just seems strange that the script works perfectly when executed manually. Anyone have any ideas? Thanks in advance!

Adam

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:15:22+00:00Added an answer on May 27, 2026 at 9:15 am

    Consider using absolute pathes. Cron may have a different base directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a PHP script that uses $_REQUEST[] superglobal. A typical client request
I have developed code on a m-file script in Matlab that communicates with a
I have developed a script that uses php's imap_search and when it gets to
I have developed a C# script that opens an XLS file, parses it and
I have developed a Powershell script that needs to be run automatically daily. This
We have a HSQL .script file in source control. Some of our developers use
I've developed a Perl script that has a confidential business logic. I have to
I've been editing a script for a company that had this application specifically developed
I have developed a script for checking that user has selected a valid month
We have a new website developed by a outside company that we are having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.