User Tools

Site Tools


wiki:backuppc_mssql

This is an old revision of the document!


Backup MSSQL Databases with BackupPC

Introduction

I did this before with Bareos/Bacula. I've since decided that product is a bit too black box for my liking. It always did what I asked of it, but the database would crash here and there and that freaked me out a bit. On to something new, and BackupPC was surprising better than I thought it would be. Admittedly it doesn't have an agent in the traditional sense which I don't like, but I was still able to achieve the needed goals.

What you'll need

  • Working BackupPC installation
  • SQL server account with sa-like privs - we'll create a more restricted backup user
  • Unprivileged account on domain or local to server for backuppc user
  • You have to have done this or something like it

The SQL Permissions

  1. Open SQL Server Management Studio - connect to the DB Engine in question as a SA or some such
  2. Drill into your Database engine's Security folder, right-click Logins and click New Login…
  3. In the Login - New dialogue fill in the Login name field with your Windows user account, use the Search… dialogue to make things simple. This can be a local or domain user. That's the only field that needs to be filled in, click OK.
  4. In the Databases folder, expand each Database you want to back up (often there is only 1), expand the Security folder within, right-click Users and click New User…
  5. Fill in User name and Login name with the information from step 3, in the Membership section check db_backupoperator, click OK
  6. Repeat steps 4 & 5 for all databases if you want to backup more than one
  7. Now is a good time to make a specific note of all the database names you want to back up, the database name is the actual text adjacent to the cylindrical shape, this will be used in the next section

The folder and scripts

  1. Create a folder somewhere on the server, I use a folder called “dbbackups” in the root of the C drive, it doesn't matter what it's called or where it is as long as there is enough free space to save the entirety of your SQL dumps there
  2. Change the permissions to be very restrictive on that folder, only the unprivileged windows user performing the backup from the SQL steps above needs access.
  3. We need 2 files in that folder
    backup_dbs.cmd
    erase "c:\dbbackups\*.bak"
    sqlcmd -E -i "c:\dbbackups\backupdbs.sql"


    backupdbs.sql
    BACKUP DATABASE [DATABASE_1] TO  DISK = N'c:\dbbackups\DATABASE_1.bak' WITH NOFORMAT, NOINIT,  NAME = N'DATABASE_1-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
    BACKUP DATABASE [DATABASE_2] TO  DISK = N'c:\dbbackups\DATABASE_2.bak' WITH NOFORMAT, NOINIT,  NAME = N'DATABASE_2-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
    GO
wiki/backuppc_mssql.1433366233.txt.gz · Last modified: 2018/09/27 02:30 (external edit)