0

I have a SQL Server database running on a Amazon Linux machine and I want to create a backup of it. I am using the following query:

BACKUP DATABASE Database TO DISK = 'backup.bak';

This, in fact, creates a backup of my database in the D:\rdsdbdata\BACKUP folder. The only problem is that this folder does not exist on my machine. Trying to specify the path results in SQL attempting to save the backup in D:\rdsdbdata\BACKUP plus my folder, like this:

 BACKUP DATABASE Database TO DISK = '/home/work/backup.bak';

I get the following error:

Msg 3201, Level 16, State 1, Server EC2AMAZ, Line 1
Cannot open backup device 'D:\rdsdbdata\BACKUP\home\work\backup.bak'. Operating system error
The system cannot find the path specified.).

Msg 3013, Level 16, State 1, Server EC2AMAZ, Line 1
BACKUP DATABASE is terminating abnormally.

Using another query, I can confirm that the .bak file actually exists in D:\rdsdbdata\BACKUP as it also increases the storage on the server. I need to retrieve the .bak file to my machine.

Is there any method to access the SQL Server disk to retrieve this file or a correct way to specify the path?

4
  • What's the output of SELECT @@VERSION on your instance? Given what you've described so far it looks like an EC2 Windows based machine. Commented Oct 16, 2023 at 21:49
  • 1
    In RDS you would normally use AWS's custom msdb.dbo.rds_backup_database to perform backups directly to an S3 bucket. See: Importing and exporting SQL Server databases using native backup and restore which also includes IAM policy examples. Commented Oct 16, 2023 at 21:55
  • This is the output: Microsoft SQL Server 2019 (RTM-CU20) (KB5024276) - 15.0.4312.2 (X64) Apr 1 2023 12:10:46 Copyright (C) 2019 Microsoft Corporation Express Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor) Commented Oct 16, 2023 at 21:58
  • So Windows Server 2016 Datacenter 10.0 != Amazon Linux. Have a read through the article I linked above and try using msdb.dbo.rds_backup_database instead. Commented Oct 16, 2023 at 22:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.