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

(-)a/misc/cronjobs/backup.sh (-11 / +10 lines)
Lines 1-22 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Script to create daily backups of the Koha database.
2
# Script to create daily backups of the Koha database.
3
# Based on a script by John Pennington
3
# Based on a script by John Pennington
4
5
DATABASE=`xmlstarlet sel -t -v 'yazgfs/config/database' $KOHA_CONF`
6
HOSTNAME=`xmlstarlet sel -t -v 'yazgfs/config/hostname' $KOHA_CONF`
7
PORT=`xmlstarlet sel -t -v 'yazgfs/config/port' $KOHA_CONF`
8
USER=`xmlstarlet sel -t -v 'yazgfs/config/user' $KOHA_CONF`
9
PASS=`xmlstarlet sel -t -v 'yazgfs/config/pass' $KOHA_CONF`
4
BACKUPDIR=`xmlstarlet sel -t -v 'yazgfs/config/backupdir' $KOHA_CONF`
10
BACKUPDIR=`xmlstarlet sel -t -v 'yazgfs/config/backupdir' $KOHA_CONF`
5
KOHA_DATE=`date '+%y%m%d'`
11
KOHA_DATE=`date '+%Y%m%d'`
6
KOHA_BACKUP=$BACKUPDIR/koha-$KOHA_DATE.sql.gz
12
KOHA_BACKUP=$BACKUPDIR/koha-$KOHA_DATE.sql.gz
7
13
8
mysqldump --single-transaction -u koha -ppassword koha | gzip -9 > $KOHA_BACKUP
14
mysqldump --single-transaction --user=$USER --password=$PASS --port=$PORT --host=$HOST $DATABASE| gzip -9 > $KOHA_BACKUP
9
10
#mv $KOHA_BACKUP /home/kohaadmin &&
11
#chown kohaadmin.users /home/kohaadmin/koha-$KOHA_DATE.dump.gz &&
12
#chmod 600 /home/kohaadmin/koha-$KOHA_DATE.dump.gz &&
13
# Makes the compressed dump file property of the kohaadmin user.
14
# Make sure that you replace kohaadmin with a real user.
15
15
16
if [ -f $KOHA_BACKUP ] ; then
16
if [ -f $KOHA_BACKUP ] ; then
17
echo "$KOHA_BACKUP was successfully created." | mail kohaadmin -s $KOHA_BACKUP
17
echo "$KOHA_BACKUP was successfully created." | mail $USER -s $KOHA_BACKUP
18
else
18
else
19
echo "$KOHA_BACKUP was NOT successfully created." | mail kohaadmin -s $KOHA_BACKUP
19
echo "$KOHA_BACKUP was NOT successfully created." | mail $USER -s $KOHA_BACKUP
20
fi
20
fi
21
21
22
# Notifies kohaadmin of (un)successful backup creation
22
# Notifies kohaadmin of (un)successful backup creation
23
- 

Return to bug 9235