/[smecontribs]/rpms/smeserver-freepbx/contribs9/smeserver-freepbx-13.bz9637.backupFBX.patch
ViewVC logotype

Contents of /rpms/smeserver-freepbx/contribs9/smeserver-freepbx-13.bz9637.backupFBX.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Jan 25 21:09:53 2017 UTC (7 years, 3 months ago) by unnilennium
Branch: MAIN
CVS Tags: smeserver-freepbx-13-15_el6_sme, smeserver-freepbx-13-13_el6_sme, smeserver-freepbx-13-12_el6_sme, smeserver-freepbx-13-11_el6_sme, smeserver-freepbx-13-14_el6_sme, HEAD
* Wed Jan 25 2017 Jean-Philipe Pialasse <tests@pialasse.com> 13-11.sme
- NFR: auto backup of whole FBX config during pre-backup event [SME: 9637]
- both asdb and fpbx, asterisk config files, freepbx folders, voicemails are part of backup
- 2 versions are kepts
- weekly backup is also done.

1 diff -Nur smeserver-freepbx-13.old/createlinks smeserver-freepbx-13/createlinks
2 --- smeserver-freepbx-13.old/createlinks 2016-06-13 08:03:08.000000000 -0400
3 +++ smeserver-freepbx-13/createlinks 2017-01-25 15:56:22.776000000 -0500
4 @@ -39,9 +39,11 @@
5 templates2events("/etc/e-smith/sql/init/30freepbx_mysql_create_database", qw(freepbx-update bootstrap-console-save));
6
7 event_link("freepbx-checkinstall", $event, "10");
8 +event_link("freepbx-checkinstall-backup", $event, "11");
9 event_link("freepbx-amportal.conf", $event, "91");
10 event_link("freepbx-clean-crontab", $event, "40");
11 event_link("freepbx-dump-astdb", "pre-backup", "30");
12 +event_link("freepbx-backup", "pre-backup", "31");
13
14 safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.init");
15 safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith");
16 diff -Nur smeserver-freepbx-13.old/root/etc/asterisk/freepbx_chown.conf smeserver-freepbx-13/root/etc/asterisk/freepbx_chown.conf
17 --- smeserver-freepbx-13.old/root/etc/asterisk/freepbx_chown.conf 2017-01-25 15:45:49.144000000 -0500
18 +++ smeserver-freepbx-13/root/etc/asterisk/freepbx_chown.conf 2017-01-25 16:05:42.195000000 -0500
19 @@ -1,2 +1,5 @@
20 [blacklist]
21 directory = /tmp/
22 +[custom]
23 +rdir = /home/e-smith/files/freepbx,0750,asterisk,asterisk
24 +
25 diff -Nur smeserver-freepbx-13.old/root/etc/e-smith/events/actions/freepbx-backup smeserver-freepbx-13/root/etc/e-smith/events/actions/freepbx-backup
26 --- smeserver-freepbx-13.old/root/etc/e-smith/events/actions/freepbx-backup 1969-12-31 19:00:00.000000000 -0500
27 +++ smeserver-freepbx-13/root/etc/e-smith/events/actions/freepbx-backup 2017-01-25 15:47:41.342000000 -0500
28 @@ -0,0 +1,3 @@
29 +#!/bin/bash
30 +
31 +su asterisk -s /bin/bash -c 'php /var/lib/asterisk/bin/backup.php --id=1'
32 diff -Nur smeserver-freepbx-13.old/root/etc/e-smith/events/actions/freepbx-checkinstall-backup smeserver-freepbx-13/root/etc/e-smith/events/actions/freepbx-checkinstall-backup
33 --- smeserver-freepbx-13.old/root/etc/e-smith/events/actions/freepbx-checkinstall-backup 1969-12-31 19:00:00.000000000 -0500
34 +++ smeserver-freepbx-13/root/etc/e-smith/events/actions/freepbx-checkinstall-backup 2017-01-25 16:06:20.613000000 -0500
35 @@ -0,0 +1,72 @@
36 +#!/bin/sh
37 +
38 +DBNAME=$(/sbin/e-smith/db configuration getprop freepbx DbName)
39 +backuppath='/home/e-smith/files/freepbx'
40 +
41 +# check if backup module is enabled and running
42 +# if not solve this...
43 +if [[ ! `/usr/sbin/fwconsole ma list|/bin/grep backup|/bin/grep Enabled` ]] ; then
44 +
45 + if [[ ! `/usr/sbin/fwconsole ma list|/bin/grep backup` ]] ;then
46 + /usr/sbin/fwconsole ma download backup -R standard -R extended 2>&1 >/dev/null
47 + /usr/sbin/fwconsole ma install backup -R standard -R extended 2>&1 >/dev/null
48 + fi
49 +
50 + if [[ `/usr/sbin/fwconsole ma list|/bin/grep backup| grep 'Not Installed'` ]] ;then
51 + /usr/sbin/fwconsole ma install backup -R standard -R extended 2>&1 >/dev/null
52 + fi
53 +
54 + if [[ `/usr/sbin/fwconsole ma list|/bin/grep backup|/bin/grep Disabled` ]] ; then
55 + /usr/sbin/fwconsole ma enable backup 2>&1 >/dev/null
56 + fi
57 +
58 + /usr/sbin/fwconsole r
59 +fi
60 +
61 +# check our freepbx backup folder is there and accessible
62 +if [[ ! -d $backuppath ]] ; then
63 + /bin/mkdir -p $backuppath
64 +fi
65 +
66 +# set first backup as the one for SME way
67 +# set destination
68 +mysql -e "use $DBNAME;UPDATE backup_server_details set value = '/home/e-smith/files/freepbx' WHERE server_id = 1;"
69 +# set info for backup 1
70 +#data = a:1:{s:10:"created_by";s:11:"install.php";}
71 +mysql -e "use $DBNAME;INSERT INTO backup (\`id\`, \`name\`, \`description\` , \`immortal\` ,\`data\`, \`email\` ) VALUES (1, 'Default backup', 'Default SME PBX backup; automatically installed', 'true','', 'admin' ) ON DUPLICATE KEY UPDATE \`description\` = 'Default SME PBX backup; automatically installed', \`immortal\` = 'true', \`email\` = 'admin' , \`name\`= 'Default backup' ;"
72 +
73 +mysql -e "use $DBNAME;ALTER TABLE backup_details ADD UNIQUE uniq ( \`backup_id\` , \`key\` , \`index\` ) ;"
74 +mysql -e "use $DBNAME;INSERT INTO backup_details (\`backup_id\`, \`key\`, \`index\`, \`value\`) VALUES
75 +(1, 'delete_time_type', '', 'days'),
76 +(1, 'delete_amount', '', '2'),
77 +(1, 'desc', '', 'Default SME PBX backup; automatically installed'),
78 +(1, 'cron_schedule', '', 'weekly'),
79 +(1, 'cron_random', '', 'on'),
80 +(1, 'cron_month', '', ''),
81 +(1, 'cron_minute', '', '0'),
82 +(1, 'cron_hour', '', '0'),
83 +(1, 'cron_dow', '', '0'),
84 +(1, 'cron_dom', '', ''),
85 +(1, 'bu_server', '', '0'),
86 +(1, 'delete_time', '', '0'),
87 +(1, 'email', '', 'admin'),
88 +(1, 'emailfailonly', '', '1'),
89 +(1, 'storage_servers', '0', '1') ON DUPLICATE KEY UPDATE \`value\`=VALUES(\`value\`) ;"
90 +mysql -e "use $DBNAME;ALTER TABLE backup_details DROP INDEX uniq;"
91 +# set what to backup
92 +mysql -e "use $DBNAME;ALTER TABLE backup_items ADD UNIQUE \`uniq\` ( \`backup_id\` , \`type\` , \`path\` ( 15 ) ) ;"
93 +mysql -e "use freepbxdb;INSERT INTO backup_items (\`backup_id\`, \`type\`, \`path\`, \`exclude\`) VALUES
94 +(1, 'dir', '/etc/dahdi', 'a:0:{}'),
95 + (1, 'dir', '__ASTSPOOLDIR__/voicemail', 'a:0:{}'),
96 +(1, 'mysql', 'server-2', 'a:0:{}'),
97 +(1, 'astdb', 'astdb', 'a:0:{}'),
98 +(1, 'mysql', 'server-3', 'a:0:{}'),
99 +(1, 'dir', '__ASTETCDIR__', 'a:0:{}'),
100 +(1, 'dir', '__AMPWEBROOT__', 'a:0:{}'),
101 +(1, 'dir', '__AMPBIN__', 'a:0:{}'),
102 +(1, 'dir', '/tftpboot', 'a:0:{}') ON DUPLICATE KEY UPDATE \`exclude\`=VALUES(\`exclude\`) ;";
103 +mysql -e "use $DBNAME;ALTER TABLE backup_items DROP INDEX \`uniq\` ;"
104 +
105 +# make sure all perms are ok for backup
106 +/usr/sbin/fwconsole chown 2>&1 >/dev/null
107 +

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed