Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucianghinda/backup-postgresql-db-remote
A simple Ruby script to backup a PostgreSQL DB remote to Cloudflare R2
https://github.com/lucianghinda/backup-postgresql-db-remote
backup postgresql ruby
Last synced: 12 days ago
JSON representation
A simple Ruby script to backup a PostgreSQL DB remote to Cloudflare R2
- Host: GitHub
- URL: https://github.com/lucianghinda/backup-postgresql-db-remote
- Owner: lucianghinda
- License: apache-2.0
- Created: 2024-04-17T02:33:59.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-23T09:23:21.000Z (7 months ago)
- Last Synced: 2024-05-01T12:39:29.258Z (7 months ago)
- Topics: backup, postgresql, ruby
- Language: Ruby
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# A simple script to backup a PostgreSQL DB to a Cloudflare R2 endpoint
## How to use it
### 1. Create an account on Cloudflare
1. Go to https://www.cloudflare.com/developer-platform/r2/ and create an account
2. Create a bucket in R2 (make sure it is not public)
3. Go to "Manage R2 API Tokens" and generate a token for your own bucket. Keep that around to add it to your environment variables### 2. Configure environment variables
Configure your environment with environment variables that are shown in `.env.sample`.
```bash
cp .env.sample .env
```### 3. Install `pg_dump` on the machine where you will run this script
Install [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) on the machine where you plan to run this script
### 4. Configure password for the user that will be used to connect to PostgreSQL
pg_dump does not allow to directly specify the password.
So you should configure the password using `.pgpass` file.
### 4. Run the script
```bash
bundle exec ruby run.rb --name DB_NAME`
```