Backup script

Status
Not open for further replies.

bcmike

Active Member
Jun 7, 2018
326
54
28
53
Hi,

I'm trying to back up the database using the backup script in the documentation. I've plugged in the password from the /etc/fusionpbx/config.php file but when I run it from the shell as root I get: connection to database "fusionpbx" failed: FATAL: Peer authentication failed for user "fusionpbx".

Do I need to get the password from somewhere else?

Thanks
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,412
376
83
When I was first getting to grips with FusionPbx, I made a little shell script to test database connectivity. I called it pgsql-test.sh

Code:
#!/bin/sh

export PGPASSWORD="xxxxXXXXxxxxxxxXXxxx"
db_host=127.0.0.1
db_port=5432

#show message to the console
echo "Test Started"
psql --host=$db_host --port=$db_port --username=fusionpbx -c "select * from v_domains"
echo " ";
echo "Test Completed";

Adrian
 

bcmike

Active Member
Jun 7, 2018
326
54
28
53
Great script, thank you! It worked so there must be a problem in my backup script.
 

bcmike

Active Member
Jun 7, 2018
326
54
28
53
Great script, thank you! It worked so there must be a problem in my backup script.

Sorted.

This was the script as copied from documentation: https://docs.fusionpbx.com/en/latest/getting_started/backup.html

#!/bin/sh
now=$(date +%Y-%m-%d)
echo "Server Backup"
export PGPASSWORD="zzzzzzzz"
mkdir -p /var/backups/fusionpbx/postgresql
#delete postgres logs older than 7 days
find /var/log/postgresql/postgresql-9.4-main* -mtime +7 -exec rm {} \;
#delete freeswitch logs older 3 days
find /usr/local/freeswitch/log/freeswitch.log.* -mtime +2 -exec rm {} \;
pg_dump --verbose -Fc --host=$database_host --port=$database_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql
echo "Backup Complete";

This is my new script with edits in bold.

#!/bin/sh
now=$(date +%Y-%m-%d)
echo "Server Backup"
export PGPASSWORD='XXXXXXXXXXXXXXXXXX'
db_host=127.0.0.1
db_port=5432

mkdir -p /var/backups/fusionpbx/postgresql
#delete postgres logs older than 7 days
find /var/log/postgresql/postgresql-9.4-main* -mtime +7 -exec rm {} \;
#delete freeswitch logs older 3 days
find /usr/local/freeswitch/log/freeswitch.log.* -mtime +2 -exec rm {} \;
pg_dump --verbose -Fc --host=$db_host --port=$db_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql
echo "Backup Complete";

For some reason because they weren't declared, I thought $database_host and $database_port must be environment variables that were already set. Thats not the case, and using the db test script pointed me in the right direction.
 

ad5ou

Active Member
Jun 12, 2018
884
196
43
The documentation script is a little outdated. Newer installs have a backup script and maintenance script in /etc/cron.daily

If it is a really new install, the database password in the scripts will automatically match the actual pw
 

Vzb007

New Member
Aug 7, 2018
18
3
3
46
can anyon kind post the new backup script kindly so i dont have do a full reinstall. as i overwrote the script from the documentation and having issues. bugger should have checked before blindly following the doc.
 

Vzb007

New Member
Aug 7, 2018
18
3
3
46
@markjcrane with the above link provide by @Adrian Fretwell fix worked perfect. is there a way i myself could assist in updating the latest doc. of the back up page. so noobs like me dont do the mistake of copying the old script.

Once again thank you for such a amazing software. its well thought out. the countless hours of coding, i cant even imagine.
 

markjcrane

Active Member
Staff member
Jul 22, 2018
448
162
43
49
Both the documentation and the install script are on github.

Documentation is found here

Formatted to look nice and searchable. Also can find a page and click on edit on github.
- https://docs.fusionpbx.com/en/latest/

Install script on github
 
  • Like
Reactions: Vzb007
Status
Not open for further replies.