View | Details | Raw Unified | Return to bug 6275
Collapse All | Expand All

(-)a/debian/koha-common.cron.daily (+1 lines)
Lines 22-24 koha-foreach --enabled /usr/share/koha/bin/cronjobs/holds/cancel_expired_holds.p Link Here
22
koha-foreach --enabled /usr/share/koha/bin/cronjobs/services_throttle.pl > /dev/null 2>&1
22
koha-foreach --enabled /usr/share/koha/bin/cronjobs/services_throttle.pl > /dev/null 2>&1
23
koha-foreach --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10
23
koha-foreach --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10
24
koha-foreach --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail
24
koha-foreach --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail
25
koha-run-backups --days 2 --output /var/spool/koha
(-)a/debian/koha-common.install (+1 lines)
Lines 22-27 debian/scripts/koha-remove usr/sbin Link Here
22
debian/scripts/koha-reset-passwd            usr/sbin
22
debian/scripts/koha-reset-passwd            usr/sbin
23
debian/scripts/koha-restart-zebra           usr/sbin
23
debian/scripts/koha-restart-zebra           usr/sbin
24
debian/scripts/koha-restore                 usr/sbin
24
debian/scripts/koha-restore                 usr/sbin
25
debian/scripts/koha-run-backups             usr/sbin
25
debian/scripts/koha-start-zebra             usr/sbin
26
debian/scripts/koha-start-zebra             usr/sbin
26
debian/scripts/koha-stop-zebra              usr/sbin
27
debian/scripts/koha-stop-zebra              usr/sbin
27
debian/scripts/koha-upgrade-schema          usr/sbin
28
debian/scripts/koha-upgrade-schema          usr/sbin
(-)a/debian/scripts/koha-run-backups (-1 / +93 lines)
Line 0 Link Here
0
- 
1
#!/bin/sh
2
# Copyright 2010-2011  Catalyst IT, Ltd
3
# 
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
# 
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
# 
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
# Daily cron job for koha.
18
# - dump all sites, except one called 'demo'
19
20
dirname="/var/spool/koha"
21
days="2"
22
23
show_help() {
24
    cat <<EOH
25
$0 - performs backups of the koha installations on the system
26
27
This allows automation of backing up the koha data and configuration to the
28
filesystem. It will keep the past so many backups, discarding older ones.
29
30
Options:
31
    --output:   the directory that the resulting files will be placed into.
32
                (default: /var/spool/koha)
33
    --days:     the number of days to keep backups around for
34
                (default: 2)
35
36
Note: backups produced using this tool can be restored using \`koha-restore'.
37
EOH
38
}
39
40
CMD_LINE=`getopt -o h --long days:,output:,help -n 'koha-run-backups' -- "$@"`
41
42
if [ $? != 0 ] ; then show_help ; exit 1 ; fi
43
44
eval set -- "$CMD_LINE"
45
while true ; do
46
    case "$1" in
47
        -h|--help)
48
            show_help; exit;;
49
        --days)
50
            days=$2; shift 2 ;;
51
        --output)
52
            dirname=$2; shift 2 ;;
53
        --) shift ; break ;;
54
        *) echo "Unknown error parsing the command line!" ; exit 1 ;;
55
    esac
56
done
57
58
for name in $(koha-list --enabled | grep -Fxv demo)
59
do
60
    koha-dump "$name" > /dev/null
61
62
    # Remove old dump files.
63
    # FIXME: This could probably be replaced by one line of perl.
64
    ls "$dirname/$name/" | 
65
    sed "s:^$name-\([0-9-]*\)\.\(sql\|tar\)\.gz$:\1:" |
66
    sort -u |
67
    tac |
68
    sed "1,${days}d" |
69
    tac |
70
    while read date
71
    do
72
        tardump="$dirname/$name/$name-$date.tar.gz"
73
        sqldump="$dirname/$name/$name-$date.sql.gz"
74
        if [ -e "$tardump" ] && [ -e "$sqldump" ]
75
        then
76
            rm "$tardump"
77
            rm "$sqldump"
78
        elif [ -e "$tardump" ] || [ -e "$sqldump" ]
79
        then
80
            echo "Only one of a pair exists! Not removing it."
81
            for x in "$tardump" "$sqldump"
82
            do
83
                if [ -e "$x" ]
84
                then
85
                    echo "Exists        : $x"
86
                else
87
                    echo "Does not exist: $x"
88
                fi
89
            done
90
        fi
91
    done
92
done
93

Return to bug 6275