@@ -, +, @@
- Run
$ koha-dump your_instance
- Save a copy of the dump files
- Apply the patch / extract the koha-dump script
- Run the new one:
$ koha-dump --include-indexes your_instance
(you can use -i too)
(i.e. it includes /var/lib/koha/your_instance)
- Run
$ koha-dump your_instance
- Go through the rest of the new option switches
-h | --help
-q | --quiet
- Sign off :-D
---
debian/docs/koha-dump.xml | 38 +++++++++++-
debian/scripts/koha-dump | 153 +++++++++++++++++++++++++++++++++++-----------
2 files changed, 152 insertions(+), 39 deletions(-)
--- a/debian/docs/koha-dump.xml
+++ a/debian/docs/koha-dump.xml
@@ -23,12 +23,46 @@
- koha-dump instancename
+ koha-dump
+
+ |
+ |
+ |
+
+ instancename
+
+ Options
+
+
+
+ |
+
+ Make koha-dump include Zebra indexes during the dump operation. This is useful for fast recovering Koha instances using koha-restore (i.e. there's no need to reindex your database). The drawback is that dumps tend to be a lot bigger and slower to create.
+
+
+
+
+ |
+
+ Make koha-dump run silently.
+
+
+
+
+ |
+
+ Show usage information.
+
+
+
+
+
+
Description
- Dump all contents and configs for a Koha site.
+ Dump all contents and configs for one or more Koha instances.
See also
--- a/debian/scripts/koha-dump
+++ a/debian/scripts/koha-dump
@@ -30,40 +30,119 @@ fi
# Make sure the files we create are not accessible by anyone else.
umask 0077
-# Parse command line.
-[ "$#" = 1 ] || die "Usage: $0 instancename"
-name="$1"
-kohaconfig="/etc/koha/sites/$name/koha-conf.xml"
-date="$(date +%Y-%m-%d)"
-
-echo "Dumping Koha site $name:"
-
-
-# Dump database.
-mysqlhost="$( xmlstarlet sel -t -v 'yazgfs/config/hostname' $kohaconfig )"
-mysqldb="$( xmlstarlet sel -t -v 'yazgfs/config/database' $kohaconfig )"
-mysqluser="$( xmlstarlet sel -t -v 'yazgfs/config/user' $kohaconfig )"
-mysqlpass="$( xmlstarlet sel -t -v 'yazgfs/config/pass' $kohaconfig )"
-backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' $kohaconfig || true )"
-[ -z "$backupdir" ] && backupdir="/var/spool/koha/$name"
-dbdump="$backupdir/$name-$date.sql.gz"
-echo "* DB to $dbdump"
-mysqldump --databases --host="$mysqlhost" \
- --user="$mysqluser" --password="$mysqlpass" "$mysqldb" |
- gzip > "$dbdump"
-chown "root:$name-koha" "$dbdump"
-chmod g+r "$dbdump"
-
-instancefile="$name.conf"
-
-# Dump configs, logs, etc.
-metadump="$backupdir/$name-$date.tar.gz"
-echo "* configs, logs to $metadump"
-tar -C / -czf "$metadump" \
- "etc/koha/sites/$name" \
- "etc/apache2/sites-available/$instancefile" \
- "etc/apache2/sites-enabled/$instancefile" \
- "var/lib/koha/$name" \
- "var/log/koha/$name"
-
-echo "Done."
+usage()
+{
+ local scriptname=$(basename $0)
+
+ cat < "$dbdump"
+ chown "root:$name-koha" "$dbdump"
+ chmod g+r "$dbdump"
+
+ instancefile="$name.conf"
+
+ # Dump configs, logs, etc.
+ metadump="$backupdir/$name-$date.tar.gz"
+ [ "$quiet" = "no" ] && echo "* configs, logs to $metadump"
+
+ zebra_files=""
+ if [ "$include_indexes" = "yes" ]
+ zebra_files="var/lib/koha/$name"
+ fi
+
+ tar -C / -czf "$metadump" \
+ "etc/koha/sites/$name" \
+ "etc/apache2/sites-available/$instancefile" \
+ "etc/apache2/sites-enabled/$instancefile" \
+ "var/log/koha/$name" "$zebra_files"
+
+ [ "$quiet" = "no" ] && echo "Done."
+}
+
+# Default values
+quiet="no"
+include_indexes="no"
+
+while [ $# -gt 0 ]; do
+
+ case "$1" in
+ -i|--include-indexes)
+ include_indexes="yes"
+ shift ;;
+ -h|--help)
+ usage ; exit 0 ;;
+ -q|--quiet)
+ quiet="yes"
+ shift ;;
+ -*)
+ die "Error: invalid option switch ($1)" ;;
+ *)
+ # We expect the remaining stuff are the instance names
+ break ;;
+ esac
+
+done
+
+# Read instance names
+if [ $# -gt 0 ]; then
+ # We have at least one instance name
+ for name in "$@"; do
+
+ if is_instance $name; then
+
+ dump_instance $name
+
+ else
+ if [ "$quiet" = "no" ]; then
+ die "Error: Invalid instance name $name"
+ else
+ exit 1
+ fi
+ fi
+
+ done
+else
+ if [ "$quiet" = "no" ]; then
+ die "Error: you must provide at least one instance name"
+ else
+ exit 1
+ fi
+fi
+
+exit 0
--