#!/bin/bash #***************************************# #*****http://alexeyka.zantsev.com/******# #***************************************# BACKUP_DIR=/home/user/PBX_BACKUPS TAR="/bin/tar -czf" DATE=$(date +%Y-%m-%d) CDRDAY=$(date +%d) SQLDUMP="/usr/bin/mysqldump" SRVNAME=pbx_ #------------------------------------------------ # function for backup routine bkuper () { # 1. cd to dir cd $BACKUP_DIR mkdir BACKUP # 2. copy mission-critical shit for i in /etc/asterisk/ /etc/lighttpd/lighttpd.conf /etc/odbc.ini /etc/odbcinst.ini /var/scripts/ ; do /bin/cp -r $i BACKUP/ done # 3. CDR SQL dump on 28 day monthly if [ $CDRDAY == 28 ] then $SQLDUMP -u root -pRoOtPaSsWoRd db_asterisk_cdr > BACKUP/db_asterisk_cdr.$DATE.sql fi # 4. archivate $TAR $SRVNAME$DATE.tar.gz BACKUP/ # 5. delete shit /bin/rm -rf BACKUP/ } #------------------------------------------------ # fire! if [ -d $BACKUP_DIR ] then bkuper else /bin/mkdir $BACKUP_DIR bkuper fi # remove older than 30 days old backups find $BACKUP_DIR -type f -name "*z" -mtime +30 -execdir rm -f {} \; exit $?
Posts Tagged ‘backup’
PBX backup script
Tuesday, September 5th, 2017PostgreSQL Database Backup
Wednesday, January 16th, 2013For a single database mybase located on a server dbserver.local, from a user john :
pg_dump -h dbserver.local -U john mybase > backup_db_mybase.`date +%Y.%m.%d`.sql
This simple trick may do a great deal for you.