Backup database (quick reference)
This page is a cheat-sheet of the most common dump commands. For full, copy-paste recipes โ including restore steps and an automated, scheduled job โ use the per-database Tutorials.
Create a local dump folder first:
mkdir -p ./db-dumps
Use a single rolling dump file and overwrite it each run. Do not create a new timestamped filename every day โ a stable path keeps uploads dedup-friendly while still producing a fresh snapshot each time.
PostgreSQL (custom-format dump)โ
export PGPASSWORD='your_password'
pg_dump \
--host=127.0.0.1 \
--port=5432 \
--username=postgres \
--format=custom \
--file=./db-dumps/app.dump \
app_db
โ Full guide: Tutorials โ PostgreSQL
MySQL / MariaDB (single transaction dump)โ
mysqldump \
--host=127.0.0.1 \
--port=3306 \
--user=root \
--password='your_password' \
--single-transaction \
--quick \
--routines \
--triggers \
app_db > ./db-dumps/app.sql
โ Full guide: Tutorials โ MySQL
SQLite (consistent online backup)โ
sqlite3 /path/to/app.db ".backup './db-dumps/app.sqlite'"
โ Full guide: Tutorials โ SQLite
MongoDB (archive dump)โ
mongodump --uri="mongodb://user:pass@127.0.0.1:27017/app_db" \
--archive=./db-dumps/app.archive --gzip
โ Full guide: Tutorials โ MongoDB
Amazon DynamoDB (table export to JSON)โ
aws dynamodb scan --table-name app_table \
--output json > ./db-dumps/app_table.json
โ Full guide: Tutorials โ Amazon DynamoDB
Amazon S3 (sync a bucket locally)โ
aws s3 sync s3://your-bucket ./db-dumps/your-bucket
โ Full guide: Tutorials โ Amazon S3
Once a dump exists in ./db-dumps, upload it with the SDK โ see Upload Backup Data and Manage Snapshots, or wire the whole thing into a cron job with Automated backup with scheduling.