I have a backup script that backs up my /var/log/ folder daily. The backup names the tar file date-logs.tgz and works just fine. If I ran it today it would look like 28-Febuary-2013-logs.tgz.
What has me scratching my head is now I want to perform the backup monthly instead of daily. So I was thinking of having the crontab run the script on the beginning of the month however the date would put the current month in as the month when I would prefer the previous month in the file name.
So my monthly script would run tomorrow March 1st and the filename would be Febuary-2013-logs.tgz.
Here is an excerpt from the script:
Can anyone point me in the right direction?
What has me scratching my head is now I want to perform the backup monthly instead of daily. So I was thinking of having the crontab run the script on the beginning of the month however the date would put the current month in as the month when I would prefer the previous month in the file name.
So my monthly script would run tomorrow March 1st and the filename would be Febuary-2013-logs.tgz.
Here is an excerpt from the script:
Code:
#!/bin/sh
present=`date +'%d-%B-%Y'`
/usr/bin/tar cvzf /usr/LogTemp/$present-logs.tgz /var/log
Can anyone point me in the right direction?