Discussion:
[rsnapshot-discuss] Run script after weekly backup
Milo Gertjejansen
2016-02-22 17:33:46 UTC
Permalink
Hello 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!

--
***@milogert.com
Gabriel Davini
2016-02-22 18:13:51 UTC
Permalink
Post by Milo Gertjejansen
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 use separated config files for each interval, you can add your
script as cmd_postexec.

Else you can run your script from crontab itself, something like:

@weekly rsnapshot -c rsnapshot_weekly.conf weekly && my_postexec_script

Hope it helps
--
Gabriel.
Ken Woods
2016-02-22 18:30:30 UTC
Permalink
And



.What's wrong with a cron job?

And by that I mean call your weekly job as a shell script where it first runs the weekly and secondly runs whatever script runs your backblaze back up.

Put in if statement in there that only runs the backblaze on success of the weekly.

I'm currently driving but if nobody else has given you what you need in a couple of hours let me know and I will write it for you.
Post by Milo Gertjejansen
Hello 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!
--
------------------------------------------------------------------------------
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
Milo Gertjejansen
2016-02-22 18:32:57 UTC
Permalink
I could do that and may opt for it. My issue with it is that it's "loosely"
connected to rsnapshot rather than actually ran by rsnapshot.

A good solution someone else posted was to use multiple config files (which
I was unaware that you could even do) and just have the weekly one
separated out to run the postexec script that uploads to backblaze.
Post by Ken Woods
And



.What's wrong with a cron job?
And by that I mean call your weekly job as a shell script where it first
runs the weekly and secondly runs whatever script runs your backblaze back
up.
Put in if statement in there that only runs the backblaze on success of the weekly.
I'm currently driving but if nobody else has given you what you need in a
couple of hours let me know and I will write it for you.
Hello 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!
--
------------------------------------------------------------------------------
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
--
Milo Gertjejansen

Phone: (952) 412-5004
Email: ***@milogert.com
Ken Woods
2016-02-22 18:40:17 UTC
Permalink
.......Which also doesn't check for success, IIRC.
I could do that and may opt for it. My issue with it is that it's "loosely" connected to rsnapshot rather than actually ran by rsnapshot.
A good solution someone else posted was to use multiple config files (which I was unaware that you could even do) and just have the weekly one separated out to run the postexec script that uploads to backblaze.
Post by Ken Woods
And



.What's wrong with a cron job?
And by that I mean call your weekly job as a shell script where it first runs the weekly and secondly runs whatever script runs your backblaze back up.
Put in if statement in there that only runs the backblaze on success of the weekly.
I'm currently driving but if nobody else has given you what you need in a couple of hours let me know and I will write it for you.
Post by Milo Gertjejansen
Hello 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!
--
------------------------------------------------------------------------------
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
--
Milo Gertjejansen
Phone: (952) 412-5004
Christopher Barry
2016-02-22 23:12:27 UTC
Permalink
On Mon, 22 Feb 2016 12:32:57 -0600
Post by Milo Gertjejansen
I could do that and may opt for it. My issue with it is that it's
"loosely" connected to rsnapshot rather than actually ran by rsnapshot.
This is the *ENTIRE* philosophy of *NIX!!!
Building up solutions by loosely connecting simple parts together!
Why are you even *USING* Linux!? Because it was free as in free beer?
Post by Milo Gertjejansen
I could run a script through systemd timed
Seriously!? systemd is taking over cron on top of everything else now
too? Un-f-ing-believable. No wonder you have no idea of what to do,
since your idea of a cronjob is 'systemd timed', your idea of an OS is
WinMac, *and* your idea of how to use a mailing list is to top-post.

*heavy, pained, sigh*.
Milo Gertjejansen
2016-02-23 00:01:32 UTC
Permalink
Post by Christopher Barry
Post by Milo Gertjejansen
I could do that and may opt for it. My issue with it is that it's
"loosely" connected to rsnapshot rather than actually ran by rsnapshot.
This is the *ENTIRE* philosophy of *NIX!!!
Sure, that's fine that it might be the philosophy of *nix, but rsnapshot
does offer a way to run the scripts after particular backup so I figured I
would take advantage of the available feature. Hopefully nothing wrong with
that there. Whether or not the script runs after a failure (for whatever
reason) is up for debate and I am still looking into it.
Post by Christopher Barry
Post by Milo Gertjejansen
I could run a script through systemd timed
Seriously!? systemd is taking over cron on top of everything else now
too? Un-f-ing-believable.
Again, systemd offers timers as a feature. The reason I want systemd is
because, *for me*, it's easy to set up and maintain. Systemd timers are
also useful in that I am doing full system backups and sometimes there are
folders that my normal operating user cannot access automatically without
elevated privileges.

