Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 📝 add back up guide #196

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/operator-guide/tutorials/backups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Backing up Orion database
It is recommended to schedule daily backups for the `orion-db` service.
This will ensure that a copy of the whole database is saved daily to be used for emergencies
This guide shows a simple method in order to back up `orion-db` using the [cron](https://en.wikipedia.org/wiki/Cron) utility.

Suppose you want to back up orion a daily cron job at 9:00 AM CET. Provided that the `orion-db` service is being run in a docker container, you can follow these steps:

1. Open your crontab file for editing. You can do this by running the following command:

```bash
crontab -e
```

2. Add the following line to your crontab file. This line schedules the job to run every day at 9:00 AM CET:

```bash
0 9 * * * TZ='Europe/Paris' docker exec orion-db pg_dumpall -U postgres > "/path/to/backup/directory/orion-production-$(date '+\%Y-\%m-\%d').bak"
```

Make sure to replace `/path/to/backup/directory` with the actual path where you want to store the backup files.

Here's what each field in the cron expression means:

- `0`: Minutes field, specifying 0 minutes past the hour.
- `9`: Hours field, specifying 9 AM.
- `*`: Wildcard for days of the month, meaning it will run every day.
- `*`: Wildcard for months, meaning it will run every month.
- `*`: Wildcard for days of the week, meaning it will run every day of the week.
- `TZ='Europe/Paris'`: Sets the timezone to CET (Central European Time) to ensure it runs at 9:00 AM CET.

3. Save and exit the crontab file. The cron job is now scheduled to run daily at 9:00 AM CET and will dump the PostgreSQL database to the specified backup file with the current date in the filename.