If you combine this.......
Post by Christopher BarryOn Mon, 22 Feb 2016 11:33:46 -0600
Post by Milo GertjejansenHello all,
I am wondering if it's possible to run a script (only) after a weekly
backup.
My setup is such that I have 24 hourlies, seven dailies, four
weeklies, and 12 monthlies. Every week I would like to upload my new
weekly backup to backblaze. I could run a script through systemd timed
right after the weekly timer, but I want to try to use a
rsnapshot-built-in command first if possible.
If you need any more information, let me know.
Thanks!
--
Here it is, as a modified cron entry.
# /etc/cron.d/rsnapshot
# backup to RAID array
#
01 */4 * * * root /usr/bin/rsnapshot hourly
01 3 * * * root /usr/bin/rsnapshot daily
01 2 * * 1 root { /usr/bin/rsnapshot weekly && \
{ do_whatever || echo "do_whatever crashed"; } || \
echo "rsnapshot weekly crashed"; }
01 1 1 * * root /usr/bin/rsnapshot monthly
# end /etc/cron.d/rsnapshot
The solution is a simple extension of the cron line.
@ 2:01am cron fires off rsnapshot on it's weekly job as usual, but
because the line is enclosed in curly braces, cron is really firing off
everything between curly braces. They run serially.
'&&' means 'if true', and functions similar to ';' in that it
separates commands, so if rsnapshot finishes without an error, the next
command on the line executes. In this case, it's the 'do_whatever'
script you wrote that does whatever to push stuff to backblaze.
'||' means 'if false', so if either command fails, the echo'd response
The line above, that I have extended via '\' line continuation
characters, should probably be on a single line in your cron.d config.
Be mindful of the grouping with braces.
You could also create a simple script, put in it what I show above, and
run that in place of the modified line I show.
TMTOWTDI
Do this in a user cron (not a system cron as I show above) to test how
$ crontab -e
enter the cron entry line below *on a single line*, setting MIN (0-59)
and HOUR (0-23) to five minutes or so in the future, save it and exit
the editor.
MIN HOUR * * * { echo "hello world" >/tmp/crontmp.tmp; sleep 10 && echo
"hello world" >>/tmp/crontmp.tmp; }
$ crontab -l
will show if it's there.
$ tail -F /tmp/crontmp.tmp
hit enter, and it will say cannot open file, but it will wait for the
file to be created.
$ touch /tmp/crontmp.tmp
you will see tail find the file and open it in the first shell.
in the second shell again, type
$ watch ls -la /tmp/crontmp.tmp
and hit enter. watch will 'ls' the file every 2 seconds.
When the cron fires, you'll see the size go up in the watch window, and
'hello world' print in the tail window. 10 seconds later, it will
print another 'hello world'.
ctrl-c in both shells to exit the commands.
either remove the test cron entry, or delete the whole user crontab, if
$ crontab -r
then
$ rm /tmp/crontmp.tmp
Please forgive my grumpy attitude earlier. I needed a snickers...
--
Regards,
Christopher
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
rsnapshot-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/rsnapshot-discuss