How to backup a database or save your database to another backup location

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
This is very easy yet this step must be done or you can't do copy and paste.

First make sure all ADMINS log off webpage please! or you will get this error
ALTER DATABASE failed because a lock could not be placed on database 'XYZdatabase'. Try again later.
ALTER DATABASE statement failed. (.Net SqlClient Data Provider)

You may still get this error= so just reboot to release connection try again. Sucess you will get this time.

Then Using Microsoft Management Studio (Free)

Right click on your database(s) and select "Take Database Offline"
Thats it.

Then you can copy and paste to a external harddrive/USB thumb Drive/Obsolete DVD roms
The default databases are located here :
C:/Programfiles/MqlServer/MSSQL(8) or (9) or (10)/MSSQL/DATA/ your databases are here!! copy them dont move them copy them.


Don't forget to bring back online after you have copied everything to a remote location.

Now if disaster strikes you have all of the hard work. The rest is very easy.


Moving it to any computer is easy also but you need to edit the path of the connection string in web.config.
Just make a admin page and drag any tables from nop onto it and you connection string is automatically created.
Also, Important note: As you deploy, make sure that the target Settings.txt and InstalledPlugins.txt files aren't overwritten unless your path to new computer databases changes, so that the production site continues to point to the production database.

Migration to another server is easy. Thus, there should be no excuses why you can't upgrade now. Now you can and you can always roll back if you results are fubar.

Hope this helps.

Mike

see
Il y a 12 ans
Thanks for that good info.

I just wanted to point out that if using windows authentication you can get issues with this method because of a mismatch with the SSIDs on the built in SQL accounts if you need to physically move the database to a new location on a different machine.
Another method for baking up and moving the database to and from different machines/servers/hosting is using  a simple backup and restore. With this method there is not any need to alter any accounts or permissions on either database.

To Backup
1. On the source machine open SQL Server Management Studio Express
2. Right click the database and select "Tasks/Backup"
3. In the window that opens click the "Add" button in the destination section
4.In the new window called "Select Backup Destination" click the browse button (...)
5.Navigate to the drive/folder where you want to backup the database to and give the file a name and append ".bak" to the file

To restore on the other machine
1.On the target machine open SQL Server Management Studio Express
2. Right click the target database and select "Tasks/Restore/Database"
3. In the window that opens select the "From Device" radio buttom and click the browse button (...)
4. In the new window called "Specify Backup" click the "add" button
5. Navigate to the drive/folder where you saved the backup in step 5 above and click "ok"
6. Click "OK" again
7. Tick the "restore" checkbox
8. In the "select a page" field click on "option" and then tick "Overwrite the existing database(WITH REPLACE)" and click "OK". This step is very important if you want to avoid duplicating all your database tables


Notes:
The "NETWORK" account must have read/write access to the backup location. If in doubt save the file in the root of your nop commerce folder which should have the right permissions already set
If uploading to a hosted service, you may not have access to SQL Management Studio however your host should provide a tool or GUI for backing up and restoring your database  and the process for restoring will be similar
The destination must have an existing database. If one doesnt already exist simply create an empty one beforehand.
Il y a 12 ans
yepper, that also works but its the connection string that makes my hair fall out more.

Moving the database there are many ways however the connection string there is only one exact location.

NopC has it in the app_data folder called settings.
DataProvider: sqlserver
DataConnectionString: Data Source= your exact string to you Moved database


So if you have a Dell computer with your databse in C:\ and a Homemade ebay D:\  thats now on fire

you will always need to add this string by hand OR Nop will do it on reinstall.


I've always had problems with connection strings if just one letter was off nothing. Remember your .aspx pages won't update themselves. I'm not for MVC I'm webpages guy with complete control. Each .aspx page needs that database connection location to talk to. Note the pages of aspx. Now I know why MVC is in vogue. Much faster but something else to learn my gawd when will it end.


Thankfully, nop does it for you automatically. I've done it in note pad and I see dinosaurs out my window.

:)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.