Skip to content

Instantly share code, notes, and snippets.

@jezman
Created September 8, 2016 14:21
Show Gist options
  • Save jezman/f0b20da43179322245c540c022b19ce8 to your computer and use it in GitHub Desktop.
Save jezman/f0b20da43179322245c540c022b19ce8 to your computer and use it in GitHub Desktop.
Zabbix backup
#!/bin/bash
DAY=`date +%Y-%m-%d`
DIR=/home/zabbix/backup/Zabbix_$DAY
set_date()
{
DT=`date "+%y-%m-%d %H:%M:%S"`
}
mkdir $DIR
mysqldump -uuser -ppass zabbix > $DIR/zabbix.sql
cd $DIR
tar -zcf $DIR/zabbix_db_$DAY.tar.gz ./zabbix.sql
rm -rf $DIR/zabbix.sql
mkdir /mnt/zabbix/zabbix_$DAY
mv $DIR/zabbix_db_$DAY.tar.gz /mnt/zabbix/zabbix_$DAY
set_date
find /mnt/zabbix/* -type f -ctime +15 -exec rm -rf {} \;
find /mnt/zabbix/* -type d -name "*" -empty -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment