Restoring a backup - Permission denied issue

Status
Not open for further replies.

Andrew Byrd

Member
Feb 16, 2018
309
10
18
53
I have run backup on one server and then restore to a different server and when I get almost to the restore complete I get this message:

nice: '/etc/cron.daily/./fusionpbx-backup.sh': Permission denied

Any ideas on this?

Debian 10
FPBX 4.11.5
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
Much more likely the script hasn't got execute permissions, it wants to run it but needs a chmod +x
 

Andrew Byrd

Member
Feb 16, 2018
309
10
18
53
I seem to have fixed the chmod issue and have another issue. When I backup I get this message

root@abnetworks:~# /etc/cron.daily/fusionpbx-backup.sh
Server Backup
find: '/var/log/postgresql/postgresql-9.4-main*': No such file or directory
find: '/usr/local/freeswitch/log/freeswitch.log.*': No such file or directory
pg_dump: error: connection to database "fusionpbx" failed: FATAL: Peer authentication failed for user "fusionpbx"
Backup Complete

Can you point me in the right direction on this error?
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
Where have you got this backup script? /usr/localfreeswitch comes from the dinosaur days of building from source?
 

Andrew Byrd

Member
Feb 16, 2018
309
10
18
53
I got the script right off of fusionpbx docs

I changed the ssh server and the password to xxxxxx's but all the rest is what I used


#!/bin/sh
now=$(date +%Y-%m-%d)
ssh_server=xx.xx.xx.xx
database_host=127.0.0.1
database_port=5432
export PGPASSWORD="xxxxxxxxxxxxxxxxx"

#run the remote backup
ssh -p 22 root@$ssh_server "nice -n -20 /etc/cron.daily/fusionpbx-backup"

#delete freeswitch logs older 7 days
find /var/log/freeswitch/freeswitch.log.* -mtime +7 -exec rm {} \;

#synchronize the backup directory
#rsync -avz -e 'ssh -p 22' root@$ssh_server:/var/backups/fusionpbx /var/backups
rsync -avz -e 'ssh -p 22' root@$ssh_server:/var/backups/fusionpbx/postgresql /var/backups/fusionpbx
rsync -avz -e 'ssh -p 22' root@$ssh_server:/var/www/fusionpbx /var/www
rsync -avz -e 'ssh -p 22' root@$ssh_server:/etc/fusionpbx /etc
find /var/backups/fusionpbx/postgresql -mtime +2 -exec rm {} \;

rsync -avz -e 'ssh -p 22' root@$ssh_server:/etc/freeswitch/ /etc
rsync -avz -e 'ssh -p 22' root@$ssh_server:/var/lib/freeswitch/storage /var/lib/freeswitch
rsync -avz -e 'ssh -p 22' root@$ssh_server:/var/lib/freeswitch/recordings /var/lib/freeswitch
rsync -avz -e 'ssh -p 22' root@$ssh_server:/usr/share/freeswitch/scripts /usr/share/freeswitch
rsync -avz -e 'ssh -p 22' root@$ssh_server:/usr/share/freeswitch/sounds /usr/share/freeswitch

echo "Restoring the Backup"
#extract the backup from the tgz file
tar -xvpzf /var/backups/fusionpbx/backup_$now.tgz -C /

#remove the old database
psql --host=$database_host --port=$database_port --username=fusionpbx -c 'drop schema public cascade;'
psql --host=$database_host --port=$database_port --username=fusionpbx -c 'create schema public;'
#restore the database
pg_restore -v -Fc --host=$database_host --port=$database_port --dbname=fusionpbx --username=fusionpbx /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql

#restart freeswitch
service freeswitch restart
echo "Restore Complete";
 

Andrew Byrd

Member
Feb 16, 2018
309
10
18
53
What I do is spin up a new server with Debian 10, Fusionpbx, and ensure Postgresql are the same version (12.1)

Then I run the back up script o the production server. Then I ssh to the backupserver and run the restore command. It now shows restore successful, but when I login there is no data there - just a blank copy of Fusion.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
Sorry, I have never used this method to backup, I guess I would just look at the backup script and reverse the actions. I didn't actually realize there is no restore!
 
Status
Not open for further replies.