Scripts

From My Notepad
Jump to: navigation, search

Asterisk system backup

#!/bin/bash
BACKUPDIR=/tmp/pbx-backup
BACKUPFILE=$BACKUPDIR/pbx-backup.`hostname`.tar.bz2

[ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR

[ -f $BACKUPFILE ] && rm -f $BACKUPFILE

tar -cjvf $BACKUPFILE -C / /etc/zaptel.conf /etc/asterisk/ /etc/sysconfig/zaptel /etc/httpd/conf* /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth* /var/lib/asterisk/astdb /var/lib/asterisk/keys /var/lib/asterisk/agi-bin/ /var/lib/asterisk/scripts /var/lib/asterisk/sounds/custom

Run this to install the script into /etc/cron.daily/:

cd /etc/cron.daily/
wget http://files.bluecrow.net/scripts/pbx-backup
chmod 755 pbx-backup
./pbx-backup

Once the script is installed and running daily, you can then pull the backup file using rsync or scp.

Create ZIP for each folder in a directory

for /f "usebackq" %G in (`dir /b /a:d "%cd%"`) do "C:\Program Files\7-Zip\7z.exe" a -r -tzip "%~G.zip" "%~G"