Does anyone want to share how to restore a backup using the CLI
In the many years I have been using FreePBX I have never got round to decoding satisfactorily the restore script:-
/var/lib/asterisk/bin/restore.php
the required restore --items=* are wrapped up in base64 encoding.
Pragmatically I have a script much like :–
#!/bin/bash
OPTS=YToyOntzOjg6InNldHRpbmdzIjtzOjQ6InRydWUiO3M6NToiZmlsZXMiO2E6MTp7aTowO3M6NDoiL2V0YyI7fX0=
DIR=/var/spool/asterisk/asterisk/everytenminutes/
FILE=$(ls -rt ${DIR}*.tgz|tail -1)
echo Restoring $FILE
php /var/lib/asterisk/bin/restore.php --restore=${FILE} --items=${OPTS}
The ${OPTS} I derived by watching what
ps -ax |grep restore.php
divulged when a particular restore selection was applied against a defined backup set.
If anyone has a fuller documentation of how --items could be properly defined before base64 encoding it, I would also be obliged to them.
FYI and just so I don’t sound like I haven’t done due diligence:-
echo ToyOntzOjg6InNldHRpbmdzIjtzOjQ6InRydWUiO3M6NToZmlsZXMiO2E6MTp7aTowO3M6NDoiL2V0YyI7fX0=|base64 -d a:2:{s:8:"settings";s:4:"true";s:5:"files";a:1:{i:0;s:4:"/etc";}}
If anyone has the patience or knows of the documentation as to how decode/encode that “serialized, array of options”, then we could perhaps make it more easily scriptable.
TONY, Can you please help?
@dicko you’ll be happy to know that if you grab the restore script from the new v12 backup &restore module, it’s a pile more useful, and documented, and, well, usable.
There’s nothing stopping you using that restore script with any backup, it’s backwards compatible.
Thank you Rob!
So to posi211, In FreePBX 12 it is now obvious:-
/var/lib/asterisk/bin/restore.php
restore.php
options:
–restore=/path/to/backup/file.tgz
Specify the path to the backup file you wish to restore.
–items=…
This is either a base64 encoded, serialized array, which is provided
by the web interface, or, a comma separated list of any of the following:
all Restore everything in the backup
This is the same as enabling all the following options
mysql Restore the MySQL Settings Database
astdb Restore the AstDB
cdr Restore the CDR Database
files Restore all files in the backup
–manifest=/path/to/file.tgz
Display the manifest file embedded in the backup .tgz.
–skipnat
This explicitly skips any per-machine NAT settings (eg, externip)
Since I’m up to my eyeballs in a broken install tonight that won’t load the Backup/Restore module, I’m looking through command line options while a backup restores to a clean install.
So an example command would be:
/var/lib/asterisk/bin/restore.php --restore=/var/spool/asterisk/backup/Default_backup/20161129-000002-1480406402-13.0.190.7-395518204.tgz --items=all
??
Sorry to revive an old topic, but I discovered an important time saving note for others using the command line restore method…
RUN THIS AS ASTERISK USER!!!
If you run it as root, new folders created will be owned by root, removing access from the asterisk user, creating strange anomalies in your FreePBX system that you won’t find solutions to in the forums.
I will post my own custom script soon for others to use, since I figured it out the hard way.
If you’ve run an restore command as root… you can always wipe and reinstall from scratch, but here’s a few commands I did that seemed to fix mine:
chown -R asterisk:asterisk /var/lib/asterisk
chown -R asterisk:asterisk /var/spool/asterisk
chown -R asterisk:asterisk /tftpboot
chown -R asterisk:asterisk /etc/dahdi
With the following commands, ignore the errors. Also ignore how errors capitalize “Core” and “Userman”, etc. the following command won’t work unless they are lowercased.
fwconsole -f ma download core
fwconsole ma install core
fwconsole -f ma download userman
fwconsole ma install userman
/var/lib/asterisk/bin/freepbx_setting MODULEADMIN_SKIP_CACHE 1 && amportal a ma upgrade framework && /var/lib/asterisk/bin/freepbx_setting MODULEADMIN_SKIP_CACHE 0
fwconsole ma download framework; fwconsole ma install framework
fwconsole ma upgradeall
If in Modules Admin GUI page, any more modules are broken, run following commands for each (replace modulename below with exact module name listed on the page):
fwconsole -f ma download modulename
fwconsole ma install modulename
If Sangoma MCU refuses to download, and you don’t use it, just nuke it:
rm -Rf /var/www/html/admin/modules/sng_mcu
Then wrap it up with:
fwconsole ma refreshsignatures
/var/lib/asterisk/bin/freepbx_setting MODULEADMIN_SKIP_CACHE 0
fwconsole Reload
Note: IF YOU DON’T INCLUDE AMPWEBROOT AND AMPBIN directories in your original backup, restoring on a different server will break modules (database listing of module versions won’t match web root folders for each module). And you’ll get modules unsigned errors, -255 errors and other anomalies.
Hi Dicko,
I am not able to find /var/lib/asterisk/bin/restore.php file in that path, can you help me in that.
I am trying to prepare script to auto restore backup file on monthly basis
Hi Dicko,
I am not able to find /var/lib/asterisk/bin/restore.php file in that path, can you help me in that.
I am trying to prepare script to auto restore backup file on monthly basis.
5 years later, read
fwconsole backup
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.