A PHP Error was encountered

Severity: Warning

Message: Undefined variable $page

Filename: front/Articles.php

Line Number: 91

Backtrace:

File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 91
Function: _error_handler

File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Undefined variable $pages

Filename: front/Articles.php

Line Number: 110

Backtrace:

File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 110
Function: _error_handler

File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Undefined variable $page

Filename: front/Articles.php

Line Number: 111

Backtrace:

File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 111
Function: _error_handler

File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Undefined variable $category

Filename: front/Articles.php

Line Number: 113

Backtrace:

File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 113
Function: _error_handler

File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Undefined variable $articles

Filename: front/Articles.php

Line Number: 114

Backtrace:

File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 114
Function: _error_handler

File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once

Automated SQL Server backup (multiple servers, instances and databases) | Celtic Productions IT

Automated SQL Server backup (multiple servers, instances and databases)

  • Home
  • /
  • Technical Articles
  • A PHP Error was encountered

    Severity: Warning

    Message: Trying to access array offset on null

    Filename: front/article.php

    Line Number: 35

    Backtrace:

    File: /opt/bitnami/projects/celticproductions.net/application/views/front/article.php
    Line: 35
    Function: _error_handler

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 124
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 117
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/index.php
    Line: 315
    Function: require_once

  • /
  • Automated SQL Server backup (multiple servers, instances and databases)
on 13th December
  • windows
  • sql server
  • instance
  • backup
  • automated
  • database

SQL Server is one of the most stable and widely used database engines around in corporate environments. Given that SQL Server 2008 R2 Express+ is available free of charge, is rock solid and can support databases up to 10GB in size, it's a logical choice for many web and desktop applications hosted in-house in corporate environments. 

What can often be overlooked until it's too late (i.e. malware has corrupted the database, ransomware has encrypted it or the hard disk has given up the ghost) is a robust backup strategy. Commercial SQL Server backup tools can cost thousands but our method of choice is a robust Windows Powershell script. This script:


  • Works its way across the network
  • Pings instances to make sure they're online
  • Connects to those instances (it uses Windows Authentication so make sure it's run under an account with suitable privileges - or, the script could easily be modified to use a SQL Server login)
  • Loops through the databases in that instance
  • Runs a DBCC CHECKDB command to ensure the database is OK
  • Backs each database up in turn to a destination specified by a configuration file
  • Verifies that the database can be restored (i.e. that the backup is valid)
  • Generates a 7-zip backup for each machine it backed up data from
  • Verifies that the compressed archive is valid
  • and finally, it emails the log file to the system administrator at the end of the process

The Powershell code looks as follows:


You'll notice that a few configuration files adjust the way the script functions. Specifically, sql_server_backup_path.txt will simply contain the path (local to the SQL Server instance) to backup the databases to - in our example, we've set it to c:\PSBackup. sql_server_backup_servers.txt contains the list of machines that we should connect to, in this example, I'm connecting to 2 local machines and one remote machine:

REKII
REKIII
REKRMVI

Finally, sql_server_backup_exclude.txt contains a list of machines, instances or databases that should be excluded from the backup plan, i.e. in our example, we don't want to backup any databases from the IMF instance on REKII and we don't want to backup the country_data database in the BIS instance on REKIII:

REKII\IMF
REKIII\BIS\country_data

There are a couple of dependencies for all aspects of this script to work, i.e. you need the Powershell SQL snap-ins, the 7-zip command line utility and you should enter in your SMTP server and account credentials so you get the summary log email. I hope it offers at the very least a solid foundation for implementing a commercial SQL Server backup strategy.

As with all articles on Celtic Productions, this article is protected by international copyright laws. It may be linked to (we are of course most grateful of links to our articles), however, it may never be reproduced without the prior express permission of its owners, Celtic Productions. All code is provided as-is, without warranty of any kind, either express or implied.

  • A PHP Error was encountered

    Severity: Warning

    Message: Undefined array key "category"

    Filename: core/MY_Controller.php

    Line Number: 94

    Backtrace:

    File: /opt/bitnami/projects/celticproductions.net/application/core/MY_Controller.php
    Line: 94
    Function: _error_handler

    File: /opt/bitnami/projects/celticproductions.net/application/helpers/general_helper.php
    Line: 16
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/views/front/article.php
    Line: 241
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 124
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 117
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/index.php
    Line: 315
    Function: require_once

    /articles/18//enabling-gzip-compression-on-your-website.html" class="c-title"> Enabling Gzip compression on your website
    19th November
  • A PHP Error was encountered

    Severity: Warning

    Message: Undefined array key "category"

    Filename: core/MY_Controller.php

    Line Number: 94

    Backtrace:

    File: /opt/bitnami/projects/celticproductions.net/application/core/MY_Controller.php
    Line: 94
    Function: _error_handler

    File: /opt/bitnami/projects/celticproductions.net/application/helpers/general_helper.php
    Line: 16
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/views/front/article.php
    Line: 258
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 124
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 117
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/index.php
    Line: 315
    Function: require_once

    /articles/12//file-path-and-name-with-spaces-in-batch-file-for-loop.html" class="c-title"> File path and name with spaces in batch file for loop
    7th October
  • A PHP Error was encountered

    Severity: Warning

    Message: Undefined array key "category"

    Filename: core/MY_Controller.php

    Line Number: 94

    Backtrace:

    File: /opt/bitnami/projects/celticproductions.net/application/core/MY_Controller.php
    Line: 94
    Function: _error_handler

    File: /opt/bitnami/projects/celticproductions.net/application/helpers/general_helper.php
    Line: 16
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/views/front/article.php
    Line: 258
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 124
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 117
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/index.php
    Line: 315
    Function: require_once

    /articles/11//add-floating-point-numbers-in-batch-file.html" class="c-title"> Add floating point numbers in batch file
    7th October
  • A PHP Error was encountered

    Severity: Warning

    Message: Undefined array key "category"

    Filename: core/MY_Controller.php

    Line Number: 94

    Backtrace:

    File: /opt/bitnami/projects/celticproductions.net/application/core/MY_Controller.php
    Line: 94
    Function: _error_handler

    File: /opt/bitnami/projects/celticproductions.net/application/helpers/general_helper.php
    Line: 16
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/views/front/article.php
    Line: 258
    Function: get_link_for_article

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 124
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
    Line: 117
    Function: view

    File: /opt/bitnami/projects/celticproductions.net/index.php
    Line: 315
    Function: require_once

    /articles/2//remote-server-backup--ncftp-.html" class="c-title"> Remote Server Backup (ncftp)
    28th March