From 44427eca48fc6be44a66bcb5d62beb699dd46f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VAN=20DER=20BIEST=20C=C3=A9lian?= Date: Tue, 14 Nov 2017 23:07:26 +0100 Subject: [PATCH] auto credentials + back_up in arg Credentials are now getting automaticly and the back_up folder can be parse in arg ( optional ). --- utils/libretime-backup.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/utils/libretime-backup.sh b/utils/libretime-backup.sh index 92356e15e..088236f8d 100644 --- a/utils/libretime-backup.sh +++ b/utils/libretime-backup.sh @@ -1,9 +1,21 @@ #!/bin/bash -sound_folder='/srv/airtime/stor/' -backup_folder='/home/example/backup/' -psql_user='airtime' -psql_password='airtime' +if [ -z "$1" ] + then + ## Use config + backup_folder=~/libretime_backup/ + else + ## User arg as config + backup_folder=$1 +fi + + +airtime_conf_path=/etc/airtime/airtime.conf +sound_folder=/srv/airtime/stor/ + +psdl_db=$(grep dbname ${airtime_conf_path} | awk '{print $3;}' ) +psql_user=$(grep dbuser ${airtime_conf_path} | awk '{print $3;}' ) +psql_password=$(grep dbpass ${airtime_conf_path} | awk '{print $3;}' ) ## Remove old backup rm -rf $backup_folder @@ -12,7 +24,7 @@ mkdir $backup_folder ## Backup of database echo 'db: Getting database...' -pg_dump --dbname='postgresql://'$psql_user':'$psql_password'@localhost/airtime' > $backup_folder'database' +pg_dump --dbname='postgresql://'$psql_user':'$psql_password'@localhost/'$psql_db > $backup_folder'database' echo 'db: Complete' ## Backup of sounds