CLI Recipes: Backup Jobs & Tiers

Harry · 14 Sep 2026 · 1 views
Advertisement
Advertisement

Practical recipes

These fight the real job: a nightly DB backup that lands in Object Storage and auto-ages to Archive via the lifecycle rule from the last lesson.

Nightly dump + upload

#!/bin/bash
BACKUP=/backups/$(date +%F).sql.gz
sudo mysqldump --all-databases | gzip > $BACKUP
oci os object put --namespace $NS --bucket-name groovygrails-books \
  --file $BACKUP
find /backups -name "*.sql.gz" -mtime +14 -delete

Schedule with cron: 0 2 * * * /usr/local/bin/backup-db.sh. Keep 14 days local, forever in the bucket (lifecycle archives after 30).

List, copy, restore

oci os object list --namespace $NS --bucket-name groovygrails-books
oci os object copy --namespace $NS --bucket-name groovygrails-books \
  --source-object-name 2026-09-14.sql.gz --destination-region ap-mumbai-1
oci os object get --namespace $NS --bucket-name groovygrails-books \
  --name 2026-09-14.sql.gz --file restore.sql.gz

Tier transitions

Also useful: oci os object update-tier to manually move an object to Infrequent-Access or Archive instantly, plus --restore-days on an archived object to un-archive for retrieval. Between lifecycle rules and one-line tier moves, your storage cost curve stays flat as the data grows.

Share this post:

Comments (0)

Please login or register to comment.