PostgreSQL db backup and restore is easy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/bin/sh
case "$1" in
b)
pg_dump -F t -f "$3.tar" "$2"
;;
r)
pg_restore -c -F t -d "$2" "$3.tar" 2>/dev/null
;;
*)
echo "usage: pgbr {b|r} <db> <file>.tar"
exit 1
;;
esac