sqlcmd -S.\SQLEXPRESS -Q "select name from sys.databases"

Similar documents
Backing Up TestTrack Native Project Databases

Using Windows Task Scheduler instead of the Backup Express Scheduler

5.6.3 Lab: Registry Backup and Recovery in Windows XP

Tool Tip. SyAM Management Utilities and Non-Admin Domain Users

FaxCore 2007 Application-Database Backup & Restore Guide :: Microsoft SQL 2005 Edition

Quick Start Guide. IT Management On-Demand

Management Utilities Configuration for UAC Environments

Assured PackOut Best Practices: Create a Back-Up

NovaBACKUP xsp Version 15.0 Upgrade Guide

Introduction Deploying Deep Freeze Enterprise with BigFix

AutoMerge for MS CRM 3

Microsoft SQL Server Scheduling

How to Backup Your Eclipse.Net Database Automatically. To clearly document a specific automatic SQL database backup method for Eclipse.net.

STATISTICA VERSION 9 STATISTICA ENTERPRISE INSTALLATION INSTRUCTIONS FOR USE WITH TERMINAL SERVER

STIDistrict SQL 2000 Database Management Plans

Backing Up CNG SAFE Version 6.0

Video Administration Backup and Restore Procedures

Published. Technical Bulletin: Use and Configuration of Quanterix Database Backup Scripts 1. PURPOSE 2. REFERENCES 3.

Lab: Data Backup and Recovery in Windows XP

Maintaining the Content Server

KEYWORDS InteractX, database, SQL Server, SQL Server Express, backup, maintenance.

Backup Procedures for IT Staff User Guide

FaxCore 2007 Database Migration Guide :: Microsoft SQL 2008 Edition

Automated backup. of the LumaSoft Gas database

Moving the Web Security Log Database

Database Back-Up and Restore

Database Backup Datacolor Match Pigment and Datacolor Tools

How to schedule and automate backups of SQL Server databases in SQL Server Express Editions

Lab - Data Backup and Recovery in Windows XP

Changing Passwords in Cisco Unity 8.x

Optional Lab: Schedule Task Using GUI and at Command in Windows 7

Upgrading a computer to Windows 10 with PetLinx

Version 8. Backing Up and Restoring Progeny Databases

Protecting SQL Server Databases Software Pursuits, Inc.

PaperStream Connect. Setup Guide. Version Copyright Fujitsu

Moving the TRITON Reporting Databases

TSM for Windows Installation Instructions: Download the latest TSM Client Using the following link:

Upgrading MySQL from 32-bit to 64-bit

JAVS Scheduled Publishing. Installation/Configuration... 4 Manual Operation... 6 Automating Scheduled Publishing... 7 Windows XP... 7 Windows 7...

Installation Manual Version 8.5 (w/sql Server 2005)

PCLaw Scheduled Backup

Configuring a Custom Load Evaluator Use the XenApp1 virtual machine, logged on as the XenApp\administrator user for this task.

Using

How to Install CS OrthoTrac on a New Server and Copy the Data from the Old Server to the New Version 12 and higher

G DATA TechPaper #0204. Installing G Data Security Client using GPOs and logon scripts. G DATA Service Team

Backups and Repository Maintenance

ProjectWise Explorer V8i User Manual for Subconsultants & Team Members

Introduction. This white paper provides technical information on how to approach these steps with Symantec Antivirus Corporate edition.

Application Note - JDSU PathTrak Video Monitoring System Data Backup and Restore Process

BSDI Advanced Fitness & Wellness Software

Setup and configuration for Intelicode. SQL Server Express

Setting Up ALERE with Client/Server Data

Migrating Mobile Security for Enterprise (TMMS) 8.0 to version 9.0

pure::variants Transformer for Software Configuration Management Manual

Automated Database Backup. Procedure to create an automated database backup using SQL management tools

Installation / Migration Guide for Windows 2000/2003 Servers

Installation Instruction STATISTICA Enterprise Small Business

Scheduling in SAS 9.3

SAS 9.3 Foundation for Microsoft Windows

How To Enable A Websphere To Communicate With Ssl On An Ipad From Aaya One X Portal On A Pc Or Macbook Or Ipad (For Acedo) On A Network With A Password Protected (

Backup Tab. User Guide

WS_FTP Professional 12

ArcGIS Server and Geodatabase Administration for 10.2

Installing Windows Server Update Services (WSUS) on Windows Server 2012 R2 Essentials

HOW TO CONFIGURE SQL SERVER REPORTING SERVICES IN ORDER TO DEPLOY REPORTING SERVICES REPORTS FOR DYNAMICS GP

STATISTICA VERSION 12 STATISTICA ENTERPRISE SMALL BUSINESS INSTALLATION INSTRUCTIONS

MIGRATING TO AVALANCHE 5.0 WITH MS SQL SERVER

Install MS SQL Server 2012 Express Edition

Appendix E. Captioning Manager system requirements. Installing the Captioning Manager

CONFIGURING MICROSOFT SQL SERVER REPORTING SERVICES

FaxCore Ev5 Database Migration Guide :: Microsoft SQL 2008 Edition

Unity Error Message: Your voic box is almost full

Creating Cost Recovery Layouts

12 NETWORK MANAGEMENT

QUANTIFY INSTALLATION GUIDE

Instructions for update installation of ElsaWin 5.00

How To Create An Easybelle History Database On A Microsoft Powerbook (Windows)

Quality Center LDAP Guide

STATISTICA VERSION 10 STATISTICA ENTERPRISE SERVER INSTALLATION INSTRUCTIONS

Scheduling in SAS 9.4 Second Edition

MINIMIZING DISK SPACE USAGE IN SAAS OR VIRTUAL OFFICE CS

Setting up the Oracle Warehouse Builder Project. Topics. Overview. Purpose

NovaBACKUP xsp Version 12.2 Upgrade Guide

Backup Cisco ICM Database in Microsoft SQL 2000

1. Product Information

Online Backup Client User Manual Linux

Database Administration

MaxSea TZ: Microsoft SQL Server problems End User

Network Server for Windows. Overview of the Sequencher Network Page 2. Installing Sequencher Server for the First Time Page 3

Recommended Solutions for Installing Symantec Endpoint Protection 12.1.x in Shared and PvD Virtual Machines

High Availability for Microsoft SQL Server 7.0 Using Double-Take

How to Set Up a Shared SQL Express Database with ManagePro 7 Standard version

Database Backup and Restore Instructions. Version 6.5. Instructions

Support Document: Microsoft SQL Server - LiveVault 7.6X

Outlook 2007: Managing your mailbox

Database Maintenance Guide

Nobeltec TZ: Microsoft SQL Server problems

VERITAS Backup Exec TM 10.0 for Windows Servers

Transcription:

A regularly scheduled backup of databases used by SyAM server programs (System Area Manager, Management Utilities, and Site Manager can be implemented by creating a Windows batch script and running it with Task Scheduler. In this document we ll look at a batch script created for this purpose. Copy the batch file (in our example it s named syamserverbackup.bat to the server where SyAM programs are installed. Edit the file using Notepad or your preferred text editor. User configuration of the backup script By default, backup is enabled for all three supported SyAM server programs. For any program that s not installed on the server, or to skip the backup for a program for any reason, set the corresponding variable to 0. SET backup_area_manager=1 SET backup_management_utilities=1 SET backup_site_manager=1 Specify the backup directory. This must be on a local drive, as the SQL backup does not support mapped drives or network shares. The script will create the directory if it does not already exist. You ll need to make sure the available free space is sufficient to store your backup files. The script creates a log file syamserverbackup.log in the same directory. C:\syamserverbackup\ is the default backup directory. SET budir=c:\syamserverbackup\ Set the number of days for backup retention; the default is 10. When the backup script runs, any backup files older than this number of days will be removed. When you choose the number of days for retention, you ll want to take into account how often the backup runs (daily, weekly, etc. and your available disk space. If retention is set to 0, the script never removes old backups. SET retention=10 Specify your SQL database instance;.\sqlexpress is the default. If SQL has been installed according to the specifications in SyAM documentation, you should be able to open a command prompt on the server and run (for example: 1

sqlcmd -S.\SQLEXPRESS -Q "select name from sys.databases" substituting the correct database instance if it is not.\sqlexpress. The command should return a list of SQL databases including syamutility (if Management Utilities is installed and syamdb (if Site Manager is installed. SET dbinstance=.\sqlexpress Finally, if System Area Manager is installed to a directory other than the default C:SyAM\ you ll need to specify the correct directory. SET amdir=c:\syam\ Save the backup script file when you re finished editing. Scheduling the backup When the script backs up the System Area Manager database, Area Manager services are stopped and then restarted after the database copy. Backing up the SQL databases for Management Utilities and Site Manager locks database tables while the copy runs. The backup should be scheduled to run at a time of day that minimizes any inconvenience to users. On the server, go to Administrative Tools Task Scheduler. Click Create Basic Task. (Our illustrations are for Windows Server 2008 R2; other operating systems may have some differences. 2

The Create a Basic Task wizard will start. Enter a task name and description. Click Next. Select the backup task frequency. Click Next. 3

Set the time of day for the backup. Click Next. Leave Start a program selected. Click Next. 4

Browse to the script file. Click Next. Check the box to open the Properties dialog. Click Finish. 5

Select the option to run whether the user is logged on or not. Click OK. If prompted, enter the password for the user account that will be running the backup. Backup script log To verify that the backup is running correctly, examine syamserverbackup.log in the backup directory. 6

The log shows the sizes of backup files, giving warnings if a file of size zero has been created. Output of SQL backup commands is included for reference. Review the log periodically to insure that backups are being performed satisfactorily. Cleanup of old backup files If the retention variable is set to a non-zero value, the script performs these cleanup actions: All backup files of size zero will be removed. For backup files older than the number of days specified by the retention variable, old- will be prepended to the file name. For each database, old backups are removed, but only if a more current backup of that database exists. This is to prevent the last good (non-zero-size backup of a database from being removed, in case the backup is failing for any reason. If the retention variable is set to zero, the cleanup routine is skipped. You will need to maintain the directory manually or by some other automated process. 7

Backup script Long lines in the batch script may be displayed in this document on more than one line. Copy the batch script from this document and paste into Notepad to eliminate these line breaks. @ECHO OFF REM syamserverbackup.bat REM Database backup for: REM SyAM System Area Manager REM SyAM Management Utilities REM SyAM Site Manager REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++ REM Enable backup for a program by setting to 1. REM If the program is not installed, set to 0. SET backup_area_manager=1 SET backup_management_utilities=1 SET backup_site_manager=1 REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++ REM Specify backup directory. This must be on a local REM drive, not a network share. The directory will be REM created if it does not already exist. SET budir=c:\syamserverbackup\ REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++ REM Backups older than this number of days will be removed. REM If retention is set to 0, no backups will be removed. REM In any case, backups of a database are not removed if REM there is no current backup file for that database REM with size greater than zero. SET retention=10 REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++ REM Specify your SQL database instance. SET dbinstance=.\sqlexpress REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++ REM Specify installation directory for System Area Manager. SET amdir=c:\syam\ REM Append trailing slashes as required IF DEFINED amdir IF NOT "%amdir:~-1%"=="\" SET amdir=%amdir%\ IF DEFINED budir IF NOT "%budir:~-1%"=="\" SET budir=%budir%\ FOR /f "tokens=2-8 delims=.:/ " %%a in ("%date% %time: =0%" DO SET DateTime=%%c-%%a- %%b_%%d-%%e-%%f IF NOT EXIST %budir% ( mkdir %budir% SET logname="syamserverbackup.log" SET logfile=%budir%%logname% IF EXIST %logfile% ( ECHO. >> %logfile% ECHO Start backup %DateTime% >> %logfile% IF %backup_area_manager% NEQ 1 ( ECHO No backup configured for System Area Manager >> %logfile% GOTO mubackup 8

IF NOT EXIST %amdir%javadb\syamdb.h2.db ( ECHO System Area Manager database not found >> %logfile% GOTO mubackup ECHO Backing up System Area Manager database >> %logfile% net stop smcentralmgr > nul 2>&1 net stop smwebsrv > nul 2>&1 net stop smdbsrv > nul 2>&1 copy %amdir%javadb\syamdb.h2.db %budir%syamdb-%datetime%.h2.db > nul 2>&1 net start smdbsrv > nul 2>&1 net start smwebsrv > nul 2>&1 net start smcentralmgr > nul 2>&1 IF NOT EXIST %budir%syamdb-%datetime%.h2.db ( ECHO System Area Manager backup failed, file does not exist >> %logfile% GOTO mubackup FOR %%A IN (%budir%syamdb-%datetime%.h2.db DO SET amsize=%%~za ECHO Size of System Area Manager backup is %amsize% >> %logfile% IF %amsize% EQU 0 ( ECHO System Area Manager backup failed, file is empty >> %logfile% GOTO mubackup :mubackup IF %backup_management_utilities% NEQ 1 ( ECHO No backup configured for Management Utilities >> %logfile% GOTO smbackup sqlcmd -S %dbinstance% -Q "select name from sys.databases" find "syamutility" > nul IF %ERRORLEVEL% EQU 1 ( ECHO Management Utilities database not found >> %logfile% GOTO smbackup sqlcmd -S %dbinstance% -Q "BACKUP DATABASE syamutility TO DISK='%budir%syamutility- %DateTime%.bak'" >> %logfile% IF NOT EXIST %budir%syamutility-%datetime%.bak ( ECHO Management Utilities backup failed, file does not exist >> %logfile% GOTO smbackup FOR %%A IN (%budir%syamutility-%datetime%.bak DO SET amsize=%%~za ECHO Size of Management Utilities backup is %amsize% >> %logfile% IF %amsize% EQU 0 ( ECHO Management Utilities backup failed, file is empty >> %logfile% GOTO smbackup :smbackup IF %backup_site_manager% NEQ 1 ( ECHO No backup configured for Site Manager >> %logfile% GOTO cleanup sqlcmd -S %dbinstance% -Q "select name from sys.databases" find "syamdb" > nul IF %ERRORLEVEL% EQU 1 ( ECHO Site Manager database not found >> %logfile% GOTO cleanup sqlcmd -S %dbinstance% -Q "BACKUP DATABASE syamdb TO DISK='%budir%syamdb- %DateTime%.bak'" >> %logfile% 9

IF NOT EXIST %budir%syamdb-%datetime%.bak ( ECHO Site Manager backup failed, file does not exist >> %logfile% GOTO cleanup FOR %%A IN (%budir%syamdb-%datetime%.bak DO SET amsize=%%~za ECHO Size of Site Manager backup is %amsize% >> %logfile% IF %amsize% EQU 0 ( ECHO Site Manager backup failed, file is empty >> %logfile% GOTO cleanup :cleanup IF %retention% LEQ 0 ( ECHO Cleanup of old backups is not configured >> %logfile% GOTO end REM delete backups of size zero forfiles /p %budir% /m syamdb*.db /c "cmd /c if @fsize==0 del @file" > nul forfiles /p %budir% /m syamutility*.bak /c "cmd /c if @fsize==0 del @file" > nul forfiles /p %budir% /m syamdb*.bak /c "cmd /c if @fsize==0 del @file" > nul REM rename old backups forfiles /d -%retention% /p %budir% /m syamdb*.db /c "cmd /c rename @file old-@file" > nul forfiles /d -%retention% /p %budir% /m syamutility*.bak /c "cmd /c rename @file old- @file" > nul forfiles /d -%retention% /p %budir% /m syamdb*.bak /c "cmd /c rename @file old-@file" > nul REM delete old backups unless no current backup exists IF EXIST %budir%syamdb*.db ( DEL %budir%old-syamdb*.db > nul IF EXIST %budir%syamutility*.bak ( DEL %budir%old-syamutility*.bak > nul IF EXIST %budir%syamdb*.bak ( DEL %budir%old-syamdb*.bak > nul :end ECHO Backup script completed >> %logfile% EXIT 10