Skip to content

Commit

Permalink
doc: add Quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
jkaninda committed Dec 18, 2024
1 parent dd0362f commit e9f01c4
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 107 deletions.
2 changes: 1 addition & 1 deletion docs/how-tos/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: How Tos
layout: default
nav_order: 3
nav_order: 4
has_children: true
---

Expand Down
105 changes: 0 additions & 105 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,112 +55,7 @@ Code and documentation for `v1` version on [this branch][v1-branch].

---

## Quickstart

### Simple backup using Docker CLI

To run a one time backup, bind your local volume to `/backup` in the container and run the `backup` command:

```shell
docker run --rm --network your_network_name \
-v $PWD/backup:/backup/ \
-e "DB_HOST=dbhost" \
-e "DB_USERNAME=username" \
-e "DB_PASSWORD=password" \
jkaninda/pg-bkup backup -d database_name
```

Alternatively, pass a `--env-file` in order to use a full config as described below.

```yaml
docker run --rm --network your_network_name \
--env-file your-env-file \
-v $PWD/backup:/backup/ \
jkaninda/pg-bkup backup -d database_name
```

### Simple backup in docker compose file

```yaml
services:
pg-bkup:
# In production, it is advised to lock your image tag to a proper
# release version instead of using `latest`.
# Check https://github.com/jkaninda/pg-bkup/releases
# for a list of available releases.
image: jkaninda/pg-bkup
container_name: pg-bkup
command: backup
volumes:
- ./backup:/backup
environment:
- DB_PORT=5432
- DB_HOST=postgres
- DB_NAME=foo
- DB_USERNAME=bar
- DB_PASSWORD=password
- TZ=Europe/Paris
# pg-bkup container must be connected to the same network with your database
networks:
- web
networks:
web:
```
### Docker recurring backup
```shell
docker run --rm --network network_name \
-v $PWD/backup:/backup/ \
-e "DB_HOST=hostname" \
-e "DB_USERNAME=user" \
-e "DB_PASSWORD=password" \
jkaninda/pg-bkup backup -d dbName --cron-expression "@every 15m" #@midnight
```
See: https://jkaninda.github.io/pg-bkup/reference/#predefined-schedules

## Kubernetes

```yaml
apiVersion: batch/v1
kind: Job
metadata:
name: backup-job
spec:
ttlSecondsAfterFinished: 100
template:
spec:
containers:
- name: pg-bkup
# In production, it is advised to lock your image tag to a proper
# release version instead of using `latest`.
# Check https://github.com/jkaninda/pg-bkup/releases
# for a list of available releases.
image: jkaninda/pg-bkup
command:
- /bin/sh
- -c
- backup -d dbname
resources:
limits:
memory: "128Mi"
cpu: "500m"
env:
- name: DB_HOST
value: "postgres"
- name: DB_USERNAME
value: "postgres"
- name: DB_PASSWORD
value: "password"
volumeMounts:
- mountPath: /backup
name: backup
volumes:
- name: backup
hostPath:
path: /home/toto/backup # directory location on host
type: Directory # this field is optional
restartPolicy: Never
```
## Available image registries

This Docker image is published to both Docker Hub and the GitHub container registry.
Expand Down
121 changes: 121 additions & 0 deletions docs/quickstart/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: Quickstart
layout: home
nav_order: 2
---

# Quickstart

## Simple Backup Using Docker CLI

To run a one-time backup, bind your local volume to `/backup` in the container and run the `backup` command:

```shell
docker run --rm --network your_network_name \
-v $PWD/backup:/backup/ \
-e "DB_HOST=dbhost" \
-e "DB_USERNAME=username" \
-e "DB_PASSWORD=password" \
jkaninda/pg-bkup backup -d database_name
```

### Using a Full Configuration File

Alternatively, you can use an `--env-file` to pass a full configuration:

```shell
docker run --rm --network your_network_name \
--env-file your-env-file \
-v $PWD/backup:/backup/ \
jkaninda/pg-bkup backup -d database_name
```

## Simple Backup Using Docker Compose

Here is an example `docker-compose.yml` configuration:

```yaml
services:
pg-bkup:
# In production, lock the image tag to a release version.
# See https://github.com/jkaninda/pg-bkup/releases for available releases.
image: jkaninda/pg-bkup
container_name: pg-bkup
command: backup
volumes:
- ./backup:/backup
environment:
- DB_PORT=5432
- DB_HOST=postgres
- DB_NAME=foo
- DB_USERNAME=bar
- DB_PASSWORD=password
- TZ=Europe/Paris
# Connect pg-bkup to the same network as your database.
networks:
- web

networks:
web:
```
## Recurring Backup with Docker
To schedule recurring backups, use the `--cron-expression` flag:

```shell
docker run --rm --network network_name \
-v $PWD/backup:/backup/ \
-e "DB_HOST=hostname" \
-e "DB_USERNAME=user" \
-e "DB_PASSWORD=password" \
jkaninda/pg-bkup backup -d dbName --cron-expression "@every 15m"
```

For predefined schedules, see the [documentation](https://jkaninda.github.io/pg-bkup/reference/#predefined-schedules).

## Backup Using Kubernetes

Here is an example Kubernetes `Job` configuration for backups:

```yaml
apiVersion: batch/v1
kind: Job
metadata:
name: backup-job
spec:
ttlSecondsAfterFinished: 100
template:
spec:
containers:
- name: pg-bkup
# In production, lock the image tag to a release version.
# See https://github.com/jkaninda/pg-bkup/releases for available releases.
image: jkaninda/pg-bkup
command:
- /bin/sh
- -c
- backup -d dbname
resources:
limits:
memory: "128Mi"
cpu: "500m"
env:
- name: DB_HOST
value: "postgres"
- name: DB_USERNAME
value: "postgres"
- name: DB_PASSWORD
value: "password"
volumeMounts:
- mountPath: /backup
name: backup
volumes:
- name: backup
hostPath:
path: /home/toto/backup # Directory location on host
type: Directory # Optional field
restartPolicy: Never
```


2 changes: 1 addition & 1 deletion docs/reference/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Configuration Reference
layout: default
nav_order: 2
nav_order: 3
---

# Configuration reference
Expand Down

0 comments on commit e9f01c4

Please sign in to comment.