By 24 Gennaio 2012 0 Comments

Dare possibilità a UTENTI di Effettuare Backup e Ripristino di SQL Server

In Sql Server, di default, possono effettuare i BACKUP dei database solo gli utenti che appartengono al gruppo db_backupoperator. Di contro possono effettuare ripristini di backup solo gli utenti che appartengono al gruppo sysadmin.

NOTE da Microsoft :

BACKUP
BACKUP DATABASE and BACKUP LOG permissions default to members of the sysadmin fixed server role and the db_owner and db_backupoperator fixed database roles

RESTORE
If the database being restored does not exist, the user must have CREATE DATABASE permissions to be able to execute RESTORE. If the database exists, RESTORE permissions default to members of the sysadmin and dbcreator fixed server roles and the owner (dbo) of the database (for the FROM DATABASE_SNAPSHOT option, the database always exists). RESTORE permissions are given to roles in which membership information is always readily available to the server. Because fixed database role membership can be checked only when the database is accessible and undamaged, which is not always the case when RESTORE is executed, members of the db_owner fixed database role do not have RESTORE permissions.

Ad ogni modo c’è un modo per fornire a gli utenti la possibilità di fare backup senza dover necessariamente assegnare l’utente al gruppo sysadmin.
Impostare l’utente come segue :

Server Level Permissions (nella sezione Security > Login > proprietà sull’utente):
*dbcreator
*public

Database Level Permissions (nella sezione Database > Nome del DB > Security > User > Utente Scelto):
*db_backupoperator
*db_denydatareader
*public

in questo modo l’utente potrà effettuare attività di BACKUP.

Per il ripristino è un pò diverso in quanto l’utente dovrà utilizzare la RIGA di COMANDO per effettuare un Ripristino, altrimenti il sistema risponderà con l’errore :
RESTORE non è in grado di elaborare il database ‘ARCHIVIODB’ perché è in uso dalla sessione corrente.
Quindi è necessario “passare” per il database MASTER con questo comando:

(esempio)

USE master;
GO

RESTORE DATABASE TEST2
FROM DISK = N’E:ftpcartellaDb6722′
WITH
FILE = 1,
NOUNLOAD,
REPLACE,
STATS = 10
GO

Posted in: Sql Server

About the Author:

shared on wplocker.com