This script creates a backup of a local database to a cloud backend. It assumes:
- Your DB is not in the cloud (otherwise just use e.g. RDS with automatic backups)
- Your destination bucket already exists and you have permissions to write to it
- You are either running this script on the DB server or can SSH to that machine
Ensure you have the following installed
- GNU parallel
- AWS command line tools and/or (to install on macOS
brew install awscli
) - Azure command line tools (to install on macOS:
brew install azure-cli
)
For Oracle:
Grab the Instant Client Tools & SQLPlus packages from Oracle, which includes expdp
and sqlplus
On macOS:
brew tap InstantClientTap/instantclient
brew install instantclient-tools
brew install instantclient-sqlplus
And update your path to include the expdp
and sqlplus
binaries
(run brew info instantclient-tools
and brew install instantclient-sqlplus
to see where they lives)
For PostgreSQL:
Install PostgreSQL client libraries
On macOS:
brew install libpq
See here for updating your path.
- Copy
backup.conf.sample
tobackup.conf
and modify settings as appropriate - Then run
./backup.sh -c backup.conf
Run make lint
To automatically patch, run e.g. shellcheck -f diff backup.sh | patch