db_yedekle.bat:
sqlcmd -S DESKTOP-DTMVGHR -U sa -P LOGO123 -i "C:\TESTBACKUP\db_yedekle.sql"
ECHO OFF
ECHO "Yedekleme Bitti..."
PAUSE
db_yedekle.sql:
DECLARE @DosyaAdi VARCHAR(50)
DECLARE @Patika VARCHAR(256)
DECLARE @DosyaAdiYeni VARCHAR(256)
DECLARE @DosyaAdiEk VARCHAR(20)
SET @Patika = 'C:\TESTBACKUP\YEDEK\'
SELECT @DosyaAdiEk = CONVERT(VARCHAR(20), GETDATE(), 120);
SET @DosyaAdiEk = REPLACE(@DosyaAdiEk, ' ','-')
SET @DosyaAdiEk = REPLACE(@DosyaAdiEk, ':','')
DECLARE dbCursor CURSOR READ_ONLY FOR
SELECT name FROM master.sys.databases WHERE name NOT IN ('master', 'model', 'msdb', 'tempdb','ReportServer','ReportServerTempDB') AND state = 0 AND is_in_standby = 0
OPEN dbCursor
FETCH NEXT FROM dbCursor
INTO @DosyaAdi
WHILE @@FETCH_STATUS = 0
BEGIN
SET @DosyaAdiYeni = @Patika + @DosyaAdi + '_' + @DosyaAdiEk + '.bak'
BACKUP DATABASE @DosyaAdi TO DISK = @DosyaAdiYeni;
FETCH NEXT FROM dbCursor
INTO @DosyaAdi
END
CLOSE dbCursor
DEALLOCATE dbCursor
KlasoruTemizle.bat:
set folder="C:\TESTBACKUP\YEDEK"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
TarihselYedek.bat:
XCOPY "C:\TESTBACKUP\YEDEK\*.*" "C:\TESTBACKUP\TARIHSELYEDEK\%DATE%\" /E/Y/W
Watch video BAT (Batch) Dosyası ile SQL Server'daki Veri Tabanlarını Otomatik Olarak Yedeklemek! online without registration, duration hours minute second in high quality. This video was added by user KolayERP 20 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 701 once and liked it 3 people.