Revert "remove shell"

This reverts commit 65914f8895.
This commit is contained in:
root
2023-09-24 18:58:33 +03:00
parent 65914f8895
commit c793b55750
26 changed files with 132 additions and 132 deletions

View File

@ -5,7 +5,7 @@ date: 2022-12-14T16:48:00+05:00
tags: [linux, postgres]
---
## Скрипт для бэкапа БД и глобальных объектов
```
```shell
#!/usr/bin/env bash
pg_dump -U <username> -h <pg-hostname> -Fc <db> --file=<db>-$(date '+%Y-%m-%d').dump
pg_dumpall -U <username> -h <pg-hostname> --globals --file=gb-$(date '+%Y-%m-%d').dump
@ -14,14 +14,14 @@ pg_dumpall -U <username> -h <pg-hostname> --globals --file=gb-$(date '+%Y-%m-%d'
```
## Файл cron с запуском скрипта (каждый день в 2:00)
```
```shell
0 2 * * * /usr/bin/env bash /home/<username>/pg-backup.sh
# crontab -e -u <username>
```
## Рестор файлов БД и глобальных объектов
```
```shell
pg_restore -C -d postgres <dbname>-<date>.dump
psql -U postgres < gb-<date>.dump
```