Re: [gentoo-user] Hows this for rsnapshot cron jobs?

2013-04-22 Thread Alan McKinnon
On 21/04/2013 22:49, Tanstaafl wrote:
 On 2013-04-21 4:32 PM, Alan McKinnon alan.mckin...@gmail.com wrote:
 On 21/04/2013 20:47, Tanstaafl wrote:
 30 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf
 monthly
 20 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf yearly
 
 Only the last line is wrong - your monthly and yearly are equivalent.To
 be properly yearly, you need a month value in field 4.
 
 Oh, right (I added that interval myself, rsnapshot only comes with the
 hourly, daily weekly and monthly by default).
 
 So, if I wanted it to run at 8:20pm on Dec 31, it would be:
 
 20 22 31 12 *  rootrsnapshot -c /etc/rsnapshot/myhost1.conf yearly


Correct



 I'm not familiar with rsnapshot, I assume that package can deal with how
 many of each type of snapshot to retain in it's conf file? I see no
 crons to delete out of date snapshots.
 
 Correct, rsnapshot handles this.
 
 And, more as a nitpick than anything else, I always recommend that when
 a sysadmin adds a root cronjob, use crontab -e so it goes in
 /var/spool/cron, not /etc/crontab. Two benefits:

 - syntax checking when you save and quit
 - if you let portage, package managers, chef, puppet or whatever manage
 your global cronjobs in /etc/portage, then there's no danger that system
 will trash the stuff that you added there manually.
 
 I prefer doing things manually... so, nothing else manages my cron jobs.
 
 That said, I prefer to do this 'the gentoo way'... so is crontab -e the
 gentoo way?


There's no gentoo way for this :-)

Admittedly, things have changed over the years, most distros now have
the equivalent of cron.daily etc that cron jobs get installed into,
leaving the main /etc/crontab as a place to put the lastrun logic. It
wasn't always like that though.

If you ever move to puppet or similar to do your configs you'll want to
revisit this. Meanwhile, as you do everything manually anyway, your
current method seems to work just fine for you


-- 
Alan McKinnon
alan.mckin...@gmail.com




[gentoo-user] Hows this for rsnapshot cron jobs?

2013-04-21 Thread Tanstaafl
Ok, my goal is to keep 3 'snapshots' per day (11:30am, 2:30pm and 
5:30pm), 7 daily's (8:50pm), 4 weekly's (8:40pm), 12 monthly's (8:30pm), 
and 5 yearly's (8:20pm).


My myhost1.conf has:

intervalhourly  3
intervaldaily   7
intervalweekly  4
intervalmonthly 12
intervalyearly  5

And my /etc/crontab now looks like:


# for vixie cron
# $Header: 
/var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.3 
2011/09/20 15:13:51 idl0r Exp $

# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59  *  * * *rootrm -f /var/spool/cron/lastrun/cron.hourly
9  3  * * * rootrm -f /var/spool/cron/lastrun/cron.daily
19 4  * * 6 rootrm -f /var/spool/cron/lastrun/cron.weekly
29 5  1 * * rootrm -f /var/spool/cron/lastrun/cron.monthly
*/10  *  * * *  roottest -x /usr/sbin/run-crons  /usr/sbin/run-crons
#
# rsnapshot cronjobs
#
30 11,14,17 * * * root   rsnapshot -c /etc/rsnapshot/myhost1.conf sync; 
rsnapshot -c /etc/rsnapshot/myhost1.conf hourly
50 20 * * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf daily
40 20 * * 6 rootrsnapshot -c /etc/rsnapshot/myhost1.conf weekly
30 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf monthly
20 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf yearly


Does this look right?

Thanks



Re: [gentoo-user] Hows this for rsnapshot cron jobs?

2013-04-21 Thread Alan McKinnon
On 21/04/2013 20:47, Tanstaafl wrote:
 Ok, my goal is to keep 3 'snapshots' per day (11:30am, 2:30pm and
 5:30pm), 7 daily's (8:50pm), 4 weekly's (8:40pm), 12 monthly's (8:30pm),
 and 5 yearly's (8:20pm).
 
 My myhost1.conf has:
 
 intervalhourly  3
 intervaldaily   7
 intervalweekly  4
 intervalmonthly 12
 intervalyearly  5
 
 And my /etc/crontab now looks like:
 
 # for vixie cron
 # $Header:
 /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.3
 2011/09/20 15:13:51 idl0r Exp $

 # Global variables
 SHELL=/bin/bash
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 MAILTO=root
 HOME=/

 # check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
 59  *  * * *rootrm -f /var/spool/cron/lastrun/cron.hourly
 9  3  * * * rootrm -f /var/spool/cron/lastrun/cron.daily
 19 4  * * 6 rootrm -f /var/spool/cron/lastrun/cron.weekly
 29 5  1 * * rootrm -f /var/spool/cron/lastrun/cron.monthly
 */10  *  * * *  roottest -x /usr/sbin/run-crons 
 /usr/sbin/run-crons
 #
 # rsnapshot cronjobs
 #
 30 11,14,17 * * * root   rsnapshot -c /etc/rsnapshot/myhost1.conf
 sync; rsnapshot -c /etc/rsnapshot/myhost1.conf hourly
 50 20 * * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf daily
 40 20 * * 6 rootrsnapshot -c /etc/rsnapshot/myhost1.conf weekly
 30 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf monthly
 20 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf yearly

Only the last line is wrong - your monthly and yearly are equivalent.To
be properly yearly, you need a month value in field 4.

I'm not familiar with rsnapshot, I assume that package can deal with how
many of each type of snapshot to retain in it's conf file? I see no
crons to delete out of date snapshots.


And, more as a nitpick than anything else, I always recommend that when
a sysadmin adds a root cronjob, use crontab -e so it goes in
/var/spool/cron, not /etc/crontab. Two benefits:

- syntax checking when you save and quit
- if you let portage, package managers, chef, puppet or whatever manage
your global cronjobs in /etc/portage, then there's no danger that system
will trash the stuff that you added there manually.

-- 
Alan McKinnon
alan.mckin...@gmail.com




Re: [gentoo-user] Hows this for rsnapshot cron jobs?

2013-04-21 Thread Tanstaafl

On 2013-04-21 4:32 PM, Alan McKinnon alan.mckin...@gmail.com wrote:

On 21/04/2013 20:47, Tanstaafl wrote:

30 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf monthly
20 20 1 * * rootrsnapshot -c /etc/rsnapshot/myhost1.conf yearly



Only the last line is wrong - your monthly and yearly are equivalent.To
be properly yearly, you need a month value in field 4.


Oh, right (I added that interval myself, rsnapshot only comes with the 
hourly, daily weekly and monthly by default).


So, if I wanted it to run at 8:20pm on Dec 31, it would be:

20 22 31 12 *  rootrsnapshot -c /etc/rsnapshot/myhost1.conf yearly


I'm not familiar with rsnapshot, I assume that package can deal with how
many of each type of snapshot to retain in it's conf file? I see no
crons to delete out of date snapshots.


Correct, rsnapshot handles this.


And, more as a nitpick than anything else, I always recommend that when
a sysadmin adds a root cronjob, use crontab -e so it goes in
/var/spool/cron, not /etc/crontab. Two benefits:

- syntax checking when you save and quit
- if you let portage, package managers, chef, puppet or whatever manage
your global cronjobs in /etc/portage, then there's no danger that system
will trash the stuff that you added there manually.


I prefer doing things manually... so, nothing else manages my cron jobs.

That said, I prefer to do this 'the gentoo way'... so is crontab -e the 
gentoo way?


;)