반응형
  1. /**********************************************************************************************
    -- Title : [2k] 백업 디바이스 설정/해제/확인 및 테이프 백업
    -- Reference : dbRang.com
    -- Key word : sp_helpdevice, sp_dropdevice, sp_addumpdevice, sqlperf, backup, restore
    **********************************************************************************************/

    -- 디바이스 확인
    sp_helpdevice;

    -- 디바이스 제거
    sp_dropdevice 'TapeHP'           -- 디바이스만 삭제
    sp_dropdevice 'DiskHP', DELFILE;  -- 디바이스와 파일 삭제  

    -- 디바이스 추가
    exec sp_addumpdevice 'tape', 'TapeHP', '\\.\Tape0';  
    exec sp_addumpdevice 'disk', 'DiskHP', 'f:\wipsci_test';

    -- 복구 모델 확인 및 변경
    select databasepropertyex('wipsci', 'recovery') as "복구 모델"
    alter database wipsci set recovery simple

    -- 로그 확인 및 축소
    dbcc sqlperf(logspace)
    backup log wipsci with no_log

    -- 백업
    backup database ttt to DiskHP with noinit, stats=10
    name = 'ttt_db_backup', description='backup_20050101';
    backup database ttt2 to DiskHP with noinit, stats=10
    name = 'ttt_db_backup', description='backup_20050101';

    backup database ttt to DiskHP with differential;
    backup database ttt2 to DiskHP with differential;

    -- 디바이스 내용 확인
    select name as "logical_name", phyname as "physical_name"
    from master..sysdevices
    where name = 'DiskHP';

    -- 백업 내용 확인
    restore verifyonly from DiskHP;               -- 백업세트 유효성 검사
    restore labelonly from DiskHP;                -- 백업세트 라벨 정보 보기
    restore filelistonly from DiskHP with file=1; -- 백업세트 파일 정보 보기
    restore filelistonly from DiskHP with file=2; -- 백업세트 파일 정보 보기
    restore headeronly from DiskHP;               -- 백업세트 헤더 정보 보기

    restore filelistonly from DiskHP with file=1;
    restore filelistonly from DiskHP with file=2;
    restore filelistonly from DiskHP with file=3;
    restore filelistonly from DiskHP with file=4;

    -- 복원
    restore database ttt from DiskHP with file=1, norecovery, stats=10;
    restore database ttt from DiskHP with file=3, recovery, stats=10;
    restore database ttt2 from DiskHP with file=2, recovery, stats=10;
    restore database ttt2 from DiskHP with file=4, recovery, stats=10;
반응형

+ Recent posts