cancel
Showing results for 
Search instead for 
Did you mean: 

Shell Script for performing a backup

 

Here is the simple script which will run as a job

Open any editor like (vi, gedit) of any choice name to the scirpt
and place the below script in it.

========================================================
#!/bin/bash

DIR=/backup/psql
[ ! $DIR ] && mkdir -p $DIR || :
LIST=$(psql -l | awk '{ print $1}' | grep -vE '^-|^List|^Name|template[0|1]|^\(|^\|')
for d in $LIST
do
  pg_dump $d | gzip -c >  $DIR/$d.out.gz
done
========================================================

Now its ready for execution

Version history
Revision #:
1 of 1
Last update:
‎06-15-2017 08:17 PM
Updated by:
 
Labels (2)
Contributors