April 23, 2017

Using a Dynamic DNS hostname in an Access List on IOS

class-map type inspect match-any Internet_To_Trusted
 match access-group name Allowed-Traffic
 match access-group name IPv6-Allowed-Traffic
 match access-group name uk-nas
ip access-list extended uk-nas
 permit tcp host xxx.xxx.xxx.xxx any
kron occurrence day8am at 8:00 recurring
 policy-list policy-day8am
kron policy-list policy-day8am
 cli tclsh gethostip

#gethostip TCL Script on flash

# Clear cached DNS Entry
exec clear host xxxxx.synology.me
# Remove ACL
ios_config "no ip access-list uk-nas"
# Add ACL - DNS Lookup will be done at this time.
ios_config "ip access-list extended uk-nas" "permit tcp host xxxxx.synology.me any"

April 11, 2017

mySQL Backup

nano /usr/local/bin/backup-mysql

DB_BACKUP="/media/nas-backup/mx1.wjw.nz/mysql/`date +%Y-%m-%d`"

# Create the backup directory
mkdir -p $DB_BACKUP

# Remove backups older than 10 days
# find /backups/mysql_backup/ -maxdepth 1 -type d -mtime +10 -exec rm -rf {} \;
# Backup each database on the system
for db in $(mysql --user=$DB_USER --password=$DB_PASSWD -e 'show databases' -s --skip-column-names|grep -viE '(staging|performance_schema|information_schema)');
do mysqldump --user=$DB_USER --password=$DB_PASSWD --events --opt --single-transaction $db | gzip > "$DB_BACKUP/mysqldump-$HN-$db-$(date +%Y-%m-%d).gz";   

chmod +x /usr/local/bin/backup-mysql mysql> grant select,show view, lock tables, event on *.* to 'backup'@localhost identified by 'xxxxxx';

Useful Links