Backing and Restoring Oracle and PostgreSQL in Docker Containers

Secure Backup & Restoration

In today’s world, we use special software packages called Docker containers to run our applications more easily and move them around if needed. However, these containers don’t automatically save a backup of our data, which is a problem if something goes wrong, like a computer crash or a cyber attack. This means it’s really important to regularly save copies of our databases that live inside these containers to keep our data safe and our businesses running smoothly.

This article will show you simple ways to save and get back your Oracle and PostgreSQL database information if you’re using Docker containers. We’ll look at different options so you can find what works best for you and make sure your data is always secure.

Backing Up Dockerized Databases

Why Save Your Data?

    • Avoid Data Loss: Computers can fail, files can be deleted by mistake, or hackers might attack. Having backups means you can get your database back to how it was.
    • Improved Disaster Recovery:Disasters can strike in various forms, from hardware failures to natural disasters. Backups ensure a quicker recovery time objective (RTO) and minimize downtime.
    • Better Development and Testing: Backups enable you to create development and testing environments with consistent data, streamlining your workflow.
    • Follow the Rules: Some industries need you to keep data for a certain time. Backups help you follow these rules and avoid fines.
    • Version Control: Backups allow you to roll back to a previous version of your database in case of accidental schema changes or data corruption.
    • Easier Growth and Moving: Backups make it easier to move your database to a new place or make it bigger in the future.

Backup Strategies for Dockerized Databases


    • Prepare the Container: Ensure your Oracle database container is running and accessible. You might use Docker commands such as ‘docker ps’ to check the container’s status.
    • Use Data Pump for Backup: Oracle Data Pump is a utility for exporting and importing database content. Run the ‘expdp’ command inside your container to export your database schema or full database into a dump file.

docker exec <oracle_container_name> expdp <username>/<password>@<dbname> DIRECTORY=dump_dir DUMPFILE=backup.dmp LOGFILE=backup.log

    • Copy Backup from Container: Use ‘docker cp’ to copy the dump file from your container to the host machine for safekeeping.

docker cp <oracle_container_name>:/path/to/dump_dir/backup.dmp /host/path/backup.dmp


    • Prepare the Container: Make sure your PostgreSQL container is running. Use ‘docker ps’ to verify.
    • Use pg_dump for Backup: ‘pg_dump’ is the PostgreSQL utility for database backup. Execute pg_dump inside your container to create a backup.

docker exec -t <postgres_container_name> pg_dump -U <username> -F c <dbname> > /host/path/backup.dump

    • Ensure Backup Integrity: Always verify the backup file’s integrity to ensure a successful restore process when needed.

Restoring with Container Backup


    • Prepare for Restore: Make sure the container is running and the dump file is accessible from the container’s filesystem.
    • Use Data Pump for Restore: Use the ‘impdp’ command to import the dump file back into your database.

docker exec <oracle_container_name> impdp <username>/<password>@<dbname> DIRECTORY=dump_dir DUMPFILE=backup.dmp LOGFILE=restore.log


    • Prepare for Restore: Ensure the container is running and the backup file is accessible.
    • Use pg_restore for Restore: Utilize ‘pg_restore’ to load the backup into your PostgreSQL database.

docker exec -i <postgres_container_name> pg_restore -U <username> -d <dbn

Best Practices for Disaster Recovery

Here are some additional tips to ensure a robust disaster recovery plan for your Dockerized databases:

    • Schedule Regular Backups: Automate your backups based on your data update frequency and recovery needs.
    • Test Your Restores: Regularly test your restore procedures to ensure they function as expected.
    • Secure Your Backups: Store your backups in a secure, off-site location to protect them from local disasters.
    • Disaster Recovery Plan: Document your disaster recovery procedures for a quick and efficient response during an actual incident.

By following these strategies and best practices, you can ensure your Oracle and PostgreSQL databases in Docker containers are always protected and recoverable in case of any unforeseen events. Remember, a well-defined disaster recovery plan is key to minimizing downtime and maintaining business continuity.

Are you prepared to safeguard your Oracle and PostgreSQL databases within Docker containers? Our guide offers easy-to-implement strategies for backup and restoration, ensuring your data remains protected.

Remember, Newt Global DMAP is a world-class product enabling mass migration of Oracle Db to cloud-native PostgreSQL faster, better, and cheaper.

For expert guidance and seamless integration assistance, visit our website at or reach out to us via email at

Embrace the power of Docker with Newt Global DMAP, and fortify your database’s resilience against unforeseen events.