Code Monkey home page Code Monkey logo

backup-postgresql-db-remote's Introduction

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.

cp .env.sample .env

3. Install pg_dump on the machine where you will run this script

Install pg_dump 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

bundle exec ruby run.rb --name DB_NAME`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.