Want to Make Successive Backups for a database - c#

I have written certain code to take the Backup of a Database, the application will take the Database Backup automatically at the time Specified. Now, I want some help to take Successive Backup of the Same Database which was taken previously and dont want to take Complete Database Backup again and again. Can any one Help me.

How to make incremental backups with MS Sql Server in c# : http://www.mssqltips.com/tip.asp?tip=1849

Related

C# desktop app/SQL Server backup strategies

I am planning to make a C# desktop app with SQL Server 2019 Express.
Because I am not so familiar with SQL Sever, it'd be appreciated if any advice given on the feasibility of my thoughts, thanks in advance!
Here are my planned backup strategies:
This app is for personal use, I make it and I use it.
Any modification to the database will be wrapped as a transaction.
Full backup of the target database will be conducted once a day, and differential backup EVERY TIME after successfully committed a transaction.
All backups are using BACKUP statement through C# code.
Questions:
Because I have backup for every modification, so I can just use "Simple" restore model, and there is no need to use Transaction Log backup, is that right?
For the same reason, I don't need to backup every time I close the app, right?
Why I am asking this is because differential backup take about 560KB even right after a full backup and without any change.
Do I need to backup system databases other than the one used by the app?
(I might change hosting pc in the future, can the backups be restored to other SQL Server instances without system databases backups?)
Thanks!

Any way other than scripting to back up data for one month of a single table in database?

I have actually built an application using C# to do differential backup with compression option on daily to reduce bak file size and increase the speed of backup. However, the file size is still too large for me. So I plan to backup the whole database but I want one of a table (that contain the most data) to contain only one month data. Any idea ? Thanks.
If not mistaken what you meant by large is you tried to backup the whole database and it require more time and processing power.
I assume that you don't have the privileges to modify the table in the original database. Maybe you can try using this https://www.w3schools.com/sql/sql_select_into.asp
to copy the rows that you can set in the "WHERE" statement to another table (external database) and then backup it.

How to auto backup MySql database periodically in winforms?

In winforms application I want to backup my database once for every week. How can i do this. Can it be done through Coding or should I go for batch file? And the backup must be done automatically with out any user interface..
You could do it either way.
If you write a batch file, you can have the Windows Scheduler run this file once a week.
Either way, you must make sure the database is closed before running the backup. This may be easier with code.
Use the Copy method of the System.IO.File class.

SQL Server 2008 R2 Express restore

I am working on project in which I have used visual c# as front end and SQL Server 2008 R2 Express for backend.
Now I know that SQL Server express database has a size limit is of 10 GB, so I have written the code for database backup when pick limit is reached and I empty the database once the backup is successful.
I want to know what will be best approach to restore the backup file so that my current applications backend (which I have emptied earlier) should not be disturb.
Is it okay if I restore the same in my current database, in that case I have question to ask does it affect my applications working, as my application is kind of real time and after every 15 min. interval stored some values in database.
Whether I need to write some other utility for seeing the old data..?
Every day around 50 MB of data is inserted into database, so it will take around 8 months to reach the pick size( as per my rough calculations). and as far as the nature of application is concern user will not going to use archive data frequently. please consider this and suggest me the approach.
thanks in advance..!!
Hope i got your question right, but consider the following suggestion for working:
one database ("Current DB") that stores the real-time data.
when it comes to a size, it is dumped (or copied mdf+ldf) to archive.
and stored with time stamps (FROM-TO).
When data is needed, the relevant mdf is attached as a new "offline" database.
(you can use a connection string to attach MDF file to an SQL Server.)
and use that connection instead of the live one.
The application can run smoothly on the On-line database.
while reading, loading etc...
is done from the temporary attached and detached database files.
Take a look at : Connection String to Connect to .MDF
for how to Attach a MDF to SQL Server instance.
If you enter the data in a whole new database server your old queries won't work on the new one. As SQL Express limit is not per database, but per database server.
You could create a new SQL Express Server, link your servers and create a query with a linked server ( How to create a linked server # msdn )
You will need to adjust your queries.
If you query your data now like this:
SELECT em.Name, em.Telefone FROM employees AS em
You need to refer the database too.
SELECT [server1\db1].dbo.em.Name, [server1\db1].dbo.em.Telefone FROM [server1\db1].dbo.employees AS em
for your current database, and
SELECT [server2\backup].dbo.em.Name, [server2\backup].dbo.em.Telefone FROM [server2\backup].dbo.em.Name
It is possible like this but I would not advise it. If you exceeded 10GB data already then you might have large tables. Each table at a linked server is copied completely to you server and could cause serious network traffic and takes quite some time to be executed.
I would think of getting the SQL Standard edition.

Sybase: create a database from a backup file

Using SQL statements (sybase) how can I create or restore a full database given the conpressed backup file (myDatabase.cmp.bak).
The reason i'm saying create or restore is that the DB already exists but I can drop it before creating it if that's easier.
Do I need to worry about Device files? For example if the backup file used 3 database files each a certain size do I need to create the empty device files first or will that be taken care of during the restore?
I'm doing this from a C# app
Cheers
Damien
First, a word of warning. You are attempting DBA tasks without reasonable understanding, and without a decent connection to the server.
1 Forget your C# app, and use isql or DBSQL or SQL Advantage (comes with the CD). You will find it much easier.
2 Second, read up on the commands you expect to use. You need a handle on the task, not just command syntax.
--
No, you do not have to change the Device files at all.
Yes, you do need to know the copression and the database allocations of the source (dumped) database. Usually when we transfer dump_files, we know to send the database create statement and the compression ratio with it. The no of stripes are also required but that is easy to ascertain.
If your target db is reasonably similar to the source db, as in, it was once synchronised, you do not need to DROP/CREATE DB , just add the new allocations. But if it isn't, you will need to. The target db must be created with the exact same CREATE/ALTER DB sequence as the source db. Otherwise, you will end up with mixed data/log segments, which prevents log dumps, and deems the db unrecoverable (from the log). That sequence can be gleaned from the dump_file, but the compression has to be known. Hence much easier for the target DBA, if the source DBA shipped the CREATE/ALTER DB and dump commands.

Categories