Changes

stoney backup: Service Software

435 bytes added, 12:15, 26 June 2014
/* writeAccountSize.pl */
* Depending on the users settings in the LDAP directory, warning mail will be sent to the reseller, customer or user, if a backup was not executed on time.
All these scripts are installed to <code>/usr/libexec/backup-utils/</code> by the <code>sys-apps/sst-backup-utils</code> package (see [[stoney_backup:_Server_set-up#backup_utils | backup-utils]]).The source code can be found on [https://github.com/stepping-stone/backup-utils github]
== writeAccountSize.pl ==
This script is installed to <code>/usr/libexec/backup-utils/writeAccountSize.pl</code> by the <code>sys-apps/sst-backup-utils</code> package and does the following:
@PAT: Please add a link to the current Git repository. --[[User:Chrigu|Chrigu]] ([[User talk:Chrigu|talk]]) 10:15, 19 June 2014 (CEST)
* Calculates the used disk space (backup and iterations) for a given account and writes the corresponding values to:
*# The LDAP backend (used by the selfcare webinterface to display quota information):
As you can see, the total used space has risen to 39.0625.
 
=== Cronjobs ===
After making sure, that everything worked as planned, you can update your crontab entry:
crontab -e
<pre>
...
# Rsnapshot for all users
30 22 * * * /usr/libexec/backup-utils/snapshot.pl --interval daily
15 22 * * sun /usr/libexec/backup-utils/snapshot.pl --interval weekly
00 22 1 * * /usr/libexec/backup-utils/snapshot.pl --interval monthly
...
</pre>
 
* TBD: Maybe this is not optimal if there is a lot of data to rotate. In this case, it might be that for example weekly and daily snapshot both run at the same time what might lead to strange results.
* Workarounds:
** Simple/short version: Instead one could create another wrapper script which is called everyday and does some simple logic:
** Is today the first day of a month?
*** Yes: Is today sunday?
**** Yes: Execute monthly then weekly then daily rsnapshots using the snapshot.pl script (but wait for each interval to finish before starting the next)
**** No: Execute monthly then daily rsnapshots using the snapshot.pl script (but wait for monthly interval to finish before starting the daily)
*** No: Is today sunday?
**** Yes: Execute weekly then daily rsnapshots using the snapshot.pl script (but wait for weekly interval to finish before starting the daily)
**** No: Execute daily rsnapshots using the snapshot.pl script
** Complex/long version: Adapt the snapshot.pl script and call it every day without interval parameter. The script does the logic described above.
This avoids the above mentioned collision
 
(Complex) / short version: rule via cronjobs:
<pre>
# Rsnapshot for all users
30 22 * * 1-6 [ $( date +\%d ) -gt 1 ] && /usr/libexec/backup-utils/snapshot.pl --interval daily
15 22 * * 7 [ $( date +\%d ) -gt 1 ] && /usr/libexec/backup-utils/snapshot.pl --interval weekly && /usr/libexec/backup-utils/snapshot.pl --interval daily
00 22 1 * * /usr/libexec/backup-utils/snapshot.pl --interval monthly && /usr/libexec/backup-utils/snapshot.pl --interval weekly && /usr/libexec/backup-utils/snapshot.pl --interval daily
...
</pre>
== scheduleWarning.pl ==
</pre>
== snapshotWrapper.pl ==
As the [[stoney_backup:_Service_Software#snapshot.pl | snapshot.pl]] script needs to be called for each interval sequentially (see [http://www.rsnapshot.org/rsnapshot.html#usage rsnapshot] for more information about rsnapshot execution) a script is needed which does the following logic
* Is today the first day of a month?
** Yes: Is today sunday?
*** Yes: Execute monthly then weekly then daily rsnapshots using the snapshot.pl script (but wait for each interval to finish before starting the next)
*** No: Execute monthly then daily rsnapshots using the snapshot.pl script (but wait for monthly interval to finish before starting the daily)
** No: Is today sunday?
*** Yes: Execute weekly then daily rsnapshots using the snapshot.pl script (but wait for weekly interval to finish before starting the daily)
*** No: Execute daily rsnapshots using the snapshot.pl script
This is all the snapshotWrapper.pl script does. It calls the [[stoney_backup:_Service_Software#snapshot.pl | snapshot.pl]] with the correct intervals for the given day sequentially
* Pod documentation:
<pre>
NAME
snapshot.pl
 
DESCRIPTION
This script ensures that the rsnapshot processes for the different
intervals (daily, weekly and monthly) are running sequentially. To do
so, the script gets todays date and performs some checks:
 
Is today the first day of the month?
Execute the monthly snapshots and wait for this process to finish.
Check if today is sunday, if yes execute the weekly snapshots wait
for the process to finish and finally execute the daily snapshots.
If today is not sunday, only execute the daily snapshots.
 
Is today sunday?
Execute the weekly snapshots and wait for this process to finsh.
Then execute the daily snapshots.
 
If no of the above checks were successful
Simply execute the daily snapshots.
 
The checks are performed in the above mentioned order, if one check is
successful, the following criterias are not checked anymore. That is how
one can ensure that all necessary rsnapshot processes run squentially
 
USAGE
./snapshotWrapper.pl
 
CREATED
2014-06-19 pat.klaey@stepping-stone.ch created
 
VERSION
2014-06-19 pat.klaey@stepping-stone.ch created
 
INCORPORATED CODE
Incorporated code with use:
 
warnings;
strict;
DateTime;
PerlUtil::Logging;
File::Basename;
</pre>
 
'''Note''': This script does not need any configuration.
== rsnapshot wrapper bash scripts ==
There are two rsnapshot wrapper scripts (these are bash scripts), they are installed by the <code>sys-apps/sst-backup-utils</code> package:
486
edits