import os
import shutil
import datetime
import cx_Oracle
# 数据库连接信息
db_user = "username"
db_password = "password"
db_host = "hostname"
db_port = "port"
db_sid = "sid"
# 备份文件夹路径
backup_folder = "your_backup_folder_path"
# 获取当前时间
now = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
# 连接数据库
dsn = cx_Oracle.makedsn(db_host, db_port, db_sid)
connection = cx_Oracle.connect(db_user, db_password, dsn)
# 创建恢复文件名
restore_file = f"{backup_folder}/backup_{now}.dmp"
# 执行恢复命令
imp_command = f"imp {db_user}/{db_password}@{dsn} file={restore_file}"
os.system(imp_command)
# 关闭数据库连接
connection.close()
pytho实现oracle数据库恢复
最新推荐文章于 2024-08-31 21:07:39 发布