I understand the cron could be used for this but I chose to use systemd. If
there is a real advantage to using cron I will certainly look at it, but so
far I couldn't see any pro- for such a simple use case.
Post by Christopher Barry
your idea of how to use a mailing list is to top-post.
*heavy, pained, sigh*.
Obviously you would not know this, but I have never posted to a mailing
list. Thankfully from your response I was able to learn something about
posting etiquette. Sadly I do not have a very good first impression of them.
Patrick O'Callaghan
2016-02-23 00:28:53 UTC
Permalink
On 22 February 2016 at 23:12, Christopher Barry <
Post by Christopher Barry
Seriously!? systemd is taking over cron on top of everything else now
too? Un-f-ing-believable. No wonder you have no idea of what to do,
since your idea of a cronjob is 'systemd timed', your idea of an OS is
WinMac, *and* your idea of how to use a mailing list is to top-post.
*heavy, pained, sigh*.
It's also part of list netiquette to avoid emotive and supercilious
language. Insulting people who may be unfamiliar with Unix or list
conventions is not the way to win friends and influence people. These
things can be pointed out without sneering at the questioner.

I can't help noticing that you don't actually answer the OP's question.

poc
Scott Hess
2016-02-23 03:24:43 UTC
Permalink
There is nothing magic about having rsnapshot run it, though, and having a
new config file adds a new place for things to go wrong, a new place to
look for things that are happening, etc. If I were doing this myself, I
would either take this cron job:
30 3 * * 0 /usr/bin/rsnapshot weekly
and change it to:
30 3 * * 0 /path/to/my_rsnapshot_wrapper weekly
where the new path runs rsnapshot with the parameters passed through, or I
would change it to:
30 3 * * 0 /usr/bin/rsnapshot weekly && /path/to/my_backup_thing
/.snapshots/weekly.0 my_backup_target
That way I could easily shift to daily or monthly, etc.

-scott
Post by Milo Gertjejansen
I could do that and may opt for it. My issue with it is that it's
"loosely" connected to rsnapshot rather than actually ran by rsnapshot.
A good solution someone else posted was to use multiple config files
(which I was unaware that you could even do) and just have the weekly one
separated out to run the postexec script that uploads to backblaze.
Post by Ken Woods
And



.What's wrong with a cron job?
And by that I mean call your weekly job as a shell script where it first
runs the weekly and secondly runs whatever script runs your backblaze back
up.
Put in if statement in there that only runs the backblaze on success of the weekly.
I'm currently driving but if nobody else has given you what you need in a
couple of hours let me know and I will write it for you.
Hello 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!
--
------------------------------------------------------------------------------
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
--
Milo Gertjejansen
Phone: (952) 412-5004
------------------------------------------------------------------------------
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
Christopher Barry
2016-02-23 04:06:49 UTC
Permalink
On Mon, 22 Feb 2016 11:33:46 -0600
Post by Milo Gertjejansen
Hello 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.

Let's break it down:

@ 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
is sent in cron's email to ***@box, which ideally you're forwarding to
***@box, and again ideally monitoring.

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
it works:

at a shell prompt:
$ 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.

Now, open two shells. In one, enter:
$ tail -F /tmp/crontmp.tmp

hit enter, and it will say cannot open file, but it will wait for the
file to be created.

In the other, enter:
$ 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
nothing is in it, with:
$ crontab -r
then
$ rm /tmp/crontmp.tmp


Please forgive my grumpy attitude earlier. I needed a snickers...
--
Regards,
Christopher
Ken Woods
2016-02-23 04:50:15 UTC
Permalink
If you combine this.......
Post by Christopher Barry
On Mon, 22 Feb 2016 11:33:46 -0600
Post by Milo Gertjejansen
Hello 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
Helmut Hullen
2016-02-23 04:26:00 UTC
Permalink
Hallo, Christopher,
Post by Christopher Barry
Post by Milo Gertjejansen
I am wondering if it's possible to run a script (only) after a
weekly backup.
[...]
Post by Christopher Barry
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.
My usual way: a "wrapper" script, which is called as a cron job.

Such script is easier to debug than such a cron monster line.

Viele Gruesse!
Helmut
Ken Woods
2016-02-23 04:51:10 UTC
Permalink
.....and this, you'd come up with exactly what I suggested 12 hours ago.


That's what I'd do.

Also, systemd fucking sucks.
Post by Helmut Hullen
Hallo, Christopher,
Post by Christopher Barry
Post by Milo Gertjejansen
I am wondering if it's possible to run a script (only) after a
weekly backup.
[...]
Post by Christopher Barry
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.
My usual way: a "wrapper" script, which is called as a cron job.
Such script is easier to debug than such a cron monster line.
Viele Gruesse!
Helmut
------------------------------------------------------------------------------
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
Loading...