-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathcron_backup.sh.original
More file actions
executable file
·51 lines (37 loc) · 2.15 KB
/
cron_backup.sh.original
File metadata and controls
executable file
·51 lines (37 loc) · 2.15 KB
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
#!/bin/bash
# cron_backup.sh
# version 0.1
########################################################################################################
# config part
# feel free to change it! because, there is big chance it will not work if you don't.
########################################################################################################
# if you are puzzled what to put here, just look at your booki/settings.py file
PGHOST=localhost # hostname for postgresql connection
#PGPORT= # port for postgresql connection
PGUSER= # postgresql connection user
PGPASSWORD= # postgresql connection password
PGDATABASE= # postgresql connection database
DESTINATION=/tmp/ # where do you want to put your backup files
ADMIN_MAIL=root # who will get mail when everything goes downhill
########################################################################################################
# config part
# probably no need to change this part
########################################################################################################
PGDUMP=pg_dump # path to pg_dump if it is not in PATH.
# if you don't know what to do with this, just leave it as it is.
COMPRESS=gzip # just in case your gzip is not in PATH.
# if you don't know what to do with this, just leave it as it is.
MAILUTILITY=mail # just in case mail is not in PATH.
# if you don't know what to do with this, just leave it as it is.
STAMP=`date +%d-%b-%Y` # for example: 12-Dec-2010
# this could be a problem if you want to make backup more then once per day.
########################################################################################################
# do not change this part
########################################################################################################
${PGDUMP} ${PGDATABASE} -b | ${COMPRESS} - > "${DESTINATION}/backup-${PGDATABASE}-${STAMP}.sql.gz"
if [ $? -ne 0 -o ${PIPESTATUS[0]} -ne 0 ]; then
${MAILUTILITY} -s "[ERROR] Could not finish backup" ${ADMIN_MAIL} <<MAILEND
Could not finish backup of database ${PGDATABASE}.
MAILEND
exit 1
fi