2 # Script to create daily backups of the Koha database.
3 # Based on a script by John Pennington
4 KOHA_DATE
=`date '+%y%m%d'`
5 KOHA_DUMP
=/tmp
/koha-
$KOHA_DATE.dump
6 KOHA_BACKUP
=/tmp
/koha-
$KOHA_DATE.dump.gz
8 mysqldump
--single-transaction -u koha
-ppassword koha
> $KOHA_DUMP &&
10 # Creates the dump file and compresses it;
11 # -u is the Koha user, -p is the password for that user.
12 # The -f switch on gzip forces it to overwrite the file if one exists.
14 mv $KOHA_BACKUP /home
/kohaadmin
&&
15 chown kohaadmin.users
/home
/kohaadmin
/koha-
$KOHA_DATE.dump.gz
&&
16 chmod 600 /home
/kohaadmin
/koha-
$KOHA_DATE.dump.gz
&&
17 # Makes the compressed dump file property of the kohaadmin user.
18 # Make sure that you replace kohaadmin with a real user.
20 echo "$KOHA_BACKUP was successfully created." |
mail kohaadmin
-s $KOHA_BACKUP ||
21 echo "$KOHA_BACKUP was NOT successfully created." |
mail kohaadmin
-s $KOHA_BACKUP
22 # Notifies kohaadmin of (un)successful backup creation