diff --git a/bin/backup b/bin/backup new file mode 100755 index 0000000000000000000000000000000000000000..e2b5d5c25f88caeb0370d5f1dd9e445b4d509016 --- /dev/null +++ b/bin/backup @@ -0,0 +1,28 @@ +#!/bin/bash + +# 0 3 * * * pg_dump --dbname=$MYDB | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz + +if [[ $1 == "" || $2 == "" ]] +then echo "USAGE : ./psql gargantext.ini backup_directory" +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 diff --git a/bin/psql b/bin/psql index e9cc6ef36ddbaaf8f30ae17487df181121136596..a42867b0d6d77f1b4dcf82a929df0ef17e1f8b95 100755 --- a/bin/psql +++ b/bin/psql @@ -1,23 +1,30 @@ #!/bin/bash + +if [[ $1 == "" ]] +then echo "USAGE : ./psql gargantext.ini" +else + INIFILE=$1 getter () { grep $1 $INIFILE | sed "s/^.*= //" } -connect () { USER=$(getter "DB_USER") NAME=$(getter "DB_NAME") PASS=$(getter "DB_PASS") HOST=$(getter "DB_HOST") PORT=$(getter "DB_PORT") + +# "postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}" + +GARGDB="postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}" + +#echo "connecting to $GARGDB" + psql "postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}" -} -if [[ $1 == "" ]] -then echo "USAGE : ./psql gargantext.ini" -else connect $INIFILE fi