backup 551 Bytes
Newer Older
1 2 3 4 5
#!/bin/bash

# 0 3 * * * pg_dump --dbname=$MYDB | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz

if [[ $1 == "" || $2 == "" ]]
6
then echo "USAGE : ./bin/backup gargantext.ini backup_directory"
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
else 

INIFILE=$1

getter () {
  grep $1 $INIFILE | sed "s/^.*= //"
}

USER=$(getter "DB_USER")
NAME=$(getter "DB_NAME")
PASS=$(getter "DB_PASS")
HOST=$(getter "DB_HOST")
PORT=$(getter "DB_PORT")


GARGDB="postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}"

#echo "backuping $GARGDB"
pg_dump --dbname=$GARGDB | gzip > $2/$(date +%Y-%m-%d).garg_dump.gz


fi