项目作者: HarryR

项目描述 :
PostgreSQL 9.5 in a Vagrant or Docker container with daily and monthly backups
高级语言: Shell
项目地址: git://github.com/HarryR/postgresql-container.git
创建时间: 2017-01-26T22:48:15Z
项目社区:https://github.com/HarryR/postgresql-container

开源协议:MIT License

下载


PostgreSQL 9.5 container with daily backups

Creates a container for PostgreSQL 9.5 for Vagrant+VirtualBox or Docker which takes nightly backups.

The database name will be the name of the directory you checkout the repository into, to create a database called ‘myapp-db’ run:

  1. git clone https://github.com/HarryR/vagrant-psql.git myapp-db

To get started with Docker, run:

  1. make docker-build docker-create docker-psql

To get started with Vagrant, run:

  1. make vagrant-install vagrant-up

A random login and password are chosen when provisioned, these are stored in the data/conf directory, run make credentials to display them.

Backups

Daily backups are made for a week, and then each sundays backups for a month are kept in the backups directory, to setup backups add a cron job for the container type you chose:

  1. @daily make -C /path-to/this-dir/ vagrant-backup
  2. @daily make -C /path-to/this-dir/ docker-backup

Each Sunday’s backups will be kept, and the past 7 days will be kept, resulting in files like:

  • backups/20161203.tar.xz
  • backups/20161210.tar.xz
  • backups/20161217.tar.xz
  • backups/20161218.tar.xz
  • backups/20161219.tar.xz
  • backups/20161220.tar.xz
  • backups/20161221.tar.xz
  • backups/20161222.tar.xz
  • backups/20161223.tar.xz

You cannot restore the data from a Docker container into a Vagrant instance or visa versa. What you do with the backups is your business, but I suggest encrypting and uploading to the cloud with transfer.py.

Restore from the latest available snapshot is possible, put the .tar.xz file into the backups/ directory and run:

  1. make restore

Misc

To destroy the box, and all runtime data, but will not delete backups:

  1. make xxx-destroy-data

To automatically start a Vagrant container at boot, use:

  1. @reboot make -C /path-to/this-dir/ vagrant-up