Giter Club home page Giter Club logo

akash-postgres-restore's Introduction

Akash Postgres Restore

An auto-restoring Postgres server running on Akash, with backups taken on a configurable schedule. Backups are stored on decentralised storage using Filebase.

Ultimately this is a two container setup, one PostgreSQL server and one scheduler container to restore the database on boot, and run a cronjob to back it up.

Usage

  • Setup a Filebase account and bucket (or any S3 compatible storage host).
  • Set the environment variables in the deploy.yml and deploy on Akash
  • Use the URL and port Akash gives you to connect to the Postgres server, with the credentials you provided in the environment variables. For example cluster.ewr1p0.mainnet.akashian.io:31234

Using with an app container

Alternatively add your own app container to the deploy.yml and expose the Postgres 5432 port to your application only for a local server.

For example:

services:
  app: 
    image: myappimage:v1
    depends_on: 
      - service: postgres
  cron:
    image: ghcr.io/ovrclk/akash-postgres-restore:v0.0.4
    env:
      - POSTGRES_PASSWORD=password
      ...
    depends_on:
      - service: postgres
  postgres:
    image: postgres:12.6
    env:
      - POSTGRES_PASSWORD=password
    expose:
      - port: 5432
        to:
          - service: app
          - service: cron

Environment variables

  • POSTGRES_USER=postgres - your Postgres server username
  • POSTGRES_PASSWORD=password - your Postgres server password
  • POSTGRES_HOST=postgres - postgres server host, whatever you named it in deploy.yml
  • POSTGRES_PORT=5432 - postgres port, will be 5432 unless you aliased it in deploy.yml
  • POSTGRES_DATABASE=akash_postgres - name of your database
  • BACKUP_PATH=bucketname/path - bucket and path for your deployments. Make sure directories exist first
  • BACKUP_KEY=key - your Filebase access key
  • BACKUP_SECRET=secret - your Filebase secret
  • BACKUP_PASSPHRASE=secret - a passphrase to encrypt your backups with
  • BACKUP_HOST=https://s3.filebase.com - the S3 backup host, this defaults to Filebase but can be any S3 compatible host
  • BACKUP_SCHEDULE=*/15 * * * * - the cron schedule for backups. Defaults to every 15 minutes
  • BACKUP_RETAIN=7 days - how many days to keep backups for

Development

You can run the application locally using Docker compose.

Copy the .env.sample file to .env and populate

Run docker-compose up to build and run the application

akash-postgres-restore's People

Contributors

rorcual-nodes avatar tombeynon avatar

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.