Hello everyone!!
I want to refer for this problem. I want to backup my database after particular interval of time. Please guide me on concept of how to do this. I have something going on in mind but still need some advice!!
Suggestions Appreciated.
Regards!!
Automaticaly Backup Database
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Automaticaly Backup Database
Assuming mysql, put mysqldump in a cron job.amplifire wrote:Hello everyone!!
I want to refer for this problem. I want to backup my database after particular interval of time. Please guide me on concept of how to do this. I have something going on in mind but still need some advice!!
Suggestions Appreciated.
Regards!!
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Automaticaly Backup Database
As an alternative strategy, and in case your database is hosted somewhere that you don't have access to system functions like cron, here's another possibility to consider:
What many people don't think about, with respect to database backups, is that no purpose is served by backing up data that hasn't been modified since the previous backup, so if you design your application so that every transaction resets a timestamp in a table, then each time your application starts, it can compare the stored timestamp with the current date-time, and if more than a certain time has passed since the most recent transaction was processed, you can initiate the mysqldump, or similar function if it is not MySQL. This approach has limitations, of course. If the database is very active (transactions almost continuously) or if the database is extremely large (many gigabytes), this approach might cause slowdowns or interruptions. But for smaller and less active databases, I would prefer this to forcing backups that only replace the same data.
What many people don't think about, with respect to database backups, is that no purpose is served by backing up data that hasn't been modified since the previous backup, so if you design your application so that every transaction resets a timestamp in a table, then each time your application starts, it can compare the stored timestamp with the current date-time, and if more than a certain time has passed since the most recent transaction was processed, you can initiate the mysqldump, or similar function if it is not MySQL. This approach has limitations, of course. If the database is very active (transactions almost continuously) or if the database is extremely large (many gigabytes), this approach might cause slowdowns or interruptions. But for smaller and less active databases, I would prefer this to forcing backups that only replace the same data.
Re: Automaticaly Backup Database
Yes my Database is updated regularly. New entries are made every day. I read somewhere i can use system() function and then mysqldump to backup after some times. Although time stamp is not required but i will try to use it too.
Can Anyone tell me how system() function works?
Thanx!
Can Anyone tell me how system() function works?
Thanx!
Re: Automaticaly Backup Database
Code: Select all
#!/bin/sh
date=`date -I`
for I in $(mysql -u root -pPASSWORD -e 'show databases' -s --skip-column-names);
do
mysqldump -u root -pPASSWORD $I | gzip > "$date-$I.sql.gz";
doneRe: Automaticaly Backup Database
Hello everyone
I referred to you for database backup using mysqldump ans system() function to execute it.
So far iam able to create backup file, but my backup file is empty. When i use mysqldump from command line, it works.
But from php it doesnt work what could be the problem?
Here's my code:
Regards
I referred to you for database backup using mysqldump ans system() function to execute it.
So far iam able to create backup file, but my backup file is empty. When i use mysqldump from command line, it works.
But from php it doesnt work what could be the problem?
Here's my code:
Code: Select all
if($_POST['backup'])
{
$command="mysqldump -h localhost -u root nigamkota > database/backup.sql";
system($command);
echo "<script>alert('table has been copied');</script>";
}