ADVERTISEMENT

SCP File Transfer

As a DBA, you often need to move .dmp, .log, .ctl, .bkp, and .par files between servers during activities like database refresh, cloning, patching, or troubleshooting.
Use scp (secure copy) to perform fast and secure file transfers between servers.

1. Upload File ➜ Target Server

Run from: Source server (where the file currently exists)
Use case: Send export dump, patch, or log file to target environment

# Upload a file from source ➜ target
scp /u01/exports/prod.dmp oracle@target_server:/u01/refresh/

# If you're in the current directory of the file
scp ./prod.dmp oracle@target_server:/u01/refresh/

🔑 Prompts for: oracle@target_server password

2. Download File ⬅ From Source Server

Run from: Target server (where you want the file copied)
Use case: Pull backup or export dump from source/production server

# Download a file from source ➜ target
scp oracle@source_server:/u01/exports/prod.dmp /u01/restore/

# If saving to current directory
scp oracle@source_server:/u01/exports/prod.dmp .

🔑 Prompts for: oracle@source_server password

3. Copy File: Source ➜ Target (Run from Jumpbox/3rd Host)

Run from: A third server (e.g., jumpbox or any server with SSH access to both source and target)
Use case: Move files between two remote servers

# Copy file between remote servers
scp oracle@source_server:/u01/backups/full.bkp oracle@target_server:/u01/restore/

🔑 Prompts for: both oracle@source_server and oracle@target_server passwords
💡 Tip: Use SSH key-based auth to skip repeated prompts

4. Upload Entire Directory ➜ Target

Run from: Source server
Use case: Move full RMAN backup or log directory to another server

# Upload full directory
scp -r /u01/rman_backups oracle@target_server:/u01/restore/

# If inside /u01 directory
scp -r ./rman_backups oracle@target_server:/u01/restore/

5. Use Custom SSH Port

Run from: Source server
Use case: When target server uses a non-default SSH port (other than 22)

scp -P 2222 prod.dmp oracle@target_server:/u01/refresh/

📌 Important Notes for Oracle DBAs:

  • SSH access must be allowed between source and target
  • Use oracle or relevant OS user with permission on both ends
  • Always use absolute paths to avoid confusion and errors
  • Use pwd and ls -l before/after transfer to verify locations
  • Use . to represent current directory when you’re already inside it

Avoid Password Prompts with SSH Keys (Highly Recommended):

# Generate SSH key (if not already done)
ssh-keygen -t rsa

# Copy your public key to target server
ssh-copy-id oracle@target_server

✅ Once set up, scp will work password-less between trusted hosts

ADVERTISEMENT