Click here to Skip to main content
16,016,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,


i need to take backup and restore from one server database to another server database remotely
1) first i take backup from original server database to another server database
2) again i have to restore anohter server database to original server database



i am doing by task scheduler for in C drive

but i dont want to do the backup in the c drive.

i want to kw how to take backup into another server database
Posted

1 solution

Task scheduler doesn't define where the backup is taken, the script you run does.

From what I gather from your question,
- use sqlcmd[^] utility to run the SQL scripts
- create one sqlcmd run for the backup and define the backup to be taken where you like
- if necessary add a step in your script where you copy the backup from a location to another
- create one sqlcmd run for the backup and define the restore of the backup to another database
- schedule this script using task scheduler

For defitions for the backup and restore commands to run, please refer to BACKUP[^] and RESTORE[^]

For sqlcmd see sqlcmd Utility[^]
 
Share this answer
 
v2
Comments
sadhana4 10-Jul-15 8:13am    
sqlcmd -S .\sa -E -Q
"BACKUP DATABASE MASTER TO TESTBACKUP"
--- < End Code Batch Script > -----

..where "MYSERVER" is the name of the SQL Server physical machine.
..where "OFFICESERVERS" is the name of the SQL Server.
..where "TESTBACKUP" is the name of the backup job.
..where "MASTER" is the name of the database.

i kw i did the script for backup and run from sqlcmd using task schedule
but how to define the path another database connection

how to defined another server database connection in the script
Wendelius 10-Jul-15 8:18am    
If I understand you correctly, you don't define the connection to another server in the restore script. You use the parameters of the sqlcmd. Something like

sqlcmd -S tcp:another_computer_name\instancename, 1433 -U another_user_name -P password_for_the_user -Q ...
sadhana4 15-Jul-15 4:05am    
if i need backup all database like 45 database to another database daily at 10 pm
and again i have to restore all this database from another server to main server database.i kw i did the backup by using sqlcmd and taskschduler daily at 10 but again i have to restore all database to main server database
how to do restore by using sqlcmd to main server or another server
Wendelius 15-Jul-15 4:12am    
I'm sorry but I don't quite understand the question. If you want to restore a database from a file, you can define the file location in the RESTORE command. Just make sure that the SQL Server service has access to the location of the file.
sadhana4 15-Jul-15 4:48am    
example A is Main server having 6 database and B is another server which don't any have database.by using sqlcmd how can i backup to B server database at 10pm daily and again
in the morning restore B server database to A server database.
i kw how to backup to local drive for example (C:/,D:/).but i am not getting
how to connect both server A to B for backup and restore daily
Please help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900