File: backup_pgsql.sh

package info (click to toggle)
rsnapshot 1.3.1-4%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,876 kB
  • ctags: 915
  • sloc: perl: 4,328; sh: 3,225; makefile: 138
file content (34 lines) | stat: -rwxr-xr-x 1,064 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

##############################################################################
# backup_pgsql.sh
#
# Debian modifications by Antony Gelberg <antony.gelberg@wayforth.com>
#
# by Nathan Rosenquist <nathan@rsnapshot.org>
# http://www.rsnapshot.org/
#
# This is a simple shell script to backup a PostgreSQL database with rsnapshot.
#
# The assumption is that this will be invoked from rsnapshot. Also, since it
# will run unattended, the user that runs rsnapshot (probably root) must su
# to Debian's postgres user.
#
# This script simply needs to dump a file into the current working directory.
# rsnapshot handles everything else.
##############################################################################

# $Id: backup_pgsql.sh,v 1.6 2007/03/22 02:50:21 drhyde Exp $

umask 0077

# backup the database
su -c 'pg_dumpall > ~/pg_dumpall.sql' postgres

# make the backup readable only by root
chown root.root ~postgres/pg_dumpall.sql
chmod 600 ~postgres/pg_dumpall.sql

# Move the backup to current working directory
mv ~postgres/pg_dumpall.sql `pwd`