Created
July 17, 2017 11:42
-
-
Save seuf/e89defe900e88da49fe2c05e01a6f6b7 to your computer and use it in GitHub Desktop.
pg_dump_zabbix_no_history.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
today=$(date "+%Y-%m-%d") | |
last_week=$(date -d "1 weeks ago" "+%Y-%m-%d") | |
data_dir="/tmp" | |
data_file="zabbix-$today.sql" | |
lastweek_file="zabbix-$last_week.sql" | |
echo "Dumping zabbix databse into $data_dir/$data_file" | |
pg_dump -h localhost -d zabbix -f $data_dir/$data_file --exclude-table-data=history* --exclude-table-data=trends* --exclude-table-data=events --exclude-table-data=alerts --exclude-table-data=sessions --exclude-table-data=auditlog --exclude-table-data=acknowledges | |
echo "Compressing dump file to $data_dir/$data_file.tar.gz" | |
cd $data_dir | |
tar -czf $data_file.tar.gz $data_file | |
rm -f $data_dir/$data_file | |
ls -lh $data_file.tar.gz | |
echo "removing last week dump : $data_dir/$lastweek_file" | |
rm -f $data_dir/$lastweek_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment