Getting there

This commit is contained in:
2025-11-25 10:51:26 -05:00
parent 60fa02c181
commit 5867e7029f
7 changed files with 108 additions and 21 deletions

29
mount_oracle_filesonly.py Normal file → Executable file
View File

@@ -5,6 +5,7 @@ import sys
import os
import argparse
import time
import socket
from datetime import datetime
from rsc import RSCAuth, RSCGraphQL
@@ -58,7 +59,6 @@ def find_database_by_name_or_id(identifier):
variables = {
"filter": [
{"texts": [identifier], "field": "NAME_EXACT_MATCH"},
{"texts": ["false"], "field": "IS_RELIC"},
{"texts": ["false"], "field": "IS_REPLICATED"}
]
}
@@ -160,7 +160,7 @@ def get_latest_pit(db_id):
print(f"INFO: Latest PIT (ISO8601): {latest_endtime}")
# Convert to datetime and then to milliseconds since epoch
dt = datetime.fromisoformat(latest_endtime.replace('Z', '+00:00'))
dt = datetime.strptime(latest_endtime.replace('Z', '+0000'), '%Y-%m-%dT%H:%M:%S.%f%z')
unixtime_ms = int(dt.timestamp() * 1000)
print(f"INFO: Latest PIT unixtime (ms): {unixtime_ms}")
@@ -304,26 +304,39 @@ def main():
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python mount_oracle_filesonly.py --mountpath /tmp/mount
python mount_oracle_filesonly.py --mountpath /tmp/mount SHED
python mount_oracle_filesonly.py --targethost target-host --mountpath /tmp/mount SHED
python mount_oracle_filesonly.py --targethost target-host --mountpath /tmp/mount --timestamp "2025-11-25 12:00:00" SHED
"""
)
parser.add_argument("--targethost", required=True,
help="Target host where the files will be mounted")
parser.add_argument("--targethost", required=False,
help="Target host where the files will be mounted (defaults to local hostname)")
parser.add_argument("--mountpath", required=True,
help="Target mount path for the files")
parser.add_argument("--timestamp",
help="Optional timestamp for the recovery point in format 'YYYY-MM-DD HH:MM:SS'")
parser.add_argument("srcdb",
help="Source database name or RSC database ID")
parser.add_argument("srcdb", nargs='?',
help="Source database name or RSC database ID (optional, defaults to local database)")
args = parser.parse_args()
if not args.targethost:
args.targethost = socket.gethostname()
print(f"INFO: No target host specified, defaulting to local hostname: {args.targethost}")
try:
# Find the source database
print(f"INFO: Finding source database: {args.srcdb}")
db = find_database_by_name_or_id(args.srcdb)
if args.srcdb:
print(f"INFO: Finding source database: {args.srcdb}")
db = find_database_by_name_or_id(args.srcdb)
else:
print("INFO: No source database specified, finding local database")
auth = RSCAuth()
gql = RSCGraphQL(auth)
db_id = gql.get_local_database_id()
db = find_database_by_name_or_id(db_id)
print(f"INFO: Found database: {db['dbUniqueName']} (ID: {db['id']})")
print(f"INFO: Cluster: {db['cluster']['name']} (ID: {db['cluster']['id']})")