Merge pull request #351 from celianvdb/patch-1

Backup script
This commit is contained in:
Robb 2019-02-08 09:20:33 -05:00 committed by GitHub
commit 1cb6e09075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 0 deletions

44
utils/libretime-backup.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
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
mkdir $backup_folder
## Backup of database
echo 'db: Getting database...'
pg_dump --dbname='postgresql://'$psql_user':'$psql_password'@localhost/'$psql_db > $backup_folder'database'
echo 'db: Complete'
## Backup of sounds
mkdir $backup_folder'sounds/'
echo 'stor : Copying sounds...'
rsync -r -a --info=progress2 $sound_folder $backup_folder'sounds/'
echo 'stor: Complete'
## Backup of libretime config
mkdir $backup_folder'airtime_config/'
echo 'config: Copying config...'
rsync -r -a --info=progress2 /etc/airtime/ $backup_folder'airtime_config/'
echo 'config: Complete'