auto credentials + back_up in arg

Credentials are now getting automaticly and the back_up folder can be parse in arg ( optional ).
This commit is contained in:
VAN DER BIEST Célian 2017-11-14 23:07:26 +01:00 committed by GitHub
parent f6386a60e7
commit 44427eca48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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