I wanted a nice way to do an hourly backup of a mysql database and only keep a days worth.
In the past I have written scripts that would check how many files were there or used find to delete
old only.
I wondered if I could use logrotate to handle this since it is installed on most systems and is simple to use.
Unfortunately it doesn't understand the term hourly and only does daily and monthly.
I wrote my backup script and created a simple logrotate.conf file but left out the section that said
how often to run.
[root@server1 bin]# cat backup-www-db.logrotate
/var/database_backup/mysql_dump.sql {
# hourly
rotate 24
compress
delaycompress
missingok
create 640 root adm
}
Then I just told the backup script to run logrotate as the first thing it does giving it that config file:
/usr/sbin/logrotate /usr/adm/bin/backup-www-db.logrotate
It rotates the previous database dump and compresses them.
It only runs when the script runs so I set cron to run every hour and we have a nice simple solution.
Showing posts with label redhat. Show all posts
Showing posts with label redhat. Show all posts
Tuesday, December 6, 2011
Cloning Redhat Servers in Vmware and networking
After cloning a Redhat/Centos box in vmware and booting it, the network refused to come up.
I found that udev had the MAC's for the old server hard coded and did not clean them up on the reboot.
Commenting out the old lines and rebooting forced udev to recreate new entries and away we went.
{ krkardlnxapp2 } [ /etc/udev/rules.d ]$ cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:00:c9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:08:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:08:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
I found that udev had the MAC's for the old server hard coded and did not clean them up on the reboot.
Commenting out the old lines and rebooting forced udev to recreate new entries and away we went.
{ krkardlnxapp2 } [ /etc/udev/rules.d ]$ cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:00:c9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:08:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:08:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
Tuesday, July 7, 2009
How to add a disk to a vmware linux guest without rebooting
I have a whole series of linux guests running on some ESX hosts off NFS shares.
Today I wanted to add another disk to a running guest and couldn't reboot it.
ESX let me add the disk but the CentOS 5.3 guests didn't see it automatically.
I ran this command:
echo - - - > /sys/class/scsi_host/host0/scan
Today I wanted to add another disk to a running guest and couldn't reboot it.
ESX let me add the disk but the CentOS 5.3 guests didn't see it automatically.
I ran this command:
echo - - - > /sys/class/scsi_host/host0/scan
"That is echo dash space dash space dash /sys/class/scsi_host/host zero /scan"
and then the disk showed up under fdisk -l
Put a new LVM on it, added a filesystem, and mounted it.
and then the disk showed up under fdisk -l
Put a new LVM on it, added a filesystem, and mounted it.
Subscribe to:
Posts (Atom)