Backup and Restore

Status
Not open for further replies.

mc6650

Member
Apr 8, 2019
110
2
18
62
Hello
I have a backup (automatically generated by FusionPBX) from a Debian 10 machine. Can I restore it to a newly minted Debian 11 machine and if so how do I do it? I don't understand the procedures outlined in this document.


Thanks in advance for any help that can be provided.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
You should be able to do it fairly easily. The steps I take are:
1. Build new server
2. Backup old server
3. Restore backup to new server
4. Run upgrade on the new server at least twice

The upgrade process will make any database schema changes and data type changes to the restored data required by the new level of software.
 

mc6650

Member
Apr 8, 2019
110
2
18
62
Thanks for the information. I'm not that sure about step 3. Restore backup to new server.

I have these instructions https://docs.fusionpbx.com/en/latest/getting_started/restore.html?highlight=Restore#restore

And I have a backup file fusionpbx_pgsql_2022-03-16.sql

I'm not sure how I use the script outlined in the above documentation to upload the .sql file. Ideally I'm looking for something in the GUI that I'd "press" restore, browse to where the backup file is and then upload it. Does FusionPBX have this capability?
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
You can't do it in the GUI, I use a small script to do the restore. Be aware this script drops the schema before the restore, use at your own risk:

Code:
#!/bin/sh

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

echo "Restore Started"

#remove the old database
psql --host=$db_host --port=$db_port  --username=fusionpbx -c 'drop schema public cascade;'
psql --host=$db_host --port=$db_port  --username=fusionpbx -c 'create schema public;'

#restore the database
pg_restore -v -Fc --host=$db_host --port=$db_port --dbname=fusionpbx --username=fusionpbx /var/backup/fusionpbx/postgresql/fusionpbx_pgsql_2022-03-16.sql

echo "Restore Completed"
 

mc6650

Member
Apr 8, 2019
110
2
18
62
Thanks

So if I've got this correct:

1.) Copy fusionpbx_pgsql_2022-03-16.sql into /var/backup/fusionpbx/postgresql
1B.) Does it matter that the user name I log in with is different to "username=fusionpbx"?
2.) I'm not sure what PGPASSWORD="XXXXXXXXXXXXXXXXXXXXXXXXXXX" is or where I would get it from.
3.) Do I still need to run Advance > Upgrade twice on the new server?
4.) If I understand this cautionary note "Be aware this script drops the schema before the restore, use at your own risk", your saying that if I've programmed anything into the new server. then it's going to be wiped out by the restore? Is that correct? I shouldn't have to worry as I haven't logged into the new server yet.

Thanks for the help.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Ok, answers in order...

fusionpbx is the database username, not a shell login username.
You will find the database password in /etc/fusionpbx/config.php
Yes you need to run upgrade twice. I tend to use the command line version, I think it is more reliable:
Code:
php /var/www/fusionpbx/core/upgrade/upgrade.php

If you have no data on there then don't worry about the script removing the database. The script is actually fairly safe until you put your actual database users password in there. Then it could do some damage to a live system!
 

mc6650

Member
Apr 8, 2019
110
2
18
62
Hello
I get this error message when I try to run it. Command line is not my specialty.

root@FusionPBX:/home/pbx2# ./bin.sh
bash: ./bin.sh: /bin/sh^M: bad interpreter: No such file or directory
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
It looks like the line #!/bin/sh is not being interpreted correctly but instead just running another instance of sh.
What file name did you call the script?
For example if you created a file called my-restore.sh and copied the contents of above into it and set the password correctly, you should then make sure it has the executable flag set:
chmod +x my-restore.sh

Finally execute it with:
./my-restore.sh

I know you said the command line is not your speciality, but you will need to know it to run, maintain and diagnose a VoIP server.
 
  • Like
Reactions: hfoster

mc6650

Member
Apr 8, 2019
110
2
18
62
Good news I've got the system restored (somewhat). I believe the gateway needs to be reconfigured and the phones aren't registering. The new machine is on a Proxmox Virtual server and I've changed the IP address of the FusionPBX Virtual Server to be the same as the old server: 192.168.2.25. I have a local DNS entery in my router to point azlan.fusionpbx.ca to 192.168.2.25 and I can ping both successfully. My micro softphone on a Windows 10 machine is set up to use domain azlan.fushiopbx.ca, how ever it won't register with the new server. I'm starting to notice other things that are broken within the GUI so I think I'll hold off on using the virtual server and revert back to my old machine and try and resolve the issue where the GUI admin page won't come up. At least I'll have two machines to play around with! :)
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
You can effectively diagnose registration issues with a packet capture (tcpdump), if your box is not too busy then sngrep works very well.
 
Status
Not open for further replies.