#420534 Anacron-like scheduling for desktop systems

#420534#5
Date:
2007-04-23 01:06:32 UTC
From:
To:
--- Please enter the report below this line. ---
I don't always have my system powered up when backupninja is set to run my
local rdiff-backup backup.  It would be nice if backupninja could use
Anacron, or some Anacron-like logic, so I could specify a frequency
of "daily" or "every 24 hours," and then have backupninja run it if that much
time has passed since the last backup was run, regardless of what time it is
at the moment.

Debian Release: testing/unstable
  900 testing         ftp.us.debian.org
  900 testing         ftp.sunet.se
  800 unstable        ftp.us.debian.org
  800 unstable        ftp.sunet.se
  500 stable          security.debian.org
  500 edgy-cafuego    ubuntu.cafuego.net
  500 edgy            wine.budgetdedicated.com
    1 experimental    ftp.us.debian.org
--- Package information. ---
Depends          (Version) | Installed
==========================-+-==============
gawk                       | 1:3.1.5.dfsg-4
 OR mawk                   | 1.3.3-11
dialog                     | 1.0-20060221-3
bash         (>= 2.05b-26) | 3.1dfsg-8

#420534#10
Date:
2007-11-02 01:03:27 UTC
From:
To:
* Adam Porter <adam@alphapapa.net> [071102 00:56]:


Hi,

Please correct me if I misunderstand you, but I believe that this
functionality already exists in backupninja.

The backupninja cron runs every hour and although the default value for
'when' in /etc/backupninja.conf is "everyday at 01:00" you could change
that to be something that works for you, such as: when = hourly, or
specify multiple 'when' options so that the backup will fire at a time
that you are likely to have your laptop on (if multiple 'when'options
are present, then they all apply). See backup.d(5) SCHEDULING section.

Or, you could use anacron with a job that on wakeup of your laptop
simply does a backupninja --now.

Micah

#420534#15
Date:
2007-11-02 01:03:27 UTC
From:
To:
* Adam Porter <adam@alphapapa.net> [071102 00:56]:


Hi,

Please correct me if I misunderstand you, but I believe that this
functionality already exists in backupninja.

The backupninja cron runs every hour and although the default value for
'when' in /etc/backupninja.conf is "everyday at 01:00" you could change
that to be something that works for you, such as: when = hourly, or
specify multiple 'when' options so that the backup will fire at a time
that you are likely to have your laptop on (if multiple 'when'options
are present, then they all apply). See backup.d(5) SCHEDULING section.

Or, you could use anacron with a job that on wakeup of your laptop
simply does a backupninja --now.

Micah

#420534#20
Date:
2007-11-09 21:18:14 UTC
From:
To:
I don't necessarily want to run backupninja every hour, or even more
than once a day.  I simply want it to run if it's been 24 hours or
more since the last time it was run.  Running rdiff-backup can be CPU-
and IO-intensive.  I have manually niced and ioniced it down, but we
shouldn't expect users to have to do that.  I don't need or want it to
run that often, anyway.

And I don't think running --now on wakeup of a laptop would
necessarily be a good idea.  If someone sleeps and wakes their laptop
several times a day...

#420534#25
Date:
2007-11-16 04:33:35 UTC
From:
To:
* Adam Porter <adam@alphapapa.net> [071109 13:18]:

The only solution I can think of is to write a cronjob that checks the
timestamp on the backupninja.log file and if its been 24 hours, then
initiate a backup immediately.

This isn't likely to be functionality added to backupninja. Most people
want their backups to run at night, typically because of the resources
required to do the backup itself slow down normal work (disk, cpu and
bandwidth) and you dont want that happening while you are trying to get
things done. If you have something setup to just run 24 hours after the
last backup, you are eventually going to skew into having a backup run
right in the middle of the day when its inconvenient.

I think there really isn't a solution to this that would work for every
person's vast and varied schedule, except for individuals to schedule
the time for the backup that works best for their situation. If you put
your laptop to sleep every night, then once a week just remember not to
put it to sleep so a backup can run, or whatever you are comfortable
with.

If you can come up with a good mechanism, I'm happy to include it, but
from where I am sitting this smacks me as a technical solution to a
non-technical problem.

I agree. The problem is I can think of a solution that wont work for at
least someone.

Micah

#420534#32
Date:
2013-08-27 08:14:13 UTC
From:
To:
SNIP

Hi.

I think I may have found a way to implement this.

It will involve setting up :

1. an anacron job that triggers :
  1       60      backup.daily    backupninja -f /etc/backupninja.conf.anacron -n --run /etc/backup.d/94.rdiff

 The specific backupninja.conf file is suppressing the colored output un debug mode, and ideally would also unset the debug details : --run sets the debug mode, but that isn't very handy when anacron reports via mail, in particular if backup is successful.
 As a backup may still be running when anacron triggers it (for instance on AC power returning), the backup may fail because it can't acquire the lock, but this should probably not be reported as a failure in the cron's report mailed to root.
 This could be improved by using cronic to wrat the execution, and check that the output is different from a non-failing case...
 I'm starting it 60 minutes after bootup to avoid messing too much with may daily routine, but this could be adjusted.

2. another backup.d special job set to execute after the rdiff backup (following my example), as 94_zzz_01.sh, which will have the same when that the preceding 94.rdiff, and which will set the timestamp of the anacron job, to flag that the cronjob has been started, and anacron doesn't need to care for the rest of that day, by issueing a "anacron -u backup.daily".

For instance :
#!/bin/sh

# 6 minutes after 94.rdiff, we will notify anacron that it shall not run 94 today

when = everyday at 22:00
when = everyday at 12:00

sleep 360

# notify anacron that backup.daily doesn't need to run today
anacron -u backup.daily


I'm not completely sure this is bullet-proof, but somehow, that should ensure that I get backups done every noon or 10PM, or 1 hour after bootup, if I wake up sooner than 11 ;-)

This needs to be tested, in particular regarding the error/success reports anacron should send to root by mail...

Any remarks/comments much welcome.

Best regards,