0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OracleAPEXのローカルへの自動バックアップを構成する

Posted at

初めに

OracleAPEXでは自動バックアップ機能がありますが、何かしらのエラーで復元出来ないことがあります。そのため別個でファイルを保存する方法を探した所、ローカル環境にアプリケーションファイルを保存できる方法を見つけたのでご紹介させて頂きます。

準備

まずクラウドウォレットファイルをAutonomous Databaseからダウンロードしておきます。
image.png

次にsqlclを使用するためファイルのダウンロードします。

ダウンロード完了後はCフォルダ直下に置き、システム環境変数のPathに以下のbinフォルダを通しておきます。
image.png

以下バッチファイルを作成して、必要パラメータを入力して実行します。

@echo off

chcp 65001

set sqlcl_path=sqlcl\binのファイルパス
set config_path=クラウドウォレットファイルパス
set database_name=データベース名
set pass=パスワード
set connect=admin/%pass%@%database_name%_high
set sql_path=@export.sql

set date_path=%date:~0,4%%date:~5,2%%date:~8,2%
set time_tmp=%time: =0%
set time_tmp=%time_tmp::=%
set folder_path=%time_tmp:~0,4%

cd %sqlcl_path%

sql.exe -S -cloudconfig %config_path% %connect% %sql_path%

for /f %%a in ('dir /a-a /b ^| findstr -i f') do (

     mkdir %date_path%\%folder_path%

     Powershell Compress-Archive -Path %%a -DestinationPath %date_path%\%folder_path%\%%a.zip -Force

     rmdir /s /q %%a

 )

)

image.png

image.png

無事ローカル環境に保存出来ました。

分割してファイルを保存しているので、ページ単位で復元が可能となります。
タスクスケジューラを使用すれば日次バックアップも可能となります。

これで以上となります。
見て下さりありがとうございました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?