Jump to content
MakeWebGames

Recommended Posts

Posted

This small mod will allow you to backup your SQLS to a folder on your FTP

create a new folder on your FTP called sqlbackups Or what ever you want to name the folder but remember to edit the name on the following piece

folder needs to be CHMODDED to 755 and make sure you place a index.php or index.html file into your newly created folder...

$mysql_host = "localhost";

$mysql_user = "username";

$mysql_pass = " -p\"password\""; // LEAVE the Final \ where it is this is incase your password uses amps or @'s

$mysql_db = "databasename";

$backupbaselocation = "/home/xxxxxx/public_html/sqlbackups"; // change the xxxxxx to your ftp username if you changed the folder name as above then change this to match

$backuplocation = $backupbaselocation . "/" . date("d-m-Y");

mkdir($backuplocation, 0777);

system("mysqldump --user=$mysql_user --password=$mysql_pass $mysql_db > $backuplocation/database.sql");

now copy and paste the whole part before the ?> on your cron_day

And your done your SQLS will be backed up each day

Posted

It will run on all Server sometimes getting the $backupbaselocation = "/home/xxxxxx/public_html/sqlbackups"; location correct can be a pain as some use different methods but on mine its as ive shown...

some have example >> $backupbaselocation = "usr/www/home/xxxxxx/public_html/sqlbackups"; so edit this if it fails

Posted

You may want to look into compressing this, otherwise it could be huge.

$backupbaselocation = "/home/xxxxxx/public_html/sqlbackups"; // change the xxxxxx to your ftp username if you changed the folder name as above then change this to match

$backuplocation = $backupbaselocation . "/" . date("d-m-Y");

mkdir($backuplocation, 0777);

system("mysqldump --user=$mysql_user --password=$mysql_pass $mysql_db | gzip > $backuplocation/database.gz");

Should do the trick

Posted
is there a way to make it so that a full backup gets sent to your email everyday?

In short yes, getting it to send as an attachment is flippin' tricky but possible.

Posted

ive been tinkering with the script and its possible for the script to just pull 1 table from the database and put that to the folder instead of the whole lot..

Posted

Specific tables

mysqldump -uusername -ppassword database-name table1,table2,table3 | gzip > db.sql.gz

You can send the files using PHP ftp_connect and ftp_put

http://php.net/manual/en/function.ftp-put.php

I prefer to use linux shell for backups kept out of root backed up to a directory out of root and a copy is also passive ftp'd to a remote backup server which is only accessible on the network not from the net itself. But I also run a ecommerce business so keeping backups is essential.

Posted
is there a way to make this work for people that dont use ftp

 

Is this a trick question :)

even for those who have cpanel you can use te file manager to locate the sqls files in the folder you created

  • 9 months later...
Posted
is there a way to make it so that a full backup gets sent to your email everyday?

You could do this indeed but maybe hard on a shared host due to most hosts blocking the system, and many other, functions due to the security reasons.

Join the conversation

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

Guest
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...