Changeset 3854
- Timestamp:
- 03/08/07 20:58:05 (6 years ago)
- Files:
-
- modules/branches/2.3/backup/bin/ampbackup.pl (modified) (7 diffs)
- modules/branches/2.3/backup/module.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.3/backup/bin/ampbackup.pl
r3019 r3854 62 62 $User_Preferences{"AMPWEBROOT"} = "/var/www/html"; 63 63 64 $User_Preferences{"AMPPROVROOT"} = ""; 65 $User_Preferences{"AMPPROVEXCLUDE"} = ""; 66 67 $User_Preferences{"FTPBACKUP"} = ""; 68 $User_Preferences{"FTPUSER"} = ""; 69 $User_Preferences{"FTPPASSWORD"} = ""; 70 $User_Preferences{"FTPSUBDIR"} = ""; 71 $User_Preferences{"FTPSERVER"} = ""; 72 73 $User_Preferences{"SSHBACKUP"} = ""; 74 $User_Preferences{"SSHUSER"} = ""; 75 $User_Preferences{"SSHRSAKEY"} = ""; 76 $User_Preferences{"SSHSUBDIR"} = ""; 77 $User_Preferences{"SSHSERVER"} = ""; 78 64 79 open(FILE, "/etc/amportal.conf") || die "Failed to open amportal.conf\n"; 65 80 while (<FILE>) { … … 95 110 $webroot = $User_Preferences{"AMPWEBROOT"}; 96 111 112 # Provisioning root(s) and exclude list, if phone configuratoins should be backed up 113 # 114 $provroot = $User_Preferences{"AMPPROVROOT"}; 115 $excludefile = $User_Preferences{"AMPPROVEXCLUDE"}; 116 97 117 # If and where to send the backup file once created (still left on local machine as well) 98 118 # … … 102 122 $ftpsubdir = $User_Preferences{"FTPSUBDIR"}; 103 123 $ftpserver = $User_Preferences{"FTPSERVER"}; 124 125 $sshbackup = uc $User_Preferences{"SSHBACKUP"}; 126 $sshuser = $User_Preferences{"SSHUSER"}; 127 $sshrsakey = $User_Preferences{"SSHRSAKEY"}; 128 $sshsubdir = $User_Preferences{"SSHSUBDIR"}; 129 $sshserver = $User_Preferences{"SSHSERVER"}; 104 130 105 131 ################### END OF CONFIGURATION ####################### … … 110 136 #my $Stamp="$year$mon$mday.$hour.$min.$sec"; 111 137 my $Stamp=sprintf "%04d%02d%02d.%02d.%02d.%02d",$year,$mon,$mday,$hour,$min,$sec; 112 113 138 114 139 if (scalar @ARGV > 1) … … 151 176 } 152 177 } 153 #print "$Backup_Name $Backup_Voicemail $Backup_Recordings $Backup_Configurations $Backup_CDR $Backup_FOP\n";154 155 178 156 179 system ("/bin/rm -rf /tmp/ampbackups.$Stamp > /dev/null 2>&1"); … … 165 188 system ($ast{'astvarlibdir'}."/bin/dumpastdb.php $Stamp > /dev/null"); 166 189 system ("/bin/tar -Pcz -f /tmp/ampbackups.$Stamp/configurations.tar.gz ".$ast{'astvarlibdir'}."/agi-bin/ ".$ast{'astvarlibdir'}."/bin/ /etc/asterisk $webroot/admin /etc/amportal.conf /tmp/ampbackups.$Stamp/astdb.dump "); 190 191 if ($provroot ne "") { 192 $excludearg = ""; 193 if (-r $excludefile) { 194 $excludearg = "--exclude-from $excludefile "; 195 } 196 system ("/bin/tar -Pcz $excludearg -f /tmp/ampbackups.$Stamp/phoneconfig.tar.gz $provroot "); 197 } 198 167 199 system ("mysqldump --add-drop-table -u $username -p$password --database $database > /tmp/ampbackups.$Stamp/asterisk.sql"); 168 200 } … … 186 218 # Note - the hardcoded full backup that cron does will overwrite each day at destination. 187 219 # 188 if ( $ftpbackup ne "YES" ) { 189 exit 190 } 191 192 open(FILE, ">$ftpfile") || die "Failed to open $ftpfile\n"; 220 if ( $ftpbackup eq "YES" ) { 221 open(FILE, ">$ftpfile") || die "Failed to open $ftpfile\n"; 193 222 194 printf FILE "user $ftpuser $ftppassword \n";195 printf FILE "binary\n";196 if ( $ftpsubdir ne "" ) {197 printf FILE "cd $ftpsubdir \n";198 }199 printf FILE "lcd /var/lib/asterisk/backups/$Backup_Name/\n";200 printf FILE "put $Stamp.tar.gz\n";201 printf FILE "bye\n";202 close(FILE);223 printf FILE "user $ftpuser $ftppassword \n"; 224 printf FILE "binary\n"; 225 if ( $ftpsubdir ne "" ) { 226 printf FILE "cd $ftpsubdir \n"; 227 } 228 printf FILE "lcd /var/lib/asterisk/backups/$Backup_Name/\n"; 229 printf FILE "put $Stamp.tar.gz\n"; 230 printf FILE "bye\n"; 231 close(FILE); 203 232 204 system ("ftp -n $ftpserver < $ftpfile > /dev/null 2>&1");233 system ("ftp -n $ftpserver < $ftpfile > /dev/null 2>&1"); 205 234 206 #system ("/bin/rm -rf /tmp/ftp2cabana > /dev/null 2>&1"); 207 208 235 #system ("/bin/rm -rf /tmp/ftp2cabana > /dev/null 2>&1"); 236 } 237 238 if ( ($sshbackup eq "YES") && ($sshrsakey ne "") && ($sshserver ne "") ) { 239 240 if ($sshuser eq "") { 241 $sshuser = system("whoami"); 242 } 243 if ($sshsubdir ne "") { 244 system("/usr/bin/ssh -o StrictHostKeyChecking=no -i $sshrsakey $sshuser\@$sshserver mkdir -p $sshsubdir"); 245 } 246 system("/usr/bin/scp -o StrictHostKeyChecking=no -i $sshrsakey /var/lib/asterisk/backups/$Backup_Name/$Stamp.tar.gz $sshuser\@$sshserver:$sshsubdir"); 247 } 209 248 210 249 exit 0; modules/branches/2.3/backup/module.xml
r3677 r3854 2 2 <rawname>backup</rawname> 3 3 <name>Backup & Restore</name> 4 <version>2.1. 1</version>4 <version>2.1.2</version> 5 5 <type>tool</type> 6 6 <category>System Administration</category> … … 12 12 </depends> 13 13 <changelog> 14 *2.1.2* Add ability to scp backups to a server, add optional provisioning directory that can be backed up (no restore ability) 14 15 *2.1.1* Remove core_users2astdb and core_devices2astdb, it isn't needed and corrupts resotred ampuser info 15 16 *2.1* Actually, really, restore ASTDB now. Finally. Also add redirect_standard to avoid problems with TRBoE.
