Backup oracle remote database under windows

1. First, you need to install the corresponding oracle database version in the window system, and then find the tnsnames.ora file under the local oracle,

Usually in the ~\oracle\product\10.2.0\db_1\network\ADMIN directory.

 

2. Open the tnsnames.ora file (you can open it in text mode) and add the following content:

1
2
3
4
5
6
7
8
orcl =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 远程数据库IP地址)(PORT = 数据库端口号))
     (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = 数据库服务名)
     )
   )

"orcl" can be customized, and then you also need to know the remote database IP address, database port number, and database service name.

 

3. Fill in the user name, password and the 'orcl' database defined above into the script below, for example

exp scott/orcl@orcl file=C:\db_bak\files\backup_%var%.dmp log=C:\db_bak\logs\backup_%var%.log 

 

 

4. Run the following script, backup documents and logs will be generated in C:\db_bak\files md C:\db_bak\files in the root directory of C drive

 

@echo off

rem Author:lafecat

rem Time:2016-11-17

 

echo start backup database

if not exist C:\db_bak\files md C:\db_bak\files

if not exist C:\db_bak\logs md C:\db_bak\logs

if not exist D:\db_bak\files md D:\db_bak\files

if not exist D:\db_bak\logs md D:\db_bak\logs

 

echo set time variable

set var=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%

 

echo export backup files and log files

exp scott/orcl@orcl file=C:\db_bak\files\backup_%var%.dmp log=C:\db_bak\logs\backup_%var%.log 

 

echo starts moving files

xcopy C:\db_bak\files\backup_%var%.dmp D:\db_bak\files\

xcopy C:\db_bak\logs\backup_%var%.log D:\db_bak\logs\ 

 

echo delete old backup records

forfiles /p "C:\db_bak" /s /m *.dmp /d -60 /c "cmd/c del @path"

forfiles /p "C:\db_bak" /s /m *.log /d -60 /c "cmd/c del @path"

 

echo backup completed at: %DATE% %time%!

 

pause

exit

pause

 

Finally, I wish you all the best.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326493484&siteId=291194637