Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

Thursday, March 26, 2009

Tar with date and a twist of chocolate

Here is a way to tar up a set of important directories with the date. You can use this as a log archive, or with Splunk. This uses the highest compression of gzip (-9).

tar cp /myapp/logs /var/log/messages /var/log/httpd/ | gzip -9c > /tmp/oldlogs`date +"%Y%m%d"`.tgz

Friday, June 27, 2008

Dates within crontab

If you want to add dates to backups or logs, like mythtvDB27062008.sql within crontab, do the following:

0 0 * * * /usr/bin/mysqldump -u mythtv -pPassword mythconverg > /mythtv/recordings/mythtvDB`date +%d%m%Y`.sql

The key is the backquotes around the `date +%d%m%Y` command. This will backup a MythTV MySQL database to a file like this: /mythtv/recordings/mythtvDB27062008.sql every night at midnight.