Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Express Backup


SQL Express Backup

Author
Message
kgrady
kgrady
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
I'm new to SQL and we have an SQLExpress database that we need to backup on a nightly basis. Is there a backup process with SQLExpress or will the Windows Server Backup process include the database if we point it to SQL location..?? Thank you..!!
spaghettidba
spaghettidba
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5732 Visits: 13305
With SQLExpress you don't have SQLAgent to run backups. You have to manually set up a Windows Scheduled Task to run a backup command.
A simple filesystem backup won't help in case you need to restore a database: you have to backup the database, not its files.

--
Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
kgrady
kgrady
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
Do you mean like a Batch(.bat) file to run...??? Is there an example anywhere..?? Thank you..!
spaghettidba
spaghettidba
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5732 Visits: 13305
Take a look at this:
http://www.sqldbatips.com/showarticle.asp?ID=27

--
Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
kgrady
kgrady
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
Thanks so much...!! I deeply appreciate your help..!! Have a great day..!!
AlexGreen
AlexGreen
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 40
You can also try this GUI tool SQL Backup and FTP which lets you schedule your backups. It is very simple to use and it's free :-)
Todd Beller
Todd Beller
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 8
Another useful free tool is SQL Backup Master.

http://www.sqlbackupmaster.com/
vikingDBA
vikingDBA
SSC-Enthusiastic
SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)

Group: General Forum Members
Points: 198 Visits: 929
Here is a simple example.

First file is the .sql script. It is invoked using SQLCMD in a batch file. Create one of these .sql files for each of the databases that you want to back up, including the system databases (master, model, msdb).

Then create a .bat file and have a line in it invoking SQLCMD for each of the database files that you want to run.


MyDatabase_backup_script.sql
==========================
DECLARE @fn nvarchar(256),
@dbname nvarchar(50),
@stmt nvarchar(4000),
@path nvarchar(4000)


SET @dbname = 'MyDatabase'
SET @path = 'c:\SQLBackups\' + @dbname + '\'


SET @fn = @path + @dbname + '_backup_' +
CONVERT(nchar(8),getdate(), 112) +
right(N'0' + rtrim(CONVERT
(nchar(2), datepart(hh, getdate()))), 2) +
right(N'0' + rtrim(CONVERT
(nchar(2), datepart(mi, getdate()))), 2) +
N'.bak'
--SELECT @fn
SET @stmt = 'BACKUP DATABASE '
+ QUOTENAME(@dbname, '[') + ' to disk
= ''' + @fn + ''''
--SELECT @stmt
EXEC (@stmt)





Database_backups.bat
==========================
sqlcmd -S (local)\SQLEXPRESS -E -i C:\SQLEE_Backups\MyDatabase_backup_script.sql -o C:\SQLBackupLogs\MyDatabase_backuplog.txt


Have one of these lines for each database to back up, then just schedule the .bat file to run every night, say at 1am.
The (local) part runs on the local machine, where the batch file is ran. This could be changed to the specific server or pc name if needed.
The -o text file is the output log file of the run. It will show any errors if it encounters any. I would keep the name in a format that will just overwrite itself so you don't have to worry about multiple versions to clean up. Note that this will be an issue with the database backups, since the script backs it up to a file name with a date stamp on it.


Here is an example of a .sql script to do a tranlog backup. Again, just have a .sql file for each database that you need to do tranlog backups for, and put them in a separate .bat file and set to run multiple times per day.

Tranlog backup script
==================================
DECLARE @fn nvarchar(256),
@dbname nvarchar(50),
@stmt nvarchar(4000),
@path nvarchar(4000)


SET @dbname = 'MyDatabase'
SET @path = 'c:\SQLBackups\' + @dbname + '\tlogs\'


SET @fn = @path + @dbname + '_backup_' +
CONVERT(nchar(8),getdate(), 112) +
right(N'0' + rtrim(CONVERT
(nchar(2), datepart(hh, getdate()))), 2) +
right(N'0' + rtrim(CONVERT
(nchar(2), datepart(mi, getdate()))), 2) +
N'.trn'
--SELECT @fn
SET @stmt = 'BACKUP LOG '
+ QUOTENAME(@dbname, '[') + ' to disk
= ''' + @fn + ''''
--SELECT @stmt
EXEC (@stmt)



Hope it helps.
mr.jeff.freedman
mr.jeff.freedman
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 13
vikingDBA (1/18/2013)
Create one of these .sql files for each of the databases that you want to back up, including the system databases (master, model, msdb).

Why is there need to backup system DBs too?
spaghettidba
spaghettidba
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5732 Visits: 13305
System databases can get corrupted just as user databases.
In case of corruption, you'll need a backup copy if you don't want to install from scratch.

--
Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search