Jump to content

Recommended Posts

Posted

Hi Juliodm,

 

Welcome to the forums :)

 

Do you just want a backup? Go into backups, and select the database you want to backup.

 

If you want to do it as an export ...

Log into cpanel,

go into MySql Databases

At the bottom of the page, go into phpmyadmin

Select the database (on the left hand side)

Select Export, and the format you need.

 

Or do you need to do it as php? why? If you could explain a little more, we may be able to help.

Posted
Hi Juliodm,

 

Welcome to the forums :)

 

Do you just want a backup? Go into backups, and select the database you want to backup.

 

If you want to do it as an export ...

Log into cpanel,

go into MySql Databases

At the bottom of the page, go into phpmyadmin

Select the database (on the left hand side)

Select Export, and the format you need.

 

Or do you need to do it as php? why? If you could explain a little more, we may be able to help.

 

Thanks for the welcome...

I need to set it up so that whenever a manager logs into my system, a php script will create a file and automatically force his browser to download it. I don't want to use cronjobs and I don't want to specify any tables, I need everything that exists in the one database file out as an sql file.

Posted (edited)
Welcome to the forum, juliodm

 

See if there is anything in this thread will help you.

 

I installed the dbsender script and added my personal info for my site. The page shows no errors and doesn't do a thing. No file is outputed no errors are given, I get just a white screen.

Edited by juliodm
Posted

Are you configuring the script correctly?

 

// configure your database variables below:

$dbhost = 'localhost'; // Server address of your MySQL Server

$dbuser = 'cpanelname_DBuser'; // Username to access MySQL database

$dbpass = 'user-password'; // Password to access MySQL database

$dbname = 'cpanelname_DBname'; // Database Name

 

// Optional Options You May Optionally Configure

 

$use_gzip = "yes"; // Set to No if you don't want the files sent in .gz format

$remove_sql_file = "yes"; // Set this to yes if you want to remove the .sql file after gzipping. Yes is recommended.

$remove_gzip_file = "yes"; // Set this to yes if you want to delete the gzip file also. I recommend leaving it to "no"

 

// Configure the path that this script resides on your server.

 

$savepath = "/home/cpanelname/path-to-script"; // Full path to this directory. Do not use trailing slash!

 

$send_email = "yes"; // Do you want this database backup sent to your email? Fill out the next 2 lines

$to = "validuser@your-destination.com"; // Who to send the emails to

$from = "validuser@your-domain.com"; // Who should the emails be sent from?

 

$senddate = date("j F Y");

 

$subject = "MySQL Database Backup - $senddate"; // Subject in the email to be sent.

$message = "MySQL database has been backed up and is attached to this email"; // Brief Message.

Posted
Are you configuring the script correctly?

 

This is my file:

 

$dbhost = 'localhost'; // Server address of your MySQL Server

$dbuser = 'myusername'; // Username to access MySQL database

$dbpass = 'mypassword'; // Password to access MySQL database

$dbname = 'myDBName'; // Database Name

 

$use_gzip = "yes"; // Set to No if you don't want the files sent in .gz format

$remove_sql_file = "no"; // Set this to yes if you want to remove the .sql file after gzipping. Yes is recommended.

$remove_gzip_file = "no"; // Set this to yes if you want to delete the gzip file also. I recommend leaving it to "no"

 

$savepath = "/home/myusername/path_to_script/"; // Full path to this directory. Do not use trailing slash!

 

$send_email = "no"; // Do you want this database backup sent to your email? Fill out the next 2 lines

$to = "myemailaddress"; // Who to send the emails to

$from = "myemailaddress"; // Who should the emails be sent from?

 

$senddate = date("j F Y");

 

$subject = "MySQL Database Backup - $senddate"; // Subject in the email to be sent.

$message = "Your MySQL database has been backed up and is attached to this email"; // Brief Message.

 

No file is created, no errors give.

Posted

You need to pre-fix your cpanel_name

 

$dbuser = 'CpanelName_myusername'; // Username to access MySQL database

$dbpass = 'CpanelName_mypassword'; // Password to access MySQL database

 

and change

$send_email = "no";

to

$send_email = "yes";

Posted (edited)
You need to pre-fix your cpanel_name

 

$dbuser = 'CpanelName_myusername'; // Username to access MySQL database

$dbpass = 'CpanelName_mypassword'; // Password to access MySQL database

 

and change

$send_email = "no";

to

$send_email = "yes";

 

What do you mean by cpanelname.... your saying that, if for example, my username was "onelove" and my password was "password" that I have to write "onelove_onelove" for my username and "onelove_password" for my password?

 

Also I don't want it to send me an email, I wan't to be able to pass the created file to the logged in manager via a URL redirect.. but if no file exists, then this won't work, neither will emailing it.

 

I just tried it your way and this is what I got:

 

Warning: filetype() [function.filetype]: Lstat failed for (null) (errno=2 - No such file or directory) in /home/myusername/public_html/test/dbsender.php on line 85

 

Warning: fopen(/home/myusername/public_html/test/myusername_siteData-103006-0713pm_sql.tar.gz) [function.fopen]: failed to open stream: No such file or directory in /home/myusername/public_html/test/dbsender.php on line 91

 

Warning: filesize() [function.filesize]: Stat failed for /home/myusername/public_html/test/myusername_siteData-103006-0713pm_sql.tar.gz (errno=2 - No such file or directory) in /home/myusername/public_html/test/dbsender.php on line 92

 

Warning: fread(): supplied argument is not a valid stream resource in /home/myusername/public_html/test/dbsender.php on line 92

 

Warning: fclose(): supplied argument is not a valid stream resource in /home/myusername/public_html/test/dbsender.php on line 93

Database backup created and sent! File name /home/myusername/public_html/test/myusername_siteData-103006-0713pm_sql.tar.gz

 

And then I checked my email and the gz file it references doesn't exist... it's a null string.

Edited by juliodm
Posted

To access a database you need to use your cpanel login name

with the database name and user

as Bruce indicated.

 

// configure your database variables below:

$dbhost = 'localhost'; // Server address of your MySQL Server

$dbuser = 'cpanelname_DBuser'; // Username to access MySQL database

$dbpass = 'user-password'; // Password to access MySQL database

$dbname = 'cpanelname_DBname'; // Database Name

 

Sorry I did not mean to add cpanelname to the password.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...