-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpg_backup.config
63 lines (48 loc) · 1.73 KB
/
pg_backup.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# Optional system user to run backups as. If the user the script is running as doesn't match this
# the script terminates. Leave blank to skip check.
BACKUP_USER=
# Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified.
DB_HOSTNAME=
# Optional username to connect to database as. Will default to "postgres" if none specified.
# should be allowed to connect to prod and dev databases
DB_USERNAME=
# user that has no ownership, so need to be grante permissions
DB_USERNAME_DEV=
# production database
DATABASE_PROD=
# will replicate prod database on dev if set to yes
RESTORE_DEV=yes
# development database to replicate dumps
DATABASE_DEV=
# Will send backup files and logs to telegram chat if set to "yes"
TELEGRAM_MODE=
# Telegram chat id
#! REQUIRED FOR TELEGRAM_MODE
TELEGRAM_CHAT=
# Telegram bot token
#! REQUIRED FOR TELEGRAM_MODE
TELEGRAM_BOT_TOKEN=
# This dir will be created if it doesn't exist. This must be writable by the user the script is
# running as.
# Different systems have different permissions for creating files
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
BACKUP_DIR=/home/$BACKUP_USER/backups/$DATABASE_PROD/
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OSX
# so i am testing locally
BACKUP_DIR=$(dirname $(stat -f $0))/backups/
else
echo "Unknown system $OSTYPE"
exit 1
fi
############# SETTINGS FOR ROTATED BACKUPS #############
# Which day to take the weekly backup from (1-7 = Monday-Sunday)
DAY_OF_WEEK_TO_KEEP=6
# Number of days to keep daily backups
DAYS_TO_KEEP=7
# How many weeks to keep weekly backups
WEEKS_TO_KEEP=5
###############################################