Sunday, October 27, 2024

Move SQL Server DB to another Server using backup and restore

Refer to here: https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-migrate-restore-database?view=sql-server-ver15 [unica@sbidemo backup_20241028]$ sqlcmd -S localhost -U sa Password: 1> SELECT Name FROM sys.Databases 2> go Name -------------------------------------------------------------------------------------------------------------------------------- master tempdb model msdb dcc acc_demo (6 rows affected) 1> BACKUP DATABASE dcc TO DISK = N'/apps/data/backup_20241028/dcc.bak' WITH NOFORMAT, NOINIT, NAME = N'dcc',SKIP, NOREWIND, NOUNLOAD, STATS = 10; 2> GO Msg 3201, Level 16, State 1, Server unicademo, Line 1 Cannot open backup device '/apps/data/backup_20241028/dcc.bak'. Operating system error 5(Access is denied.). Msg 3013, Level 16, State 1, Server unicademo, Line 1 BACKUP DATABASE is terminating abnormally. 1> BACKUP DATABASE dcc TO DISK = N'/apps/data/backup_20241028/dcc.bak' WITH NOFORMAT, NOINIT, NAME = N'dcc',SKIP, NOREWIND, NOUNLOAD, STATS = 10; 2> GO 10 percent processed. 20 percent processed. 30 percent processed. 40 percent processed. 50 percent processed. 60 percent processed. 70 percent processed. 80 percent processed. 90 percent processed. 100 percent processed. Processed 251840 pages for database 'dcc', file 'demoCombined_Data' on file 1. Processed 1 pages for database 'dcc', file 'demoCombined_Log' on file 1. BACKUP DATABASE successfully processed 251841 pages in 82.777 seconds (23.768 MB/sec).

1> BACKUP DATABASE dcc TO DISK = N'/apps/data/backup_20241028/acc_demo.bak' WITH NOFORMAT, NOINIT, NAME = N'acc_demo',SKIP, NOREWIND, NOUNLOAD, STATS = 10; 2> GO 10 percent processed. 20 percent processed. 30 percent processed. 40 percent processed. 50 percent processed. 60 percent processed. 70 percent processed. 80 percent processed. 90 percent processed. 100 percent processed. Processed 251840 pages for database 'dcc', file 'demoCombined_Data' on file 1. Processed 1 pages for database 'dcc', file 'demoCombined_Log' on file 1. BACKUP DATABASE successfully processed 251841 pages in 133.949 seconds (14.688 MB/sec). 1> [unica@sbidemo data]$ sqlcmd -S localhost -U sa -C Password: 1> RESTORE DATABASE dcc FROM DISK = '/apps/data/backup_20241028/dcc.bak' 2> GO Processed 251840 pages for database 'dcc', file 'demoCombined_Data' on file 1. Processed 1 pages for database 'dcc', file 'demoCombined_Log' on file 1. Converting database 'dcc' from version 904 to the current version 957. Database 'dcc' running the upgrade step from version 904 to version 905. Database 'dcc' running the upgrade step from version 905 to version 906. Database 'dcc' running the upgrade step from version 906 to version 907. Database 'dcc' running the upgrade step from version 907 to version 908. Database 'dcc' running the upgrade step from version 908 to version 909. Database 'dcc' running the upgrade step from version 909 to version 910. Database 'dcc' running the upgrade step from version 910 to version 911. Database 'dcc' running the upgrade step from version 911 to version 912. Database 'dcc' running the upgrade step from version 912 to version 913. Database 'dcc' running the upgrade step from version 913 to version 914. Database 'dcc' running the upgrade step from version 914 to version 915. Database 'dcc' running the upgrade step from version 915 to version 916. Database 'dcc' running the upgrade step from version 916 to version 917. Database 'dcc' running the upgrade step from version 917 to version 918. Database 'dcc' running the upgrade step from version 918 to version 919. Database 'dcc' running the upgrade step from version 919 to version 920. Database 'dcc' running the upgrade step from version 920 to version 921. Database 'dcc' running the upgrade step from version 921 to version 922. Database 'dcc' running the upgrade step from version 922 to version 923. Database 'dcc' running the upgrade step from version 923 to version 924. Database 'dcc' running the upgrade step from version 924 to version 925. Database 'dcc' running the upgrade step from version 925 to version 926. Database 'dcc' running the upgrade step from version 926 to version 927. Database 'dcc' running the upgrade step from version 927 to version 928. Database 'dcc' running the upgrade step from version 928 to version 929. Database 'dcc' running the upgrade step from version 929 to version 930. Database 'dcc' running the upgrade step from version 930 to version 931. Database 'dcc' running the upgrade step from version 931 to version 932. Database 'dcc' running the upgrade step from version 932 to version 933. Database 'dcc' running the upgrade step from version 933 to version 934. Database 'dcc' running the upgrade step from version 934 to version 935. Database 'dcc' running the upgrade step from version 935 to version 936. Database 'dcc' running the upgrade step from version 936 to version 937. Database 'dcc' running the upgrade step from version 937 to version 938. Database 'dcc' running the upgrade step from version 938 to version 939. Database 'dcc' running the upgrade step from version 939 to version 940. Database 'dcc' running the upgrade step from version 940 to version 941. Database 'dcc' running the upgrade step from version 941 to version 942. Database 'dcc' running the upgrade step from version 942 to version 943. Database 'dcc' running the upgrade step from version 943 to version 944. Database 'dcc' running the upgrade step from version 944 to version 945. Database 'dcc' running the upgrade step from version 945 to version 946. Database 'dcc' running the upgrade step from version 946 to version 947. Database 'dcc' running the upgrade step from version 947 to version 948. Database 'dcc' running the upgrade step from version 948 to version 949. Database 'dcc' running the upgrade step from version 949 to version 950. Database 'dcc' running the upgrade step from version 950 to version 951. Database 'dcc' running the upgrade step from version 951 to version 952. Database 'dcc' running the upgrade step from version 952 to version 953. Database 'dcc' running the upgrade step from version 953 to version 954. Database 'dcc' running the upgrade step from version 954 to version 955. Database 'dcc' running the upgrade step from version 955 to version 956. Database 'dcc' running the upgrade step from version 956 to version 957. RESTORE DATABASE successfully processed 251841 pages in 22.186 seconds (88.682 MB/sec). 1>

No comments:

Post a Comment