Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automatic Backup with SQL Server Express

294 views
Skip to first unread message

Fabio Martins

unread,
Jan 5, 2009, 7:30:30 AM1/5/09
to
Hi!

How can I set up an automatic backup with SQL Server Express?

Thankyou in advance.

FM

Ekrem Önsoy

unread,
Jan 5, 2009, 7:43:36 AM1/5/09
to
Write a T-SQL script which contains backup commands, schedule this script
using Windows Scheduler and run the script using SQLCMD.

--
Ekrem Önsoy


"Fabio Martins" <support.m...@fabiomartins.net> wrote in message
news:Ou3wNFzb...@TK2MSFTNGP06.phx.gbl...

Fabio Martins

unread,
Jan 5, 2009, 8:34:54 AM1/5/09
to
Thankyou for answering!
I'll look for how to do it in google ;) I don't know almost nothing about
SQL Server.
I'll be very glad if you have an example for me.

Thankyou!

FM

"Ekrem Önsoy" <ek...@compecta.com> escreveu na mensagem
news:A8732FAA-8541-4F79...@microsoft.com...

Ekrem Önsoy

unread,
Jan 5, 2009, 9:21:01 AM1/5/09
to
Well, I can redirect you to the related resources about SQLCMD utility and
BACKUP command in SQL Server.

BACKUP:
http://msdn.microsoft.com/en-us/library/ms186865(SQL.90).aspx

SQLCMD:
http://msdn.microsoft.com/en-us/library/ms162773.aspx

I have an article about this subject but it's in Turkish. If you are
interested:
http://www.ekremonsoy.net/makaleler/sql/express_edition_yedek/express_edition_otoyedek.aspx

Example to BACKUP Command (assume you saved the following line to a file
called AutoBackup.sql):
BACKUP DATABASE [test_2005] TO DISK = N'c:\test\test.bak'

Example to SQLCMD to run the BACKUP script:
SQLCMD -S [Ekrem-PC\SQLEXPRESS] -E -i C:\Test\AutoBackup.sql
For example the -S switch stands for Server Name, -E means this is going to
be a Trusted Connection and -i is to define the script file. See the links
above for more information about these commands... And ask if you have any
further questions in case you can't find the answer from those links.

--
Ekrem Önsoy

"Fabio Martins" <support.m...@fabiomartins.net> wrote in message

news:OdeTNpzb...@TK2MSFTNGP06.phx.gbl...

Daniel Imesch

unread,
Jan 6, 2009, 2:01:37 PM1/6/09
to
Hi Fabio,

A simple procedure to backup the database, change the backup path.
You can start this procedure with sqlcmd.

Regards,
Daniel


CREATE PROCEDURE [dbo].[backup_db]
@db varchar(50),
@backup_path varchar(254) = 'D:\SQL_BACKUP\'
AS
------------------------------------------------------------------------------------------
DECLARE @backup_device nvarchar(1024);
DECLARE @backup_name nvarchar(127);
DECLARE @device_type nvarchar(50);
------------------------------------------------------------------------------------------
SET @backup_device = @backup_path + @db + '_db.bak';
SET @backup_name = @db +'-Full Database Backup';
SET @device_type = 'disk';

EXEC master.dbo.sp_addumpdevice
@devtype = @device_type,
@logicalname = @db,
@physicalname = @backup_device;

BACKUP DATABASE @db TO @db WITH NOFORMAT, INIT,
NAME = @backup_name , SKIP, NOREWIND, NOUNLOAD, STATS = 10;

EXEC sp_dropdevice @db;
Go


"Fabio Martins" <support.m...@fabiomartins.net> a écrit dans le
message de news:Ou3wNFzb...@TK2MSFTNGP06.phx.gbl...

Fabio Martins

unread,
Jan 6, 2009, 3:14:42 PM1/6/09
to
Thankyou!

The SQL command ran OK in Management Studio Express.
But after the SQLCMD command I got the message:

HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while
establishing a connection to the server. When connecting to SQL Server 2005,
this failure may be caused by the fact that under the default settings SQL
Server does not allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

How can I fix that?

FM


"Ekrem Önsoy" <ek...@compecta.com> escreveu na mensagem

news:AF722068-3A80-4E07...@microsoft.com...

Ekrem Önsoy

unread,
Jan 6, 2009, 4:44:57 PM1/6/09
to

Fabio, I think your problem is about the connection. Ensure that you use a
correct path for your SQL Server' s instance name and ensure that you use
correct information for the Login. To resolve your problem, you must study
the link I've provided you about SQLCMD.

Also, ensure that your SQL Server service is running.

--
Ekrem Önsoy

"Fabio Martins" <support.m...@fabiomartins.net> wrote in message

news:O1oQRtDc...@TK2MSFTNGP04.phx.gbl...

Daniel Imesch

unread,
Jan 6, 2009, 4:18:12 PM1/6/09
to
Hi Fabio,
 
Add the stored procedure to the master database then try to start the procedure in the management studio.
 
backup_db 'databaseName','filePath'
 
If this works try with sqlcmd set the database name:
 
sqlcmd -E -S .\SQLEXPRESS -d master -Q "backup_db 'databaseName','C:\TEMP\'"
 
(. is for the local machine)
 
Please activate the TCP/IP protocole in the SQL Service configuration.
 
It woks fine on my PC (Windows Vista).
 
Regards,
Daniel
 
 
"Fabio Martins" <support.m...@fabiomartins.net> a écrit dans le message de news:O1oQRtDc...@TK2MSFTNGP04.phx.gbl...

mar...@gmail.com

unread,
Jan 28, 2013, 12:08:06 PM1/28/13
to
Try SQL Backup Master (basic edition is free):

http://www.sqlbackupmaster.com
Message has been deleted

pass...@gmail.com

unread,
Jul 16, 2013, 3:00:09 AM7/16/13
to
Try out SQLBackupAndFTP software. It allows you backup your SQL databases to local/network folders, FTP, Dropbox, Box, Google Drive, Amazon S3 or SkyDrive destinations. You can scheduled backup jobs and setup email notifications.
Basic features are available in free version or you can try all features in trial mode.

http://sqlbackupandftp.com
0 new messages