Why do I copy files to the container? docker cp Documents/sql/QuanLySP.bak azuresqledge:/var/opt/mssql/backup Successfully copied 2.87MB to azuresqledge:/var/opt/mssql/backup was successful. But when I go into

a47777 Nguyễn Bá Hoàng 0 Reputation points
2024-05-18T09:10:39.41+00:00

Why do I copy files to the container?

docker cp Documents/sql/QuanLySP.bak azuresqledge:/var/opt/mssql/backup

                                          Successfully copied 2.87MB to azuresqledge:/var/opt/mssql/backup

was successful. But when I go into the container and check ls var/opt/mssql/backup, it shows var/opt/mssql/backup, meaning I don't see that file.

When I manage to localhost cx there is no restore button but only refresh

Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 4,546 Reputation points
    2024-05-18T18:22:20.79+00:00

    Hi a47777 Nguyễn Bá Hoàng,

    Thank you for you posting your question here.

    Based on your question:

    Why do I copy files to the container, it shows successful, but you did not see the copied file.

    Firstly, you need to be sure the file is copied. To check if the file is indeed copied, you can do the following:

    • Start a shell inside the container:

    docker exec -it azuresqledge /bin/bash

    • Navigate to the directory and list files:

    cd /var/opt/mssql/backup

    ls -l

    • Ensure that the directory /var/opt/mssql/backup has the correct permissions for writing the file. If there are permission issues, you might not be able to see the file even though the docker cp command reported success.

    Your second question:

    When I manage to localhost cx there is no restore button but only refresh.

    I do not understand what you meant by cx?

    I hope this is helpful! Ensure you can find the file in the container and provide us the second question.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,


  2. Alberto Morillo 33,086 Reputation points MVP
    2024-05-18T19:50:55.1833333+00:00

    Please ensure you add a slash after the backup folder when you run the docker cp command.

    docker cp Documents/sql/QuanLySP.bak azuresqledge:/var/opt/mssql/backup/

    That way you will find the .bak file copied correctly.

    You cannot restore the database using SSMS GUI (graphical user interface). You need to use Transact SQL to restore the database. Below is a T-SQL statement I use to restore backups on containers

    RESTORE DATABASE [QuanLySP] FROM  DISK = N'/var/opt/mssql/backup/QuanLySP.bak'
    WITH  FILE = 1,  
    MOVE N'LUN1\PRIMARY_DF' TO N'/var/opt/mssql/data/QuanLySP.mdf',  
    MOVE N'LUN1\LOG-LF1' TO N'/var/opt/mssql/data/QuanLySP_log.ldf',  
    NOUNLOAD,  REPLACE,  STATS = 5
    
    0 comments No comments