From 4625f8db208858d204915eb08d170781b0a2e1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VAN=20DER=20BIEST=20C=C3=A9lian?= Date: Fri, 10 Nov 2017 22:30:12 +0100 Subject: [PATCH 1/4] Adding a backup script Just have to set config, chmod +x and it works ;) --- utils/airtime-backup.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 utils/airtime-backup.sh diff --git a/utils/airtime-backup.sh b/utils/airtime-backup.sh new file mode 100644 index 000000000..afd8f9503 --- /dev/null +++ b/utils/airtime-backup.sh @@ -0,0 +1,30 @@ +sound_folder='/srv/airtime/stor/' +backup_folder='/home/example/backup/' +psql_user='airtime' +psql_password='airtime' + +## 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/airtime' > $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' From 1bec7b619cb5e9d9256105cc2a52de6f08411fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VAN=20DER=20BIEST=20C=C3=A9lian?= Date: Fri, 10 Nov 2017 22:32:18 +0100 Subject: [PATCH 2/4] Forgot #!/bin/bash --- utils/airtime-backup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/airtime-backup.sh b/utils/airtime-backup.sh index afd8f9503..92356e15e 100644 --- a/utils/airtime-backup.sh +++ b/utils/airtime-backup.sh @@ -1,3 +1,5 @@ +#!/bin/bash + sound_folder='/srv/airtime/stor/' backup_folder='/home/example/backup/' psql_user='airtime' From f6386a60e748981b8750bfe73ad2b153b1f8d843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VAN=20DER=20BIEST=20C=C3=A9lian?= Date: Sat, 11 Nov 2017 11:15:10 +0100 Subject: [PATCH 3/4] Rename airtime-backup.sh to libretime-backup.sh --- utils/{airtime-backup.sh => libretime-backup.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename utils/{airtime-backup.sh => libretime-backup.sh} (100%) diff --git a/utils/airtime-backup.sh b/utils/libretime-backup.sh similarity index 100% rename from utils/airtime-backup.sh rename to utils/libretime-backup.sh 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 4/4] 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