简体   繁体   中英

How to backup SQL Server 2019 Express and upload to Azure Blob with 120 days retention

如何备份 SQL Server 2019 Express 并将其上传到 Azure Blob,保留天数?

  1. Download AzCopy 8.1 and SqlPackage
  2. Add a Command with a Script below

    cls forfiles /p "%CD%" /s /m *.* /D -120 /C "cmd /c del @FILE" echo -- BACKUP DATABASE -- set DATABASENAME={Your db name} :: filename format Name-Date (eg MyDatabase-2009.5.19.bak) set DATESTAMP=%DATE:~-4%.%DATE:~7,2%.%DATE:~4,2% set BACKUPFILENAME=%CD%\\\\%DATABASENAME%-%DATESTAMP%.bacpac echo. SqlPackage.exe /a:export /scs:"Server=(local);Database=%DATABASENAME%;Trusted_Connection=True;" /tf:"%BACKUPFILENAME%" AzCopy /Source:%BACKUPFILENAME% /Dest:https://myseogenie.blob.core.windows.net/db-bacup/%BACKUPFILENAME% /DestKey:{YOUR_KEY_HERE}/Y echo -- BACKUP DONE--
  3. You can create a Windows Scheduler to run it daily

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM