Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have to backup a mysql database to certain drive. The user select two dates, I want to backup the database between this two date . I am working in winform c# application.

Thanks for your time and consideration.
Posted
Comments
Ron Beyer 17-Dec-13 10:28am    
What have you tried? Where are you stuck?
binoyvijayan 17-Dec-13 10:32am    
void Backup()
{
string constr = "server=localhost;user=root;pwd=qwerty;database=test;";
string file = "C:\\MyDumpFile.sql";
MySqlBackup mb = new MySqlBackup(constr);
mb.ExportInfo.FileName = file;
mb.Export();
}
binoyvijayan 17-Dec-13 10:31am    
I am trying with the MySqlBackUp class. But it has no way to specify the date

Backups don't have a date specification so your question doesn't make any sense. You either take a backup of the entire database, tables and all data in them, or you're not creating a backup.

What I think you're refering to is copying records between data ranges to a another table in another database.
 
Share this answer
 
Comments
binoyvijayan 18-Dec-13 4:08am    
Hi,
Thanks for your Reply,
Let me explain little,

I am working on a desktop application, its a database management tool.The user specify the minimum memory space level.The code check the drive that the database is stored, when the free space of the drive is less than the specified minimum memory space .then we persist a certain period data to same drive and remaining backup to another media (flash drive, external hdd etc). The Persisting database period is specified by the user.
Now I think you get my situation..
Thanks ...
Please help me
Dave Kreskowiak 18-Dec-13 12:34pm    
Yes, I understand, and that doesn't changethe answer. What you're talking about is not backup, but archiving old data. The two concepts are not the the same.
So far the best solution to backup MySQL database is here: MySqlBackup.NET - MySQL Backup Solution for C#, VB.NET, ASP.NET[^]

But i think, you need to use INSERT[^] and/or UPDATE[^] stetemens.

It would be something similar to below query:
SQL
INSERT INTO DestinationDatabase (Field1, Field2, Field3, ..., FieldN)
SELECT (Field1, Field2, Field3, ..., FieldN)
FROM SourceDatabase
WHERE DateField BETWEEN @date1 AND @date2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900