Hi gang, I see that some posters today don't do full (or any?) backups of their Asterisk systems/configuration. This may (sort of) help you. Since pretty much all Linux systems have some sort of PERL installed, these two files will let you make a quick copy of any configuration or other file you might be about to change or destroy. File 1 - /usr/bin/checkout /usr/local/bin/perl /etc/asterisk/checkout.pl $1 File 2 - /etc/asterisk/checkout.pl #!/usr/local/bin/perl # Author: Danny Nicholas use File::Copy; # assign command line parms my $inname = $ARGV[0]; my ($sec, $min, $hr, $day, $mon, $year) = localtime(time); $mon = $mon +1; $mon = sprintf("%2d",$mon); $day = sprintf("%2d",$day); $hr = sprintf("%2d",$hr); $min = sprintf("%2d",$min); $mon =~ s/\s/0/; $day =~ s/\s/0/; $hr =~ s/\s/0/; $min =~ s/\s/0/; my $outname = $inname."_".$mon.$day."_".$hr.$min; print "copy $inname to $outname\n"; copy($inname,$outname); exit If you are going to make a dialplan change, just do Checkout /etc/asterisk/extensions.conf and voila, you have a backup to fall back on. Hope this helps somebody. Regards, Danny Nicholas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100914/6b9b053e/attachment.htm
On Tue, 14 Sep 2010, Danny Nicholas wrote:> I see that some posters today don?t do full (or any?) backups of their > Asterisk systems/configuration.? This may (sort of) help you.? Since > pretty much all Linux systems have some sort of PERL installed, these > two files will let you make a quick copy of any configuration or other > file you might be about to change or destroy.Good advice, however I prefer to work on a copy. I do something similar with a bash function: # save a file creating a copy and appending a timestamp to the file name function save() { SUFFIX=$(date +%Y-%m-%d-%H-%M-%S) mv $1 $1-${SUFFIX} cp $1-${SUFFIX} $1 } I do the move before the copy so I can undo my mistakes just by mv'ing the file with the suffix back to the file name without the suffix. That way, even the modification* date of the file is not changed and it won't be backed up unnecessarily. If whatever I screwed up isn't discovered for a few days, I can choose which suffixed file I want to "restore." Better advice would be to get off your LFA and do the backups :) For all the hosts I manage, I have a script started by crontab that creates a tarball of the configuration and source files and emails the tarball back to me. I have a rule in my procmailrc to automagically dump the tarball into my /backup/ directory. This shows its value when a client says "I like it better the way it was before Xmas" or "Why did you charge me $XXX 6 weeks ago Tuesday." *) I'll leave it as an exercise for the reader to preserve the access and change dates :) -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000