Last active
April 30, 2020 11:56
-
-
Save marcelobrake/6ba39e8ccddeae00d93d0d74c7eaf846 to your computer and use it in GitHub Desktop.
Revisions
-
marcelobrake revised this gist
Apr 30, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ ## Para fazer um backup/restore do banco SQL Server do RDS em um bucket S3 será necessário executar os seguintes passos: 1. Criar o bucket no S3 na mesma região onde está o banco (ex: Conta: My_Account, região: sa-east-1, bucket: my-backup-bucket) 2. No RDS, criar ou editar um "Option Group" adicionando a opção SQLSERVER_BACKUP_RESTORE, setando o bucket em questão ### Comando para iniciar o backup (substitua com os valores nas variáveis) ```sql @@ -20,7 +20,7 @@ SELECT 'Return Value' = @return_value GO ``` ### Verificar o progresso do backup/restore (substitua com os valores nas variáveis) ```sql USE [msdb] GO @@ -34,7 +34,7 @@ SELECT 'Return Value' = @return_value GO ``` ### Comando para fazer o restore (substitua com os valores nas variáveis) ```sql exec msdb.dbo.rds_restore_database -
marcelobrake revised this gist
Apr 30, 2020 . 2 changed files with 43 additions and 47 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ ## Para fazer um backup/restore do banco SQL Server do RDS em um bucket S3 será necessário executar os seguintes passos: 1. Criar o bucket no S3 na mesma região onde está o banco (ex: Conta: My_Account, região: sa-east-1, bucket: my-backup-bucket) 2. No RDS, criar ou editar um "Option Group" adicionando a opção SQLSERVER_BACKUP_RESTORE, setando o bucket em questão ### Comando para iniciar o backup (substitua com os valores nas variáveis) ```sql USE [msdb] GO DECLARE @return_value int EXEC @return_value = [dbo].[rds_backup_database] @source_db_name = 'your_database_name', @S3_arn_to_backup_to = 'arn:aws:s3:::your-bucket-name/folder/db.bak', @KMS_master_key_arn = NULL, @overwrite_S3_backup_file = NULL SELECT 'Return Value' = @return_value GO ``` ### Verificar o progresso do backup/restore (substitua com os valores nas variáveis) ```sql USE [msdb] GO DECLARE @return_value int EXEC @return_value = [dbo].[rds_task_status] @db_name = 'your_database_name', @task_id = <<<found in result of previous query>>> SELECT 'Return Value' = @return_value GO ``` ### Comando para fazer o restore (substitua com os valores nas variaveis) ```sql exec msdb.dbo.rds_restore_database @restore_db_name='database_name', @s3_arn_to_restore_from='arn:aws:s3:::bucket_name/folder/file_name_and_extension'; ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,47 +0,0 @@ -
marcelobrake created this gist
Apr 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ -- Para fazer um backup/restore do banco SQL Server do RDS em um bucket S3 será necessário executar os seguintes passos: -- 1. Criar o bucket no S3 na mesma região onde está o banco (ex: Conta: My_Account, região: sa-east-1, bucket: my-backup-bucket) -- 2. No RDS, criar ou editar um "Option Group" adicionando a opção SQLSERVER_BACKUP_RESTORE, setando o bucket em questão -- ******************************************************************************************************************************************* -- Comando para iniciar o backup (substitua com os valores nas variáveis) -- ******************************************************************************************************************************************* USE [msdb] GO DECLARE @return_value int EXEC @return_value = [dbo].[rds_backup_database] @source_db_name = 'your_database_name', @S3_arn_to_backup_to = 'arn:aws:s3:::your-bucket-name/folder/db.bak', @KMS_master_key_arn = NULL, @overwrite_S3_backup_file = NULL SELECT 'Return Value' = @return_value GO -- ******************************************************************************************************************************************* -- Verificar o progresso do backup/restore (substitua com os valores nas variáveis) -- ******************************************************************************************************************************************* USE [msdb] GO DECLARE @return_value int EXEC @return_value = [dbo].[rds_task_status] @db_name = 'your_database_name', @task_id = <<<found in result of previous query>>> SELECT 'Return Value' = @return_value GO -- ******************************************************************************************************************************************* -- Comando para fazer o restore (substitua com os valores nas variaveis) -- ******************************************************************************************************************************************* exec msdb.dbo.rds_restore_database @restore_db_name='database_name', @s3_arn_to_restore_from='arn:aws:s3:::bucket_name/folder/file_name_and_extension';