Re: Password protected BAK Files

From: Jasper Smith (jasper_smith9_at_hotmail.com)
Date: 12/31/03


Date: Wed, 31 Dec 2003 19:47:04 -0000

SQL2000 only

BACKUP DATABASE pubs to DISK = 'c:\pubs.bak'
WITH PASSWORD = 'test'

If you try and restore this without a password, you get

RESTORE DATABASE pubs FROM DISK = 'c:\pubs.bak'
WITH REPLACE

Server: Msg 3279, Level 16, State 2, Line 1
Access is denied due to a password failure
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

To restore, you need the password e.g.

RESTORE DATABASE pubs FROM DISK = 'c:\pubs.bak'
WITH REPLACE,PASSWORD = 'test'

However, I've never really seen anyone use this. There's also the issue of
managing/generating/storing the passwords so they're not just hardcoded into
the jobs but using something like NEWID would probably do it but you would
have to store it with the backup filename somewhere so you could restore it
e.g.

declare @p varchar(36) ; set @p = NEWID()
declare @file varchar(200) ; set @file = '<generate filename>'
-- store password away somewhere secure with filename
BACKUP DATABASE pubs to DISK = @file
WITH PASSWORD = @p

-- 
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Tuoc" <anonymous@discussions.microsoft.com> wrote in message
news:D9549303-3521-4C75-ABFB-685820FC140D@microsoft.com...
> Hello All,
>
> Can anyone help me? I would like to put a password on BAK files everytime
my backup jobs run. So that when I restore a db from one of these BAK files,
I need to provide the password.
>
> Thanks in Advance,
> Tuoc


Relevant Pages

  • Re: Slow XP
    ... Did you update hardware drivers from the manufacturer when you upgraded OS ... When was the last time you checked your hard disk for problems? ... Microsoft has these suggestions for Protecting your computer from the ... The system restore feature is a new one - first appearing in Windows ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: New hard disk
    ... "Reboot after restore". ... Shall I have reformatted the disk prior to booting from the Drive Image ... Image was one of the first to support the use of external SCSI drives. ... Should I have ran Drive Image prior to the Windows restore CD? ...
    (microsoft.public.windowsxp.newusers)
  • Re: user32.dll - error and then Blues Screen c0000135 user32.dll
    ... I do have a PS2 mouse and Keyboard installed so that this menu is usable. ... I did not know that there was a WIn XP Pro CD in the disk drive when i ... work - i.e. bring me to anything tha tlooked like a restore menu .. ... original install.) ...
    (microsoft.public.windowsxp.general)
  • Re: user32.dll - error and then Blues Screen c0000135 user32.dll
    ... I did not know that there was a WIn XP Pro CD in the disk drive when i ... Disable automatic restart on system failure. ... work - i.e. bring me to anything tha tlooked like a restore menu .. ...
    (microsoft.public.windowsxp.general)
  • Re: New hard disk
    ... "Reboot after restore". ... Shall I have reformatted the disk prior to booting from the Drive Image ... Image was one of the first to support the use of external SCSI drives. ... Should I have ran Drive Image prior to the Windows restore CD? ...
    (microsoft.public.windowsxp.newusers)