How to Automate Backups on Oracle Cloud Free Tier VPS

Key Takeaways
- ✓Install OCI CLI and configure API signing keys for automated snapshots
- ✓Write a daily Bash script for Gzip MySQL dumps and web file archiving
- ✓
Get started now or speak directly with our engineering team for specialized assistance.

Operating a production web application, MySQL database, or WordPress site on Oracle Cloud Infrastructure (OCI) Free Tier offers incredible compute value, but it also carries an inherent operational risk that many developers discover too late: Oracle Cloud Free Tier Always Free instances do not include automated built-in backup schedules by default.
If your compute instance suffers file system corruption, an inadvertent kernel misconfiguration, or an automated tenancy idle reclamation, unbacked-up data can be lost permanently. While paid enterprise tenancies allow automated backup policies via the OCI Console, Free Tier block volumes require custom automation. In this comprehensive step-by-step guide, we will cover how to write automated OCI CLI snapshot scripts, schedule local cron jobs, configure database dumps, and sync encrypted backups to off-site cloud storage (S3 / Backblaze) using rclone.
If you have already optimized your server performance by following our guides on Opening Ports 80 & 443 on Oracle VPS and Fixing Oracle Cloud Out of Memory Crashes, establishing an automated backup pipeline is the mandatory next step to guarantee server uptime and data protection.
Prefer enterprise-grade automated daily backups without writing custom scripts? Explore RackUp IT's Managed Cloud & Web Hosting Services, featuring automated daily disaster recovery snapshots and one-click instant site restoration.
Why is automated backup scheduling so crucial for Oracle Cloud VM instances compared to traditional web hosting providers?
Connect to your Oracle Cloud instance via SSH and install the official Oracle Cloud Infrastructure CLI tool:
# Download and execute the official OCI CLI installer script
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
# Accept default installation paths and reload shell profile
exec -l $SHELL
# Verify OCI CLI installation version
oci --version
Generate your API signing key pair and configure authentication credentials:
# Initialize interactive OCI CLI configuration
oci setup config
Provide your User OCID, Tenancy OCID, and Region (found in the OCI Console under User Settings & Tenancy Details). The CLI will generate a public key (~/.oci/oci_api_key_public.pem). Copy this public key, log into the OCI Console, navigate to User Settings > API Keys, and click Add API Key. Test your API connection by running oci os ns get.
Create a dedicated script directory and construct a unified backup bash script that exports database dumps and compresses web application document roots:
# Create backup directory with restricted permissions
sudo mkdir -p /opt/backups
sudo chmod 700 /opt/backups
# Create backup script
sudo nano /opt/backups/daily_backup.sh
Paste the following automated backup script into the file:
#!/bin/bash
# Configuration Variables
TIMESTAMP=$(date +"%Y-%m-%d_%H%M%S")
BACKUP_DIR="/opt/backups/archive"
MYSQL_USER="root"
MYSQL_PASSWORD="YOUR_SECURE_MYSQL_PASSWORD"
WEB_ROOT="/var/www"
RETENTION_DAYS=7
# Create archive subfolder
mkdir -p ${BACKUP_DIR}
# Step 1: Dump all MySQL databases into a compressed Gzip file
mysqldump --all-databases --single-transaction --quick --lock-tables=false -u ${MYSQL_USER} -p"${MYSQL_PASSWORD}" | gzip > ${BACKUP_DIR}/db_backup_${TIMESTAMP}.sql.gz
# Step 2: Compress web application document roots and SSL configs
tar -czf ${BACKUP_DIR}/web_files_${TIMESTAMP}.tar.gz ${WEB_ROOT} /etc/nginx/sites-available
# Step 3: Remove local backups older than retention threshold
find ${BACKUP_DIR} -type f -mtime +${RETENTION_DAYS} -delete
echo "Local backup completed successfully at ${TIMESTAMP}"
Grant execution permissions to your script: sudo chmod +x /opt/backups/daily_backup.sh.
Storing backups solely on your server's local NVMe drive leaves you vulnerable to host hardware failures. We will use rclone to automatically sync compressed archives to remote cloud storage (Amazon S3, Backblaze B2, or Google Cloud Storage):
# Install rclone on Ubuntu/Debian
sudo apt update && sudo apt install -y rclone
# Configure remote cloud storage endpoint interactively
rclone config
Follow the interactive prompt to connect your S3 bucket or Backblaze B2 repository. Append the rclone sync command to your daily backup script:
# Append rclone sync command to daily_backup.sh
rclone sync /opt/backups/archive remote_s3_bucket:oracle-vps-backups/ --min-age 0 --log-file=/var/log/rclone_backup.log
Schedule your backup script to execute automatically every night at 2:00 AM using system cron:
# Open root user crontab editor
sudo crontab -e
Add the following cron schedule entry to the bottom of the file:
# Execute daily backup script at 2:00 AM every night
0 2 * * * /opt/backups/daily_backup.sh >> /var/log/oracle_backup.log 2>&1
Save and exit. Your backup pipeline is now fully automated and will run every night without manual intervention!
Click the button below to learn more and get started.
A backup pipeline is only as reliable as its restoration process. Test database and file restoration periodically on a staging server or local environment:
# Decompress web files archive
tar -xzf web_files_2026-08-07.tar.gz -C /var/www/
# Restore MySQL database dump safely
gunzip < db_backup_2026-08-07.sql.gz | mysql -u root -p
Verify that your restored website loads correctly and that database records match recent application states.
In addition to file and database level backups, you can trigger cloud-level block volume backups programmatically using the OCI CLI command line interface:
# Trigger an automated OCI boot volume backup
oci bv boot-volume-backup create --boot-volume-id ocid1.bootvolume.oc1... --display-name "Daily-Auto-Backup-$(date +%Y-%m-%d)"
Combining local file compression with cloud block volume snapshots creates an enterprise-grade dual-layer backup architecture on free hardware.
To maximize data safety and compliance when managing cloud backups, adopt these industry standards:
Can I automate OCI Boot Volume Snapshots via OCI CLI?
Yes. You can use the command oci bv boot-volume-backup create --boot-volume-id <OCID> inside a cron script to trigger cloud-level block volume backups programmatically.
How much storage space do I need for off-site backups?
For a typical WordPress website (1GB database + 3GB media assets), a 7-day rolling retention archive consumes approximately 15GB to 25GB of remote cloud storage (costing less than $0.15/month on Backblaze B2 or S3 Glacier).
Why should I compress database dumps with gzip?
Gzip compression reduces raw SQL text dumps by 80% to 90%, significantly accelerating off-site cloud synchronization speeds and cutting remote storage costs.
What happens if the backup script fails during execution?
By appending >> /var/log/oracle_backup.log 2>&1 to your cron command, all error messages and exit codes are recorded locally. You can also configure email alerts using mailx or a Discord webhook to notify you immediately if a backup fails.
How do I encrypt my off-site backups before uploading?
You can pass the --gpg flag to tar or configure an encrypted remote in rclone (`rclone crypt`), ensuring that your database dumps and configuration files are fully encrypted before reaching remote cloud servers.
Cloud Infrastructure Engineer and technical writer specializing in VPS setups and network configurations.
Networking & SecurityPrevent DNS and SSL breakdowns when your VM restarts. Learn how to convert ephemeral IPs to a free Reserved Public Static IP on Oracle Cloud VPS.
Hosting BenchmarksComprehensive guide for UK business owners comparing Managed WordPress Hosting against Self-Hosted Cloud VPS on speed, uptime, security, and maintenance costs.
Cloud HostingIs MySQL or Nginx crashing on your Oracle Cloud Free Tier instance? Learn how to prevent kernel OOM killer crashes by configuring a Linux Swap file.