diff --git a/.github/workflows/create-release-and-upload-asset.yml b/.github/workflows/create-release-and-upload-asset.yml index c53fc06..19a7307 100644 --- a/.github/workflows/create-release-and-upload-asset.yml +++ b/.github/workflows/create-release-and-upload-asset.yml @@ -32,19 +32,13 @@ jobs: working-directory: src run: dotnet build --configuration Release --no-restore - - name: 🚀 Publish BackupSqlDatabase + - name: 🚀 Publish shell: pwsh run: | - dotnet publish .\src\BackupSqlDatabase\BackupSqlDatabase.csproj --configuration Release --output out\BackupSqlDatabase --runtime win-x64 --self-contained true - rm out\BackupSqlDatabase\*.pdb - Compress-Archive -Path "out\BackupSqlDatabase\*.*" -DestinationPath "out\BackupSqlDatabase-win-x64.zip" - - - name: 🚀 Publish RestoreSqlDatabase - shell: pwsh - run: | - dotnet publish .\src\RestoreSqlDatabase\RestoreSqlDatabase.csproj --configuration Release --output out\RestoreSqlDatabase --runtime win-x64 --self-contained true - rm out\RestoreSqlDatabase\*.pdb - Compress-Archive -Path "out\RestoreSqlDatabase\*.*" -DestinationPath "out\RestoreSqlDatabase-win-x64.zip" + dotnet publish .\src\BackupSqlDatabase\BackupSqlDatabase.csproj --configuration Release --output out --runtime win-x64 --self-contained true + dotnet publish .\src\RestoreSqlDatabase\RestoreSqlDatabase.csproj --configuration Release --output out --runtime win-x64 --self-contained true + rm out\*.pdb + Compress-Archive -Path "out\*.*" -DestinationPath "out\DbBackupRestore-win-x64.zip" - name: 📝 Create Release id: create_release @@ -59,22 +53,12 @@ jobs: draft: true prerelease: true - - name: 🚢 Upload BackupSqlDatabase Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: out\BackupSqlDatabase-win-x64.zip - asset_name: BackupSqlDatabase-win-x64.zip - asset_content_type: application/zip - - - name: 🚢 Upload RestoreSqlDatabase Release Asset + - name: 🚢 Upload Release Asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: out\RestoreSqlDatabase-win-x64.zip - asset_name: RestoreSqlDatabase-win-x64.zip + asset_path: out\DbBackupRestore-win-x64.zip + asset_name: DbBackupRestore-win-x64.zip asset_content_type: application/zip diff --git a/README.md b/README.md index 4d408a5..a5914d7 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,17 @@ SQL Server データベースの完全バックアップ、および新しい場 ```ps1 .\BackupSqlDatabase.exe ``` +* 実行されるSQL例 + ```sql + BACKUP DATABASE @databaseName + TO DISK = @backupFilePath WITH NOFORMAT + , NAME = @description + , INIT + , SKIP + , NOREWIND + , NOUNLOAD + , STATS = 10; + ``` ## データベースの新しい場所への復元 @@ -19,6 +30,21 @@ SQL Server データベースの完全バックアップ、および新しい場 ```ps1 .\RestoreSqlDatabase.exe ``` +* 実行されるSQL例 + ```sql + RESTORE FILELISTONLY FROM DISK = @backupFilePath; + + ALTER DATABASE @databaseName SET OFFLINE WITH ROLLBACK IMMEDIATE; + + RESTORE DATABASE @databaseName + FROM DISK = @backupFilePath WITH REPLACE + , NOUNLOAD + , STATS = 5 + , MOVE N'{logicalName1}' TO N'{moveToFilePath1}' + , MOVE N'{logicalName2}' TO N'{moveToFilePath2}'; + + ALTER DATABASE @databaseName SET ONLINE; + ``` ## バックアップ先と復元先フォルダのアクセス権について バックアップ先と復元先フォルダには SQL Server に対してアクセス許可を与える必要があります。 diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0df76e2..a9d6b81 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,7 +3,7 @@ - 0.0.1 + 1.0.0