Скрипт типовой задачи – скопировать боевую базу в тестовую
--- сreate copy database ZKGU to ZKGUDEMO
-- create backup database ZKGU
USE zkgu;
GO
BACKUP DATABASE zkgu
TO DISK = 'D:\bak\zkgu.bak'
WITH FORMAT,
MEDIANAME = 'Z_SQLServerBackups',
NAME = 'Full Backup of ZKGU';
GO
-- restore database ZKGU to database ZKGUDEMO
USE master;
GO
-- First determine the number and names of the files in the backup.
-- ZKGU_Backup is the name of the backup device.
RESTORE FILELISTONLY
FROM ZKGU_Backup;
-- Restore the files for ZKGUDEMO.
RESTORE DATABASE zkgudemo
FROM ZKGU_Backup
WITH RECOVERY,
MOVE 'ZKGU_Data' TO 'D:\MSSQL_Data\zkgudemo_Data.mdf',
MOVE 'ZKGU_Log' TO 'F:\MSSQL_Logs\zkgudemo_Log.ldf';
GO
-- End of program
Пример резервного копирования базы PostgreSQL с одного хоста на другой
Скрипт для резервного копирование БД из Windows:
@echo off
chcp 65001
echo *** buh04 PostgreSQL database clone ***
set source=
set target=
set /p source="Source database: "
set /p target="Target database [%source%]: "
if [%target%] == [] set target=%source%
set /p confirm="Clone database %source% to %target% ? (y/n) "
if [%confirm%] == [y] "C:\Program Files\PuTTY\plink" -i C:\scripts\keys\1cdb_key.ppk clone@10.5.23.1 sudo -u user /buh/scripts/bin/clone.sh %source% %target%
set /p source="Press ENTER to exit! "